1 #!/boot/rc -m /boot/rcmain
2 # boot script for file servers, including standalone ones
3 path=(/boot /$cputype/bin /rc/bin .)
5 # set up any /dev/sd partitions
6 for(disk in /dev/sd*) {
7 if(test -f $disk/data && test -f $disk/ctl)
8 fdisk -p $disk/data >$disk/ctl >[2]/dev/null
9 if(test -f $disk/plan9)
15 prep -p $part >$disk/ctl >[2]/dev/null
21 if (! test -e /env/vmpc)
22 vmpc=23 # % of free memory for venti
36 # start usb for keyboard, disks, etc.
37 if (test -e /dev/usb/ctl) {
41 if not if (test -e /dev/usb0) {
44 if (test -e '#m/mouse')
48 disk -l -s usbdisk -m /mnt # mounts on /mnt/<lun>
53 for (ctl in /dev/sd[C-H]?/ctl)
59 # set up any fs(3) partitions (HACK)
60 # don't match AoE disks, as those may be shared.
61 if (test ! -e /env/fscfg)
62 fscfg=`{ls -d /dev/sd[~e-h]?/fscfg >[2]/dev/null | sed 1q}
63 if (~ $#fscfg 1 && test -r $fscfg)
64 zerotrunc <$fscfg | read -m >/dev/fs/ctl
66 # figure out which arenas and fossil partitions to use.
67 # don't match AoE disks, as those may be shared.
68 if(! test -e /env/arena0){
69 if (test -e /dev/fs/arena0)
70 arena0= /dev/fs/arena0
71 if not if (test -e /dev/sd[~e-h]?/arena0)
72 arena0= /dev/sd[~e-h]?/arena0
76 if (test -e /dev/fs/fossil)
77 fossil= /dev/fs/fossil
78 if not if (test -e /dev/sd[~e-h]?/fossil)
79 fossil= /dev/sd[~e-h]?/fossil
84 # the local disks are now sorted out.
85 # set up the network, auth, venti and fossil.
89 if (~ $#ip 1 && ! ~ $ip '') {
90 # need to supply ip, ipmask and ipgw in plan9.ini to use this
91 ipconfig -g $ipgw ether /net/ether0 $ip $ipmask
92 echo 'add 0 0 '^$ipgw >>/net/iproute
96 switch (`{sed '/\.(0|255)[ ]/d' /net/ipselftab}) {
98 echo 'add 135.104.9.0 255.255.255.0 204.178.31.10' >>/net/iproute
100 ipconfig loopback /dev/null 127.1
102 # local hackery: add extra sr luns
103 if (test -e /dev/aoe/1.1 && ! test -e /dev/sdf0)
104 echo config switch on spec f type aoe//dev/aoe/1.1 >/dev/sdctl
105 if (test -e /dev/aoe/1.2 && ! test -e /dev/sdg0)
106 echo config switch on spec g type aoe//dev/aoe/1.2 >/dev/sdctl
109 # so far we're using the default key from $nvram, usually
110 # for insideout.plan9.bell-labs.com on outside machines,
111 # and have mounted our root over the net, if running diskless.
112 # factotum always mounts itself (on /mnt by default).
116 echo start factotum on $auth
117 factotum -sfactotum -S -a $auth
120 factotum -sfactotum -S
121 mount -b /srv/factotum /mnt
123 # if a keys partition exists, add its contents to factotum's
124 keys=`{ls -d /dev/sd*/keys >[2]/dev/null | sed 1q}
125 if (~ $#keys 1 && test -r $keys) {
127 zerotrunc <$keys | aescbc -n -d | read -m >/mnt/factotum/ctl
130 # get root from network if fsaddr set in plan9.ini, and bail out here
131 if (test -e /env/fs) {
133 if(! srv tcp!$fs!564 boot)
134 exec ./rc -m/boot/rcmain -i
135 if(! mount -c /srv/boot /root)
136 exec ./rc -m/boot/rcmain -i
140 if (! ~ $arena0 /dev/null && test -r $arena0) {
141 echo -n start venti on $arena0...
142 venti=tcp!127.0.0.1!17034
143 vcfg=`{ls -d /dev/sd*/venticfg >[2]/dev/null | sed 1q}
144 if (~ $#vcfg 1 && test -r $vcfg)
145 venti -m $vmpc -c $vcfg
147 venti -m $vmpc -c $arena0
150 if not if (! test -e /env/venti)
151 venti=tcp!135.104.9.33!17034 # local default
153 # start root fossil, may serve /srv/boot
154 if (! ~ $fossil /dev/null && test -r $fossil) {
155 echo -n root fossil on $fossil...
156 fossil -m 2 -f $fossil
161 # normal start up on local fossil root
167 # factotum is now mounted in /mnt; keep it visible.
168 # newns() needs it, among others.
171 if (test -e /srv/boot)
173 if not if (test -e /srv/fossil)
175 if not if (test -e /srv/fsmain)
178 echo cannot find a root in /srv:
181 echo -n mount -cC /srv/$srv $rootdir...
182 mount -cC /srv/$srv $rootdir
185 if (test -d $rootdir/mnt)
186 bind -ac $rootdir/mnt /mnt
187 mount -b /srv/factotum /mnt
190 if (! test -d /$cputype) {
191 echo /$cputype missing!
192 exec ./rc -m/boot/rcmain -i
194 bind /$cputype/bin /bin
202 exec ./rc -m/boot/rcmain -i