2020-01-09 11:28:25 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Script to stop RaspiSMS daemons
|
|
|
|
#
|
|
|
|
PID_DIR="/var/run/raspisms"
|
|
|
|
DAEMON_LAUNCHER_PID_FILE="/var/run/raspisms/RaspiSMS Daemon Launcher.pid"
|
|
|
|
PID_FILES=$PID_DIR/*.pid
|
|
|
|
|
|
|
|
|
|
|
|
kill_process()
|
|
|
|
{
|
|
|
|
local PID=$1
|
|
|
|
kill "$PID"
|
|
|
|
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
#Kill daemon launcher if available
|
|
|
|
if [ -f "$DAEMON_LAUNCHER_PID_FILE" ]
|
|
|
|
then
|
|
|
|
printf "Stop RaspiSMS daemon Launcher..."
|
|
|
|
PID=$(cat "$DAEMON_LAUNCHER_PID_FILE")
|
|
|
|
$(kill_process "$PID")
|
|
|
|
RETURN=$?
|
|
|
|
|
|
|
|
if [ $RETURN -eq 0 ]
|
|
|
|
then
|
2020-03-04 03:28:34 +01:00
|
|
|
rm -f "$DAEMON_LAUNCHER_PID_FILE"
|
2020-01-09 11:28:25 +01:00
|
|
|
printf "success.\n"
|
|
|
|
else
|
|
|
|
printf "failed.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
printf "Stop RaspiSMS remaining daemons..."
|
|
|
|
for f in $PID_FILES
|
|
|
|
do
|
|
|
|
[ -f "$f" ] || continue #Bypass no real file return on empty dir
|
|
|
|
|
|
|
|
printf "."
|
|
|
|
PID=$(cat "$f")
|
|
|
|
kill_process "$PID"
|
2020-03-04 03:28:34 +01:00
|
|
|
rm -f "$f"
|
2020-01-09 11:28:25 +01:00
|
|
|
done
|
|
|
|
printf "Done.\n"
|
|
|
|
|
|
|
|
exit 0
|