diff options
author | Benjamin Trigona-Harany <slackbuilds@jaxartes.net> | 2014-02-07 22:53:06 +0700 |
---|---|---|
committer | Erik Hanson <erik@slackbuilds.org> | 2014-02-08 11:10:12 -0600 |
commit | 8e5c9ccf2412873107709343f14a965b86882a02 (patch) | |
tree | 3628cc47eab3331e780e6007351c79b09500e9be /system/thinkfan/rc.thinkfan | |
parent | af347ec2dc475738eb6103af53567802acd1cf2b (diff) | |
download | slackbuilds-8e5c9ccf2412873107709343f14a965b86882a02.tar.gz |
system/thinkfan: Added (fan control program).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/thinkfan/rc.thinkfan')
-rw-r--r-- | system/thinkfan/rc.thinkfan | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/system/thinkfan/rc.thinkfan b/system/thinkfan/rc.thinkfan new file mode 100644 index 0000000000..fae364cbe5 --- /dev/null +++ b/system/thinkfan/rc.thinkfan @@ -0,0 +1,76 @@ +#!/bin/sh + +NAME=thinkfan +BIN=/usr/bin/$NAME +CONFIG=/etc/thinkfan.conf +ARGS="-q -c $CONFIG" +PIDFILE=/var/run/$NAME.pid + +thinkfan_start() { + echo -n "Starting $NAME ... " + if [ -e "$PIDFILE" ]; then + echo "already running!" + else + $BIN $ARGS + if [ $? -ne 0 ] ; then + echo "failed to start!" + return 1 + else + echo "done!" + fi + fi +} + +thinkfan_status() { + if [ $(pgrep -f $BIN) ]; then + echo "thinkfan is running" + + if [ ! -e $PIDFILE ]; then + echo "Warning: Missing pid file $PIDFILE" + fi + + exit 0 + else + echo "thinkfan is stopped" + + if [ -e $PIDFILE ]; then + echo "Detected stale pid file $PIDFILE" + fi + + exit 0 + fi +} + +thinkfan_stop() { + echo -n "Stopping $NAME ... " + if [ -e "$PIDFILE" ]; then + kill -TERM $(cat $PIDFILE) > /dev/null 2>&1 + echo "done!" + rm -f "$PIDFILE" + else + echo "not running!" + fi +} + +thinkfan_restart() { + thinkfan_stop + sleep 1 + thinkfan_start +} + +case "$1" in +'start') + thinkfan_start + ;; +'status') + thinkfan_status + ;; +'stop') + thinkfan_stop + ;; +'restart') + thinkfan_restart + ;; +*) + echo "usage $0 start|stop|restart|status" +esac |