PageRenderTime 449ms CodeModel.GetById 445ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 1ms

/init.d/hddtemp

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