Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.39 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          halt
  4. # Required-Start:
  5. # Required-Stop:
  6. # Default-Start:
  7. # Default-Stop:      0
  8. # Short-Description: Execute the halt command.
  9. # Description:
  10. ### END INIT INFO
  11.  
  12. NETDOWN=yes
  13.  
  14. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  15. [ -f /etc/default/halt ] && . /etc/default/halt
  16.  
  17. . /lib/lsb/init-functions
  18.  
  19. do_stop () {
  20.     if [ "$INIT_HALT" = "" ]
  21.     then
  22.         case "$HALT" in
  23.           [Pp]*)
  24.             INIT_HALT=POWEROFF
  25.             ;;
  26.           [Hh]*)
  27.             INIT_HALT=HALT
  28.             ;;
  29.           *)
  30.             INIT_HALT=POWEROFF
  31.             ;;
  32.         esac
  33.     fi
  34.  
  35.     # See if we need to cut the power.
  36.     if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ]
  37.     then
  38.         /etc/init.d/ups-monitor poweroff
  39.     fi
  40.  
  41.     # Don't shut down drives if we're using RAID.
  42.     hddown="-h"
  43.     if grep -qs '^md.*active' /proc/mdstat
  44.     then
  45.         hddown=""
  46.     fi
  47.  
  48.     # If INIT_HALT=HALT don't poweroff.
  49.     poweroff="-p"
  50.     if [ "$INIT_HALT" = "HALT" ]
  51.     then
  52.         poweroff=""
  53.     fi
  54.  
  55.     # Make it possible to not shut down network interfaces,
  56.     # needed to use wake-on-lan
  57.     netdown="-i"
  58.     if [ "$NETDOWN" = "no" ]; then
  59.         netdown=""
  60.     fi
  61.  
  62.     log_action_msg "Will now halt"
  63.     halt -d -f $netdown $poweroff $hddown
  64. }
  65.  
  66. case "$1" in
  67.   start|status)
  68.     # No-op
  69.     ;;
  70.   restart|reload|force-reload)
  71.     echo "Error: argument '$1' not supported" >&2
  72.     exit 3
  73.     ;;
  74.   stop)
  75.     do_stop
  76.     ;;
  77.   *)
  78.     echo "Usage: $0 start|stop" >&2
  79.     exit 3
  80.     ;;
  81. esac
  82.  
  83. :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement