mirror of
https://github.com/troglobit/finit.git
synced 2026-09-30 21:13:01 +07:00
Install start-stop-daemon in test root. Add S01-service.sh, which uses start-stop-daemon to start service.sh. Modify service.sh to respect signals, and not exit immediately when sleep exits due to SIGTERM. Remove PID file in signal callback and make sure to exit OK The test itself is basically a copy of the start-stop-service.sh test. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
44 lines
643 B
Bash
Executable File
44 lines
643 B
Bash
Executable File
#!/bin/sh
|
|
# SysV style start script for service.sh
|
|
|
|
DAEMON="/test_assets/service.sh"
|
|
PIDFILE="/var/run/service.pid"
|
|
|
|
start() {
|
|
printf 'Starting %s: ' "$DAEMON"
|
|
start-stop-daemon -S -b -q -p "$PIDFILE" -x "$DAEMON"
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
stop() {
|
|
printf 'Stopping %s: ' "$DAEMON"
|
|
start-stop-daemon -K -q -p "$PIDFILE"
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
sleep 1
|
|
start
|
|
}
|
|
|
|
case "$1" in
|
|
start|stop|restart)
|
|
"$1";;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart}, got $0 $1"
|
|
exit 1
|
|
esac
|