k8root.rc 3.1 KB

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