shithub: 9scripts

ref: 44169dbfddf55a45fdef6d9cb813034aacdf0273
dir: /gridstart/

View raw version
#!/bin/rc
# connects to 9gridchan grid services and starts a new subrio
# options -t tls -m mountonly -s scriptonly
# awk '/exportfs/{print "srv -c", $1, $3, $5}' /mnt/registry/index

fn cpl{
	cp $1 /n/griddisk/cpl
	ptarg=`{basename $1}
	plumb http://wiki.9gridchan.org/incoming/cpl/$ptarg
}

fn error{
	echo An error ocurred.
	exit
}

while (~ $1 -*){
	switch($1){
	case -t
		tls = yes
		shift
	case -m
		mountonly = yes
		shift
	case -s
		scriptonly = yes
		shift
	case *
		echo bad flag $1 >>[1=2]
		shift
	}
}

if(test -e /srv/gridregistry){
	echo 'old grid connections found in /srv, remove? (y/n)'
	ans=`{read}
	if(~ $ans y){
		rm /srv/gridchat
		rm /srv/gridplumber
		rm /srv/gridram
		rm /srv/gridregistry
		rm /srv/gridroot
		rm /srv/gridwiki
		rm /srv/griddisk
		rm /srv/pubregistry
	}
}		

if(~ $tls yes){
	auth/factotum
	echo 'key proto=dp9ik user=glenda dom=grid !password=9gridchan' >/mnt/factotum/ctl
	srvtls tcp!registry.9gridchan.org!16675 gridregistry /mnt/registry || error
	awk '/tlssrv/{print "srvtls -c", $1, $3, $5}' /mnt/registry/index >/tmp/gridscript
#	cat /mnt/registry/index |grep tlssrv |sed 's/^/srvtls -c /g' |sed 's/is //g' |sed 's/mountpoint //g' |sed 's/service.*$//g' >/tmp/gridscript
}
if(! ~ $tls yes){
	srv tcp!registry.9gridchan.org!6675 gridregistry /mnt/registry || error
	awk '/exportfs/{print "srv -c", $1, $3, $5}' /mnt/registry/index >/tmp/gridscript
#	cat /mnt/registry/index |grep exportfs |sed 's/^/srv -c /g' |sed 's/is //g' |sed 's/mountpoint //g' |sed 's/service.*$//g' >/tmp/gridscript
}

if(~ $scriptonly yes){
	echo 'script saved in /tmp/gridscript'
	cat /tmp/gridscript
	exit
}

. /tmp/gridscript

if(~ $mountonly yes){
	echo 'grid services mounted'
	exit
}

if(test -e /bin/grio)
	srio=(grio -s -c 0x99009900)
if not
	srio=(rio -s)

echo '#!/bin/rc
window -r 0 0 700 400 chat
window -r 700 0 1300 400 acme -l/tmp/gridacme
window -r 0 400 700 750 mothra -a http://wiki.9gridchan.org/message_board
window -r 700 400 1300 750 page /n/gridroot/lib/musicant.png
' >/tmp/gridrio

chmod +x /tmp/gridrio
if(! test -e /mnt/web/ctl)
	webfs

echo '/usr/glenda
/lib/font/bit/vga/unicode.font
/lib/font/bit/vga/unicode.font
          0          66
f          1           1          36          36           3 
          1          33          36           1           0 /n/griddisk/ Del Snarf Get | Look 
F          1           1          15          15          28          15 
          2          23          15           0           1  Del Snarf Undo | Look 
Wiki /mnt/wiki' >/tmp/gridacme

window -m -r 0 0 1350 750 $srio -i /tmp/gridrio