main 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/rc
  2. . defs
  3. while()
  4. {
  5. div=--------------------------------------
  6. echo
  7. echo $div
  8. echo
  9. echo -n 'Preparing menu...'
  10. # must be topologically sorted (by prereq)
  11. tasks=(\
  12. configfs\
  13. partdisk prepdisk\
  14. fmtfossil\
  15. mountfs\
  16. configdist\
  17. confignet\
  18. mountdist\
  19. fmtventi\
  20. download\
  21. copydist\
  22. bootsetup finish stop\
  23. stopether stopppp\
  24. )
  25. # startether startppp stopether stopppp download\
  26. # these don't show up in the menu but still matter
  27. pseudotasks=(configip havefiles etherup etherdown pppup pppdown)
  28. for(i in $tasks $pseudotasks)
  29. $i=notdone
  30. coherence
  31. for(i in $tasks $pseudotasks)
  32. if(~ $#$i 0)
  33. $i=notdone
  34. #
  35. # we believe the environment about what is done
  36. # only if we've confirmed it. since the tasks list is sorted so that
  37. # prereqs of xxx come before xxx, it's okay to assume xxx
  38. # is done until proven otherwise -- either a prereq or checkdone
  39. # will say so.
  40. #
  41. done=()
  42. ready=()
  43. rm /env/done
  44. rm /env/ready
  45. for(i in $tasks) {
  46. $i=done
  47. for(j in `{prereq $i})
  48. if(! ~ $$j done)
  49. $i=notdone
  50. if(~ $$i done) {
  51. export $i
  52. $i checkdone
  53. $i=`{grep '^'$i^'=' /tmp/vars | sed -n '$p' | sed 's/.*=//'}
  54. }
  55. if(~ $$i notdone ready) {
  56. okay=yes
  57. for(j in `{prereq $i})
  58. if(! ~ $$j done)
  59. okay=no
  60. switch($okay){
  61. case yes
  62. $i=ready
  63. export $i
  64. $i checkready
  65. $i=`{grep '^'$i^'=' /tmp/vars | sed -n '$p' | sed 's/.*=//'}
  66. case no
  67. $i=notdone
  68. }
  69. }
  70. if(~ $$i done ready)
  71. $$i=($$$i $i) # rc can be just as complicated as perl!
  72. }
  73. export $tasks $pseudotasks done ready
  74. coherence
  75. echo
  76. if(! ~ $#done 0) {
  77. echo 'The following tasks are done: '
  78. for(i in $done)
  79. desc $i
  80. echo
  81. }
  82. echo 'The following unfinished tasks are ready to be done:'
  83. for(i in $ready)
  84. desc $i
  85. echo
  86. if(~ $#ready 0) {
  87. echo hey you finished everything! not supposed to happen.
  88. sleep 100
  89. exit
  90. }
  91. prompt -d $ready(1) -w '' 'Task to do' $done $ready
  92. echo
  93. echo $div
  94. $rd go
  95. $rd=done # if it's not, the check will figure that out
  96. export $rd
  97. }