kumquat-buildroot/package/mender/S42mender
Angelo Compagnucci 63739c5c25 package/mender: fix sysv startup script
Mender is a service explicitly written for systemd and so it doesn't
fork on background, doesn't redirect outputs and doesn't create a pid
file by itself.
To make the service running correctly is therefore necessary to use the
-m switch of start-stop-daemon to create the pid file and -b option to
send the process to background.
Logging is preserved because the service will log anyway on syslog.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-15 23:00:12 +01:00

57 lines
1.2 KiB
Bash

#!/bin/sh
#
# Starts mender service.
#
start() {
# If /var/lib/mender is a symlink to /var/run/mender, and
# - the filesystem is RO (i.e. we can not rm the symlink),
# create the directory pointed to by the symlink.
# - the filesystem is RW (i.e. we can rm the symlink),
# replace the symlink with an actual directory
if [ -L /var/lib/mender \
-a "$(readlink /var/lib/mender)" = "/var/run/mender" ]
then
if rm -f /var/lib/mender >/dev/null 2>&1; then
mkdir -p /var/lib/mender
else
echo "No persistent location to store mender data. Data will be lost"
echo "at reboot. Are you sure this is what you want to do?"
mkdir -p "$(readlink /var/lib/mender)"
fi
fi
printf "Starting mender service: "
umask 077
start-stop-daemon -S -q -b -m -p /var/run/mender.pid \
--exec /usr/bin/mender -- -daemon
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
stop() {
printf "Stopping mender service: "
start-stop-daemon -K -q -p /var/run/mender.pid
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?