mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-25 10:03:03 +01:00
bc3fdec6bc
Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
76 lines
1.1 KiB
Bash
76 lines
1.1 KiB
Bash
#!/bin/sh
|
|
|
|
NAME=thinkfan
|
|
BIN=/usr/sbin/$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
|