From 4505c7a8f421f6b55323957816f8921b8fb4d866 Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Mon, 1 Jun 2020 09:37:17 +0200 Subject: [PATCH] Turn low_bat_chack and system_stats into services --- .../etc/init.d/S07low-bat-check | 36 +++++++++++++++++++ .../rootfs-overlay/etc/init.d/S08system-stats | 36 +++++++++++++++++++ .../board/funkey/rootfs-overlay/etc/rc.local | 6 ---- 3 files changed, 72 insertions(+), 6 deletions(-) create mode 100755 FunKey/board/funkey/rootfs-overlay/etc/init.d/S07low-bat-check create mode 100755 FunKey/board/funkey/rootfs-overlay/etc/init.d/S08system-stats diff --git a/FunKey/board/funkey/rootfs-overlay/etc/init.d/S07low-bat-check b/FunKey/board/funkey/rootfs-overlay/etc/init.d/S07low-bat-check new file mode 100755 index 0000000..03a4bf5 --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/etc/init.d/S07low-bat-check @@ -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 diff --git a/FunKey/board/funkey/rootfs-overlay/etc/init.d/S08system-stats b/FunKey/board/funkey/rootfs-overlay/etc/init.d/S08system-stats new file mode 100755 index 0000000..16edd8b --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/etc/init.d/S08system-stats @@ -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 diff --git a/FunKey/board/funkey/rootfs-overlay/etc/rc.local b/FunKey/board/funkey/rootfs-overlay/etc/rc.local index 1d96541..baf6973 100755 --- a/FunKey/board/funkey/rootfs-overlay/etc/rc.local +++ b/FunKey/board/funkey/rootfs-overlay/etc/rc.local @@ -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