~fultonbrowne/rc-scripts

ref: 1548cc3d3364e742e401026593c24123c7b17457 rc-scripts/grid/gridstart -rwxr-xr-x 2.5 KiB
1548cc3d — glenda added yet another handy script 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/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