home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20120521.etc.tar.gz / bradford.20120521.etc.tar / etc / init.d / rc < prev    next >
Text File  |  2006-03-16  |  10KB  |  399 lines

  1. #! /bin/bash
  2. #
  3. # Copyright (c) 1996-2004 SuSE Linux AG, Nuernberg, Germany.
  4. # All rights reserved.
  5. #
  6. # Author: Florian La Roche, 1996
  7. #      Werner Fink <werner@suse.de> 1994-99,2000-2004
  8. #
  9. # Please send feedback to http://www.suse.de/feedback
  10. #
  11. # /etc/init.d/rc   --    The Master Resource Control Script
  12. #
  13. # This file is responsible  for  starting/stopping  services
  14. # when the runlevel changes.  If the action for a particular
  15. # feature in the new run-level is the same as  the action in
  16. # the previous run-level, this script will neither start nor
  17. # stop that feature.
  18. #
  19.  
  20. #
  21. # Avoid be interrupted by child or keyboard
  22. #
  23. trap "echo" SIGINT SIGSEGV SIGQUIT
  24. trap 'test "$RUNLEVEL" = "1" && exit 0' SIGTERM
  25. set +e
  26.  
  27. #
  28. # On previous runlevel identical with current runlevel do not
  29. # re-examine current runlevel.
  30. #
  31. test "$PREVLEVEL" = "$RUNLEVEL" && exit 0
  32.  
  33. #
  34. # Coming from runlevel 1 we do not need to enter S
  35. #
  36. test "$PREVLEVEL" = "1" -a "$RUNLEVEL" = "S" && exit 0
  37.  
  38. #
  39. # Up from runlevel N we may want to run in confirm mode
  40. #
  41. if test "$PREVLEVEL" = "N" ; then
  42.     test -e /proc/cmdline || mount -n -t proc proc /proc
  43.     read -t 2 check < /proc/cmdline 2> /dev/null
  44.     case "$check" in
  45.     *confirm*) DO_CONFIRM=yes ;;
  46.     esac
  47.     test -e /var/run/do_confirm && DO_CONFIRM=yes
  48.     rm -f   /var/run/do_confirm
  49.     export DO_CONFIRM
  50. fi
  51.  
  52. runrc=/etc/init.d/rc${RUNLEVEL}.d
  53. prerc=/etc/init.d/rc${PREVLEVEL}.d
  54.  
  55. #
  56. # Initialize boosplash progressbar variables
  57. #
  58. . /etc/rc.splash $RUNLEVEL
  59.  
  60. #
  61. # Up from runlevel S we have to check if the system was
  62. # cold booted into single user mode and call /etc/init.d/boot.
  63. #
  64. if test "$PREVLEVEL" = "S" ; then
  65.     # Double check
  66.     single="no"
  67.     hvname="yes"
  68.     #
  69.     check=""
  70.     test -e /proc/cmdline || mount -n -t proc proc /proc
  71.     read -t 2 check < /proc/cmdline 2> /dev/null
  72.     case " ${check} " in
  73.     *\ single\ *|*\ s\ *)
  74.         single="yes"
  75.     esac
  76.     read -t 2 check < /proc/sys/kernel/hostname 2> /dev/null
  77.     case "${check}" in
  78.     "(none)"|unknown|"")
  79.         hvname="no"
  80.     esac
  81.     unset check
  82.  
  83.     if test "$single" = "yes" -a "$hvname" = "no" ; then
  84.     # This is the case if we're up from cold boot
  85.     echo "Sending all processes the TERM signal..."
  86.     killall5 -15
  87.     sleep 3
  88.     echo "Sending all processes the KILL signal..."
  89.     killall5 -9
  90.     cat /proc/mounts | while read des fs type rest; do
  91.         case "$type" in
  92.         swap)    continue ;;
  93.         proc)    continue ;;
  94.         nfs|nfs4)    continue ;;
  95.         smbfs|cifs)    continue ;;
  96.         esac
  97.         umount -n -r $fs
  98.     done
  99.     cat /proc/swaps | while read des rest ; do
  100.         test "$des" = "Filename" && continue
  101.         swapoff $des &> /dev/null
  102.     done
  103.     umount -n -t proc /proc
  104.     /etc/init.d/boot
  105.     else
  106.     for b in /etc/init.d/boot.d/S*boot.udev
  107.     do
  108.         test -x $b || continue
  109.         $b start
  110.     done
  111.     fi
  112. fi
  113.  
  114. #
  115. # Get terminal size of standard input of the system console
  116. #
  117. test -z "$CONSOLE" && CONSOLE=/dev/console
  118. set -- $(stty size < $CONSOLE)
  119.   LINES=$1
  120. COLUMNS=$2
  121. export LINES COLUMNS CONSOLE
  122.  
  123. #
  124. # Set I/O of this script and its childs to console
  125. #
  126. exec 0<> $CONSOLE 1>&0 2>&0
  127.  
  128. #
  129. # Dummy shell function
  130. #
  131. chvt () { true; }
  132.  
  133. #
  134. # This redirects all rc messages during reboot and halt
  135. # to tty1 if the system console is bound on VGA (tty0).
  136. #
  137. REDIRECT="`showconsole 2>/dev/null`"
  138. export REDIRECT
  139. if test -x /sbin/isserial && /sbin/isserial ; then
  140.     # Serial: columns and lines are not defined
  141.     : ${LINES:=24}
  142.     : ${COLUMNS:=80}
  143.     test "$TERM" = "linux" -o -z "$TERM" && TERM=vt102
  144. else
  145.     # VGA
  146.     if test "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "6" ; then
  147.     case "$REDIRECT" in /dev/tty[1-9]*)
  148.         REDIRECT=/dev/tty1
  149.         setconsole $REDIRECT < $CONSOLE
  150.         # Overwrite chvt shell function
  151.         chvt () { test -x /usr/bin/chvt && /usr/bin/chvt 1 ; }
  152.         set -- $(stty size < $REDIRECT)
  153.         LINES=$1
  154.         COLUMNS=$2
  155.         export LINES COLUMNS
  156.     esac
  157.     fi
  158. fi
  159.  
  160. #
  161. # May change to first terminal, but first we kill all vlock sessions
  162. #
  163. killall -q /usr/bin/vlock &> /dev/null || true
  164. chvt
  165.  
  166. #
  167. # Configuration and coloring of the boot messages
  168. #
  169.  
  170. . /etc/rc.status
  171. . /etc/sysconfig/boot
  172.  
  173. #
  174. # Save old terminal settings and set -nl to avoid staircase
  175. # effect, do not lock scrolling, and avoid break characters.
  176. #
  177. otty=$(stty -g)
  178. if test "$FLOW_CONTROL" = "yes" ; then
  179.     stty -nl  ixon ignbrk -brkint
  180. else
  181.     stty -nl -ixon ignbrk -brkint
  182. fi
  183.  
  184. #
  185. # Start blogd if not in single user mode
  186. #
  187. if test "$RUNLEVEL" != "S" -a -x /sbin/blogd -a -n "$REDIRECT" ; then
  188.     /sbin/blogd $REDIRECT
  189. fi
  190. if test -z "$REDIRECT" ; then
  191.     if (echo -n > /dev/tty) 2>/dev/null ; then
  192.     REDIRECT=/dev/tty
  193.     else
  194.     REDIRECT=/dev/console
  195.     fi
  196. fi
  197.  
  198. if test "$DO_CONFIRM" = "yes" ; then
  199.     echo -n "Master Resource Control: "
  200.     echo -e "${stat}${extd}Interactive startup${norm}"
  201. fi
  202. echo -n "Master Resource Control: "
  203. echo -n "previous runlevel: $PREVLEVEL, "
  204. echo -e "switching to runlevel: ${stat}${extd}${RUNLEVEL}${norm}"
  205.  
  206. splashtrigger "rlchange $RUNLEVEL"
  207.  
  208. #
  209. # Start the user defined resource control script which
  210. # should be executed _before_ runlevel is entered.
  211. #
  212. if test -f /etc/init.d/before.local ; then
  213.     echo -n "Master Resource Control: "
  214.     echo "Running /etc/init.d/before.local"
  215.     /bin/sh /etc/init.d/before.local
  216.     rc_status -v1 -r
  217.     splashtrigger "before.local"
  218. fi
  219.  
  220. rex="[0-9][0-9]"
  221. failed=""
  222. skipped=""
  223. callord=""
  224.  
  225. #
  226. # Check if we are able to use make like booting
  227. #
  228. test -s /etc/init.d/.depend.start || RUN_PARALLEL="no"
  229. test -s /etc/init.d/.depend.stop  || RUN_PARALLEL="no"
  230. test "$DO_CONFIRM"   = "yes"      && RUN_PARALLEL="no"
  231. type -p startpar &> /dev/null     || RUN_PARALLEL="no"
  232. startpar -v      &> /dev/null      || RUN_PARALLEL="no"
  233.  
  234. #
  235. # Stop/Start services to enter new runlevel
  236. #
  237. if test "$RUN_PARALLEL" = "yes" ; then
  238.  
  239.     #
  240.     # Stop/Start services in parallel with make behaviour of startpar
  241.     #
  242.  
  243.     startopt="-p4 -t 30 -T 3 $(splashmake)"
  244.     eval $(startpar $startopt -M stop  -P $PREVLEVEL -R $RUNLEVEL)
  245.     failed="${failed:+$failed }$failed_service"
  246.     skipped="${skipped:+$skipped }$skipped_service"
  247.  
  248.     eval $(startpar $startopt -M start -P $PREVLEVEL -R $RUNLEVEL)
  249.     failed="${failed:+$failed }$failed_service"
  250.     skipped="${skipped:+$skipped }$skipped_service"
  251.  
  252.     unset failed_service skipped_service startopt 
  253.  
  254. else
  255.  
  256.     #
  257.     # First check and test services of previous and current (new) runlevel.
  258.     #
  259.     for i in $prerc/K${rex}*; do
  260.  
  261.     test -x "$i" || continue
  262.  
  263.     #
  264.     # Don't stop service if the new runlevel requires the service.
  265.     #
  266.     K=${i##*/}
  267.     service=${K#*K$rex}
  268.     K=${K%$service}
  269.     set -- $runrc/S$rex$service
  270.     test $# -gt 1 && echo -e "$attn$runrc/: more than one link for service $service$norm"
  271.     test -x "$1"  && continue
  272.  
  273.     blogger "$service stop"
  274.     $i stop; status=$?
  275.     echo -en "$rc_reset"
  276.     splashprogress "$service stop"
  277.  
  278.     case $status in
  279.     [1-4])     failed="${failed:+$failed }$service"    ;;
  280.     [56])    skipped="${skipped:+$skipped }$service" ;;
  281.     [07]|*)    ;;
  282.     esac
  283.  
  284.     blogger "'$service stop' exits with status $status"
  285.  
  286.     done
  287.  
  288.     for i in $runrc/S${rex}*; do
  289.  
  290.     test -x "$i" || continue
  291.  
  292.     #
  293.     # Don't start service if previous runlevel includes the service.
  294.     #
  295.     S=${i##*/}
  296.     service=${S#*S$rex}
  297.     S=${S%$service}
  298.     set -- $prerc/K$rex$service
  299.     test $# -gt 1 && echo -e "$attn$prerc/: more than one link for service $service$norm"
  300.     test -x "$1"  && continue
  301.  
  302.     #
  303.     # Ask the user if wanted
  304.     #
  305.     if test "$DO_CONFIRM" = "yes" ; then
  306.         rc_confirm -t 5 "Start service $service"
  307.         case "$?" in
  308.         0) true    ;;
  309.         1) continue    ;;
  310.         2) DO_CONFIRM=""
  311.         esac
  312.     fi
  313.  
  314.     blogger "$service start"
  315.     $i start; status=$?
  316.         echo -en "$rc_reset"
  317.     splashprogress "$service start"
  318.  
  319.     case "$status" in
  320.     [1-47])     failed="${failed:+$failed }$service"    ;;
  321.     [56])    skipped="${skipped:+$skipped }$service" ;;
  322.     0|*)    ;;
  323.     esac
  324.  
  325.     blogger "'$service start' exits with status $status"
  326.     done
  327. fi
  328.  
  329. #
  330. # Inform the users
  331. #   Reaction on LSB return values:
  332. #    OK   : 0 - success
  333. #    FAIL : 1 - generic or unspecified error
  334. #    FAIL : 2 - invalid or excess argument(s)
  335. #    FAIL : 3 - unimplemented feature (e.g. "reload")
  336. #    FAIL : 4 - insufficient privilege
  337. #    SKIP : 5 - program is not installed
  338. #    SKIP : 6 - program is not configured
  339. #    FAIL : 7 - program is not running (doing "start")
  340. #    OK   : 7 - program is not running (doing "stop")
  341. #
  342.  
  343. #
  344. # Start the user defined resource control script which
  345. # should be executed _after_ runlevel is reached.
  346. #
  347. if test -f /etc/init.d/after.local ; then
  348.     echo -n "Master Resource Control: "
  349.     echo "Running /etc/init.d/after.local"
  350.     /bin/sh /etc/init.d/after.local
  351.     rc_status -v1 -r
  352.     splashtrigger "after.local"
  353. fi
  354.  
  355. splashtrigger "rlreached $RUNLEVEL"
  356.  
  357. #
  358. # Be verbose and print stats
  359. #
  360. echo -n "Master Resource Control: "
  361. echo -e "runlevel ${RUNLEVEL} has been ${stat}${extd}reached${norm}"
  362. if test -n "$failed" ; then
  363.     n=$((${#failed} + 7))
  364.     echo -n  "Failed services in runlevel ${RUNLEVEL}: "
  365.     test $n -lt 47 && echo -en "\033[${COLUMNS}C\033[${n}D"
  366.     echo -e  "${warn}${failed}${norm}"
  367. fi
  368. if test -n "$skipped" ; then
  369.     n=$((${#skipped} + 7))
  370.     echo -n  "Skipped services in runlevel ${RUNLEVEL}: "
  371.     test $n -lt 47 && echo -en "\033[${COLUMNS}C\033[${n}D"
  372.     echo -e  "${attn}${skipped}${norm}"
  373. fi
  374.  
  375. #
  376. # Check for boot cycle detection
  377. #
  378. test -s /lib/bootcycle/stats && . /lib/bootcycle/stats
  379.  
  380. #
  381. # Stop blogd if running
  382. #
  383. test -x /sbin/blogd && killproc -QUIT /sbin/blogd
  384.  
  385. #
  386. # Restore old terminal settings
  387. #
  388. stty $otty
  389.  
  390. #
  391. # For the first logon on a virtual console.
  392. #
  393. test -e /etc/issue-SuSE-first-run && {
  394.     cat /etc/issue-SuSE-first-run > $REDIRECT
  395.     rm -f /etc/issue-SuSE-first-run 2>/dev/null
  396. }
  397.  
  398. exit 0
  399.