Turn low_bat_chack and system_stats into services

This commit is contained in:
Michel-FK 2020-06-01 09:37:17 +02:00
parent 4edc9abae2
commit 4505c7a8f4
3 changed files with 72 additions and 6 deletions

View File

@ -0,0 +1,36 @@
#!/bin/sh
#
# Start/stop low_bat_check
#
DAEMON=/usr/local/sbin/low_bat_check
PIDFILE=/var/run/low_bat_check.pid
case "$1" in
start)
echo -n "Starting low_bat_check: "
start-stop-daemon -S -x ${DAEMON} -p ${PIDFILE} -m -b -- > /dev/null 2>&1
if [ ${?} -eq 0 ]; then
echo "OK"
else
echo "ERROR"
fi
;;
stop)
echo -n "Stopping low_bat_check: "
start-stop-daemon -K -x ${DAEMON} -p ${PIDFILE} -o > /dev/null 2>&1
if [ ${?} -eq 0 ]; then
echo "OK"
else
echo "ERROR"
fi
;;
restart)
${0} stop
sleep 1 # Prevent race condition: ensure low_bat_check stops before start.
${0} start
;;
*)
echo "Usage: ${0} {start|stop|restart}"
exit 1
esac

View File

@ -0,0 +1,36 @@
#!/bin/sh
#
# Start/stop system_stats
#
DAEMON=/usr/local/sbin/system_stats
PIDFILE=/var/run/system_stats.pid
case "$1" in
start)
echo -n "Starting system_stats: "
start-stop-daemon -S -x ${DAEMON} -p ${PIDFILE} -m -b -- > /dev/null 2>&1
if [ ${?} -eq 0 ]; then
echo "OK"
else
echo "ERROR"
fi
;;
stop)
echo -n "Stopping system_stats: "
start-stop-daemon -K -x ${DAEMON} -p ${PIDFILE} -o > /dev/null 2>&1
if [ ${?} -eq 0 ]; then
echo "OK"
else
echo "ERROR"
fi
;;
restart)
${0} stop
sleep 1 # Prevent race condition: ensure system_stats stops before start.
${0} start
;;
*)
echo "Usage: ${0} {start|stop|restart}"
exit 1
esac

View File

@ -15,10 +15,4 @@
#notif_set 0 "upgrade"
#upgrade_fk_incremental
# Low bat check #
low_bat_check >/dev/null 2>&1 &
# System stats #
system_stats >/dev/null 2>&1 &
exit 0