1#!/boot/rc -m /boot/rcmain 2flag x + 3 4cputype=amd64 5objtype=$cputype 6service=cpu 7authid=bootes 8rootdir=/root 9rootspec='' 10rootsrv=boot 11 12beetroot=k10root.rr 13authentication='nvram=/boot/adm/nvram auth/factotum -sfactotum -S' # -a ... 14# test xyzip=(0 0 0 104.9.33) 15# test fsaddr='tcp!135.$xyzip(4)^!564' 16ip=(135.104.9.32 255.255.255.0 135.104.9.0 135.104.9.1) 17 18# 19# Post the read-only filesystem in #s/$beetroot 20# and mount it on /boot so the commands in /boot/$cputype/bin 21# are available to create the namespace (namespaces like to 22# mount #s/boot on / and that should not be the read-only 23# filesystem). 24# Must set hostowner to be that of the owner of the nvram file 25# before paqfs starts otherwise factotum will not be able to 26# open it. 27# 28/boot/echo -n sys > '#c/hostowner' 29/boot/paqfs -p -S $beetroot -m /boot -q /boot/$beetroot 30cd /boot/$cputype/bin 31bind '#c' /dev 32bind '#d' /fd 33bind -c '#e' /env 34bind '#p' /proc 35bind -c '#s' /srv 36 37# 38# Configure the networks. 39# 40bind -a '#I' /net 41bind -a '#l0' /net 42 43if(~ $#ip 4 && ! ~ $ip(1) '10.-1.-1.-1'){ 44 i=`{sed '' /net/ipifc/clone} 45 echo bind ether /net/ether0 > /net/ipifc/$i/ctl 46 echo add $ip(1) $ip(2) $ip(3) > /net/ipifc/$i/ctl 47 echo add 0 0 $ip(4) >>/net/iproute 48 echo I am $ip(1)^, default route $ip(4) 49} 50i=`{sed '' /net/ipifc/clone} 51echo bind loopback /dev/null > /net/ipifc/$i/ctl 52echo add 127.0.0.1 255.0.0.0 127.0.0.0 > /net/ipifc/$i/ctl 53 54# 55# Set up authentication if necessary. 56# Factotum has to be allowed to mount on /mnt here because 57# auth_proxy (called by mount) will look for it there. 58# Normally, factotum will set '#c/hostowner'; if not, do it 59# by hand. 60# 61if(! ~ $authentication '') 62 eval `{echo $authentication} 63if(~ `{sed '' '#c/hostowner'} sys) 64 echo -n $authid > '#c/hostowner' 65 66# 67# Attach to the remote filesystem and mount it. 68# If this fails, set $root(dir|srv) and continue, 69# there's enough in the read-only filesystem to run 70# listen and telnet; at least cat /dev/kmesg might 71# then give a clue as to the problem. 72# Must check for the presence of expected files after 73# the mount because srv/mount do not always return 74# proper status. 75# $rootsrv is used in /lib/namespace because the 76# root might not be served from the usual #s/boot. 77# 78if(! ~ $fsaddr '' && ! eval srv -c -m $fsaddr $rootsrv $rootdir) 79 echo srv -c -m $fsaddr $rootsrv $rootdir fails: $status 80if(! test -d $rootdir/$cputype){ 81 rootdir=/boot 82 rootspec='' 83 rootsrv=$beetroot 84} 85rootsrv='#s/'$rootsrv 86echo root is on $rootdir, root is served from $rootsrv 87 88# 89# Finish the namespace setup. 90# 91bind -a $rootdir / 92bind -c -b $rootdir/mnt /mnt 93bind $rootdir/$cputype/bin /bin 94bind -a $rootdir/rc/bin /bin 95cd / 96 97# 98# Finish environment setup and start services. 99# Listen is run trusted if there is no factotum running, 100# as 'cpu -R' with no authentication needs to be able to 101# open '#¤/caphash' in order to change the owner and 102# that can only be done if running as '#c/hostowner'. 103# 104sysname=cpu-$ip(1) 105prompt=($sysname'# ' ' ') 106bind /boot/rc/bin/service /bin/service 107if(test -d /mnt/factotum) 108 aux/listen -q tcp 109if not 110 aux/listen -t /bin/service tcp 111 112flag x - 113while(echo Hello Squidboy) 114 . -i '#d/0' 115