summaryrefslogtreecommitdiff
path: root/bin/aux
diff options
context:
space:
mode:
Diffstat (limited to 'bin/aux')
-rwxr-xr-xbin/aux/addwuser.rc33
-rwxr-xr-xbin/aux/bpst.rc64
-rwxr-xr-xbin/aux/gensitemaptxt.rc14
-rwxr-xr-xbin/aux/runtsts.rc16
4 files changed, 127 insertions, 0 deletions
diff --git a/bin/aux/addwuser.rc b/bin/aux/addwuser.rc
new file mode 100755
index 0000000..9364d39
--- /dev/null
+++ b/bin/aux/addwuser.rc
@@ -0,0 +1,33 @@
+#!/bin/rc
+
+if(! ~ $#werc_root 0)
+ cd $werc_root
+
+fn usage {
+ if(! ~ $#* 0)
+ echo $0: $* >[1=2]
+ echo 'Usage:' $0 'user_name user_password [groups ...]' >[1=2]
+ exit usage
+}
+
+if(! test -d etc/users/)
+ usage 'Run for root of werc installation or set $werc_root'
+
+user_name=$1
+shift
+user_pass=$1
+shift
+user_groups=$*
+
+if(~ $"user_name '' || ~ $"user_pass '')
+ usage
+
+mkdir etc/users/$user_name
+echo $user_pass > etc/users/$user_name/password
+
+if(! ~ $#user_groups 0)
+ for(g in $user_groups) {
+ mkdir -p etc/users/$g
+ echo $user_name >> etc/users/$g/members
+ }
+
diff --git a/bin/aux/bpst.rc b/bin/aux/bpst.rc
new file mode 100755
index 0000000..e60d034
--- /dev/null
+++ b/bin/aux/bpst.rc
@@ -0,0 +1,64 @@
+#!/bin/rc
+
+path=( $PLAN9/bin $path )
+base=.
+
+if(~ $#user 0)
+ user=`{whoami}
+
+file=(); title=();
+bloguser=$user
+while(! ~ $#* 0) {
+ switch($1) {
+ case -u
+ base=/gsoc/www/people/$user/blog/
+ case -b
+ shift
+ base=$1
+ case -f
+ shift
+ file=$1
+ }
+ shift
+}
+
+if(~ $"EDITOR '')
+ EDITOR=vi
+
+if(~ $#file 0 || ! test -f $file) {
+ file=/tmp/blogtmp.$pid
+ rm $file >[2]/dev/null
+ touch $file
+}
+
+$EDITOR $file
+ispell $file
+rm $file.bak >[2]/dev/null
+
+fn mkbpost {
+ umask 002 # Let group write
+ bptext=$1
+ if(! ~ $#2 0)
+ bpid=`{echo -n '-'^$"bpid | sed 's/'$forbidden_uri_chars'+/_/g; 1q'}
+ d=`{/bin/date +%F|sed 's,-,/,g'}
+
+ ddir=$blagh_root^$d^'/'
+ n=`{ls $ddir >[2]/dev/null |wc -l}
+
+ mkdir -p $ddir/$"n^$"bpid/
+ {
+ # TODO: Enable metadata
+ #echo '* Posted:' `{date}
+ #if(! ~ $#logged_user 0)
+ # echo '* Author: '$logged_user
+ cat $bptext
+ }> $ddir/$"n^$"bpid/index.md
+}
+
+forbidden_uri_chars='[^a-zA-Z0-9_+\-\/\.]'
+blagh_root=$base
+
+if(test -s $file)
+ mkbpost $file
+if not
+ echo Empty file!
diff --git a/bin/aux/gensitemaptxt.rc b/bin/aux/gensitemaptxt.rc
new file mode 100755
index 0000000..a1b349d
--- /dev/null
+++ b/bin/aux/gensitemaptxt.rc
@@ -0,0 +1,14 @@
+#!/bin/rc
+# DEPRECATED: sitemap.tpl now generates and updates a sitemap.txt when requested, and is also more smart than this simplistic script.
+
+for(d in sites/*/) {
+echo $d
+9 du -a $d | awk '/\.(md|html)$/ { print $2 }; {}' | 9 sed -e 's/\.(md|html)$//' -e 's,/index$,/,' -e 's,^sites/,http://,' > $d/sitemap.txt
+
+if(! test -f $d/robots.txt) {
+ echo generating missing robots.txt for $d
+ echo $d|sed 's,sites/,Sitemap: http://,; s/$/sitemap.txt/;' > $d/robots.txt
+ cat $d/robots.txt
+}
+
+}
diff --git a/bin/aux/runtsts.rc b/bin/aux/runtsts.rc
new file mode 100755
index 0000000..b5b1df7
--- /dev/null
+++ b/bin/aux/runtsts.rc
@@ -0,0 +1,16 @@
+#!/bin/rc
+
+tstdom='http://test.cat-v.org'
+
+cd sites/tst.cat-v.org
+
+tstfiles=`{du -a |awk '/\.tst$/ { print $2 }; {} ' | sed 's/^\.//; s/\.tst$//'}
+
+for(f in $tstfiles) {
+ ifs='
+' { tsts=`{cat ./$f.tst} }
+
+ for(t in $tsts) {
+ echo tst $t
+ }
+}