home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / base / root.15 / usr / lib / drf / S01drf_nws / S01drf_nws~
Text File  |  1998-08-19  |  4KB  |  194 lines

  1. #! /usr/bin/winxksh
  2. #ident    "@(#)drf:cmd/S01drf_nws    1.1.1.4"
  3.  
  4. eval `defadm coterm TERM`
  5. export TERM
  6. if [ -z "$LANG" ]
  7. then
  8.     LNG=`defadm locale LANG 2>/dev/null`
  9.     if [ "$?" != 0 ]
  10.     then LANG=C
  11.     else eval $LNG
  12.     fi
  13. fi
  14. if [ -z "$LC_ALL" ] 
  15. then
  16.     LC_ALL=$LANG
  17. fi
  18. export LANG LC_ALL
  19.  
  20. [ "$RANDOM" = "$RANDOM" ] && exec /usr/bin/xksh /etc/rc3.d/S01drf_nws
  21.  
  22. function get_sec_medium
  23. {
  24.     msg
  25.     footer 2> /dev/null #clear the footer
  26.     FOUND=false
  27.     display "$TAPE_PROMPT"
  28.     call getkey
  29.     wclose
  30.     for i in /dev/rmt/ntape?
  31.     do
  32.         check_devs -g ${i} && {
  33.             SEC_MEDIUM=$i
  34.             FOUND=true
  35.             break
  36.         }
  37.     done
  38.     $FOUND || {
  39.         display "$TAPE_OPEN_ERROR" -bg $RED -fg $WHITE
  40.         call getkey
  41.         wclose
  42.         return 1
  43.     }
  44.     footer "$GENERIC_WAIT_FOOTER"
  45.     tapecntl -w ${SEC_MEDIUM} # Rewind the tape
  46.     tapecntl -f 512 ${SEC_MEDIUM} # set the fixed block length
  47.     return 0
  48. }
  49.  
  50. function next_tape_prompt
  51. {
  52.     wclose
  53.     footer 2> /dev/null #clear the footer
  54.     display "$NEXT_TAPE_PROMPT"
  55.     call getkey
  56.     wclose
  57.     display "$DSK_RST_MSG"
  58.     footer "$GENERIC_WAIT_FOOTER"
  59.     tapecntl -w ${SEC_MEDIUM} # Rewind the tape
  60.     tapecntl -f 512 ${SEC_MEDIUM} 
  61. }
  62.  
  63. function SYS_restore
  64. {
  65.     tapecntl -p1 ${SEC_MEDIUM} #Skip first cpio archive
  66.     sleep 20    #give the tape time to move, st01 weirdness...
  67.     [ -f /usr/lib/drf/dd_flag ] && tapecntl -p1 ${SEC_MEDIUM}
  68.     sleep 20    #give the tape time to move, st01 weirdness...
  69. #archive of SYS volume on tape has pathname relative to "/"
  70.     cd /
  71.      ( cpio -icmdu -M "" -G STDIO -I ${SEC_MEDIUM}  2>/dev/null 
  72.          err=$?
  73.          echo one one one
  74.          echo Done Done Done
  75.          echo $err) |&
  76.        
  77.     while :
  78.     do
  79.           read -p one two three
  80.           [ "$one" = "Done" ] && {
  81.            read -p err
  82.            break
  83.           }
  84.           if [ "$two" = "of" ]
  85.           then
  86.            next_tape_prompt
  87.            print -p
  88.           fi
  89.     done
  90.     
  91.     if [ $err -ne 0 -a $err -ne 2 ] 
  92.     then
  93.            cd /
  94.            disp_disk_rst_err
  95.            return 1
  96.     fi
  97.     cd /
  98.     # call unlink /usr/sbin/disksetup
  99. }
  100.  
  101. function NWS_start
  102. {
  103.     eval `LC_MESSAGES="$LANG" /usr/sbin/nwcm -v ipx_start_at_boot -v nws_start_at_boot`
  104.     NWSBOOT=$nws_start_at_boot
  105.     nwcm -q -s nws_start_at_boot=on #In case they had turned it off
  106.  
  107.     sh /etc/init.d/nw start    #start NPSD daemon
  108.     nwcm -q -s login=on    #needed to get the server up (?)
  109.     sh /etc/init.d/nws start    #start NetWare Server
  110.  
  111.     until nwserverstatus >/dev/null 2>&1    #nwserverstatus returns 0 (true)
  112.     do                    #when server is fully up
  113.         echo "return code was $?" >>/tmp/err
  114.         sleep 10
  115.     done
  116.  
  117.     nwcm -q -s login=off    #set NetWare server for limited access mode
  118. }
  119. function NWS_stop
  120. {
  121.     sh /etc/init.d/nws stop
  122.     sleep 15
  123.     sh /etc/init.d/nw stop
  124.     nwcm -q -s login=on    #reset NetWare server for full access mode
  125.     nwcm -q -s nws_start_at_boot=$NWSBOOT #set it back the way it was
  126. }
  127.  
  128.  
  129. function ask_server_exit
  130. {
  131.  
  132. #The first choice was 'continue', so do nothing unless they chose 'cancel'
  133.  
  134.     case $CHOICE in
  135.  
  136.         ${ASKSERVER_OPT[1]})
  137.         NWS_SYS_PATH=$(</usr/lib/drf/nws_sys_path)
  138.         rm $NWS_SYS_PATH/_netware/*
  139.         call endwin
  140.         rm /etc/rc3.d/S01drf_nws
  141.         exit
  142.         ;;
  143.     esac
  144.  
  145.     return
  146. }
  147.  
  148. function ask_server
  149. {
  150.     if [ -z "${ASKSERVER_OPT}" ]
  151.     then
  152.         typeset OIFS="$IFS"
  153.         IFS="$nl"
  154.         set -A ASKSERVER_OPT ${ASKSERVER_CHOOSE}
  155.         IFS="$OIFS"
  156.     fi
  157.     ASKSERVER=$ASKSERVER_OPT
  158.  
  159.     CHOOSE_FOOTER="$GENERIC_CHOOSE_FOOTER"
  160.     CHOOSE_TITLE="$NWS_CHOOSE"
  161.     choose -f -e -winparms "-below 0 -fg $COMBO2_FG -bg $COMBO2_BG" -help "helpwin user_limit" -exit 'ask_server_exit' "$ASKSERVER" "${ASKSERVER_OPT[@]}"
  162.     return
  163. }
  164. function NWS_server_check
  165. {
  166.     display   "$NWS_SERVER_INFO" -above 1 -below 2
  167.     _t=$CURWIN
  168.  
  169. # get user's choice ('single-server' or 'multi-server')
  170.     ask_server
  171.     input_handler
  172.     wclose $_t
  173. }
  174. #MAIN
  175. {
  176. FPATH=/etc/dcu.d/menus
  177. SCRIPTS=/etc/dcu.d/scripts
  178. . $SCRIPTS/funcrc
  179. . /usr/lib/drf/locale/$LANG/txtstr
  180. . $SCRIPTS/winrc
  181. . $SCRIPTS/scr_init
  182. NWS_server_check
  183. display -w "$NWS_INFO"
  184. input_handler
  185. wclose
  186. get_sec_medium
  187. display "$DSK_RST_MSG"
  188. NWS_start
  189. SYS_restore
  190. NWS_stop
  191. call endwin
  192. } </dev/vt02 >/dev/vt02
  193. rm /etc/rc3.d/S01drf_nws
  194.