Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

/etc/init.d/halt
Thursday, November 1st, 2007 at 9:23:46am UTC 

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          halt
  4. # Required-Start:    umountroot
  5. # Required-Stop:
  6. # Should-Start:      lvm raid2
  7. # Should-Stop:
  8. # Default-Start:     0
  9. # Default-Stop:
  10. # Short-Description: Execute the halt command.
  11. # Description:
  12. ### END INIT INFO
  13.  
  14. PATH=/usr/sbin:/usr/bin:/sbin:/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.         log_action_msg "Will now halt"
  56.         sleep 1
  57.         halt -d -f -i $poweroff $hddown
  58. }
  59.  
  60. case "$1" in
  61.   start)
  62.         # No-op
  63.         ;;
  64.   restart|reload|force-reload)
  65.         echo "Error: argument '$1' not supported" >&2
  66.         exit 3
  67.         ;;
  68.   stop)
  69.         do_stop
  70.         ;;
  71.   *)
  72.         echo "Usage: $0 start|stop" >&2
  73.         exit 3
  74.         ;;
  75. esac
  76.  
  77. :

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus