PageRenderTime 72ms CodeModel.GetById 63ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/rc2.d/S20fancontrol

http://github.com/brinkman83/bashrc
Shell | 66 lines | 50 code | 6 blank | 10 comment | 11 complexity | d007dfb8c2b450d8cb44b2e37f11d6c9 MD5 | raw file
 1#! /bin/sh
 2
 3### BEGIN INIT INFO
 4# Provides:          fancontrol
 5# Required-Start:    $remote_fs
 6# Required-Stop:     $remote_fs
 7# Default-Start:     2 3 4 5
 8# Default-Stop:
 9# Short-Description: fancontrol
10# Description:       fan speed regulator
11### END INIT INFO
12
13. /lib/lsb/init-functions
14
15[ -f /etc/default/rcS ] && . /etc/default/rcS
16PATH=/bin:/usr/bin:/sbin:/usr/sbin
17DAEMON=/usr/sbin/fancontrol
18DESC="fan speed regulator"
19NAME="fancontrol"
20PIDFILE=/var/run/fancontrol.pid
21CONF=/etc/fancontrol
22
23test -x $DAEMON || exit 0
24
25case "$1" in
26  start)
27  	if [ -f $CONF ] && [ -n "`grep INTERVAL $CONF | cut -d= -f2`" ]; then
28		if [ -n "`grep DEVPATH $CONF | cut -d= -f2`" ] && [ -n "`grep DEVNAME $CONF | cut -d= -f2`" ] ; then
29			log_daemon_msg "Starting $DESC" "$NAME"
30			start-stop-daemon --start --quiet --background --pidfile $PIDFILE --startas $DAEMON
31			log_end_msg $?
32		else
33			log_failure_msg "Not starting fancontrol, outdated configuration file; please re-run pwmconfig."
34		fi
35	else
36		if [ "$VERBOSE" != no ]; then
37			log_warning_msg "Not starting fancontrol; run pwmconfig first."
38		fi
39	fi
40	;;
41  stop)
42	log_daemon_msg "Stopping $DESC" "$NAME"
43	start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --startas $DAEMON
44	rm -f $PIDFILE
45	log_end_msg $?
46	;;
47  restart)
48  	$0 stop
49	sleep 3
50	$0 start
51	;;
52  force-reload)
53	if start-stop-daemon --stop --test --quiet --pidfile $PIDFILE --startas $DAEMON ; then
54		$0 restart
55	fi
56	;;
57  status)
58	status_of_proc $DAEMON $NAME && exit 0 || exit $?
59	;;
60  *)
61	log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload|status}"
62	exit 1
63	;;
64esac
65
66exit 0