C 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/rc
  2. # C system - connect to system's console
  3. rfork en
  4. oflag=()
  5. opt=-r
  6. while(~ $1 -*)
  7. switch($1){
  8. case -r
  9. shift
  10. opt=''
  11. case -O -o
  12. oflag=-O
  13. shift
  14. case *
  15. opt=-r
  16. shift
  17. }
  18. switch($1){
  19. case ella
  20. exec C office0
  21. exit
  22. case erika
  23. exec C office1
  24. exit
  25. case *
  26. # look for server in /lib/ndb
  27. server=`{ndb/query sys $1 console}
  28. switch($server){
  29. case ''
  30. echo C: unknown console server for $1
  31. exit 1
  32. }
  33. }
  34. # can't cpu to old servers any more
  35. switch($server){
  36. case dinar bones
  37. ssh $server C $1
  38. exit 0
  39. }
  40. if(! test -e /mnt/consoles/$1){
  41. switch($sysname){
  42. case $server
  43. mount /srv/consoles /mnt/consoles
  44. case *
  45. import $oflag $server /mnt/consoles
  46. }
  47. }
  48. if(! test -e /mnt/consoles/$1 && test -e /srv/consoles)
  49. mount /srv/consoles /mnt/consoles
  50. if(! test -e /mnt/consoles/$1){
  51. echo console not found
  52. exit 'console not found'
  53. }
  54. if (test -w /dev/label) {
  55. olab=`{cat /dev/label}
  56. label $1
  57. }
  58. con -l $opt /mnt/consoles/$1
  59. if (test -w /dev/label)
  60. label $olab