/rc4.d/S20hddtemp

http://github.com/brinkman83/bashrc · Shell · 91 lines · 58 code · 10 blank · 23 comment · 21 complexity · f85cd79ae51d3f89ab756e723021a6b9 MD5 · raw file

  1. #!/bin/sh
  2. #
  3. # skeleton example file to build /etc/init.d/ scripts.
  4. # This file should be used to construct scripts for /etc/init.d.
  5. #
  6. # Written by Miquel van Smoorenburg <miquels@cistron.nl>.
  7. # Modified for Debian GNU/Linux
  8. # by Ian Murdock <imurdock@gnu.ai.mit.edu>.
  9. #
  10. # Version: @(#)skeleton 1.8 03-Mar-1998 miquels@cistron.nl
  11. #
  12. ### BEGIN INIT INFO
  13. # Provides: hddtemp
  14. # Required-Start: $remote_fs $syslog $network
  15. # Required-Stop: $remote_fs $syslog $network
  16. # Default-Start: 2 3 4 5
  17. # Default-Stop: 0 1 6
  18. # Short-Description: disk temperature monitoring daemon
  19. # Description: hddtemp is a disk temperature monitoring daemon
  20. ### END INIT INFO
  21. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  22. NAME=hddtemp
  23. DAEMON=/usr/sbin/$NAME
  24. DESC="disk temperature monitoring daemon"
  25. DISKS="/dev/hd? /dev/sr? /dev/sg? /dev/sd?"
  26. INTERFACE="0.0.0.0"
  27. PORT="7634"
  28. SEPARATOR="|"
  29. RUN_SYSLOG="0"
  30. # Reads config file (will override defaults above)
  31. [ -r /etc/default/hddtemp ] && . /etc/default/hddtemp
  32. if [ -n "$RUN_SYSLOG" ] && [ "$RUN_SYSLOG" != "0" ] ; then
  33. SYSLOG_ARG="-S $RUN_SYSLOG"
  34. fi
  35. if [ "$RUN_DAEMON" = "true" ] || [ "$RUN_DAEMON" = "yes" ] ; then
  36. DAEMON_ARG="-d -l $INTERFACE -p $PORT -s $SEPARATOR"
  37. fi
  38. [ -x "$DAEMON" ] || exit 0
  39. . /lib/lsb/init-functions
  40. case "$1" in
  41. start)
  42. # master switch
  43. if [ -n "$DAEMON_ARG" ] || [ -n "$SYSLOG_ARG" ] ; then
  44. log_daemon_msg "Starting $DESC" "$NAME:"
  45. CDROMS_LIST=$(sed -ne 's/^drive name:\t\+\(.*\)$/ \/dev\/\1/p' /proc/sys/dev/cdrom/info 2>/dev/null) || :
  46. CDROMS_LIST="$CDROMS_LIST $(grep -sl '^ide-scsi ' /proc/ide/hd*/driver | awk -F / '{ print "/dev/"$4 }')"
  47. for disk in $DISKS ; do
  48. echo $CDROMS_LIST | grep -wq $disk && continue
  49. echo $DISKS_NOPROBE | grep -wq $disk && continue
  50. if $DAEMON -wn $OPTIONS $disk 2>/dev/null | grep -q '^[0-9]\+$' ; then
  51. DISKS_LIST="$DISKS_LIST $disk";
  52. fi
  53. done
  54. if [ -n "$DISKS_LIST" ] || [ -n "$DISKS_NOPROBE" ] ; then
  55. start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_ARG $SYSLOG_ARG $OPTIONS $DISKS_NOPROBE $DISKS_LIST
  56. ret=$?
  57. log_progress_msg "$DISKS_NOPROBE$DISKS_LIST"
  58. log_end_msg $ret
  59. else
  60. log_progress_msg "no disks with monitoring capability were found."
  61. log_end_msg 0
  62. fi
  63. fi
  64. ;;
  65. stop)
  66. # master switch
  67. if [ "$RUN_DAEMON" = "true" ] || [ "$RUN_DAEMON" = "yes" ] || [ "$RUN_SYSLOG" != "0" ] ; then
  68. log_daemon_msg "Stopping $DESC" "$NAME"
  69. start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30
  70. log_end_msg $?
  71. fi
  72. ;;
  73. reload|restart|force-reload)
  74. $0 stop && $0 start
  75. ;;
  76. *)
  77. echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
  78. exit 1
  79. ;;
  80. esac
  81. exit 0