8b87d87688
- Split S01logging into S01syslogd and S02klogd. Install them only if no other syslog package is selected and the corresponding daemons are selected in the Busybox configuration. - Support /etc/default/$DAEMON configuration files. - Detect and report start/stop errors (previous version ignored them and always reported OK). - Use a separate function for restart. - Implement reload as restart. The dependency of busybox on rsyslog and syslog-ng was only needed because those packages also installed S01logging. Since now they no longer install the same file, these dependencies are no longer needed. The dependency on sysklogd is still needed since that one installs the syslogd and klogd executables with the same name as busybox. The -n option of syslogd/klogd is obligatory because start-stop-daemon starts it in the background. Therefore, move it out of the SYSLOGD_ARGS resp. KLOGD_ARGS variable so the user can no longer remove it. Signed-off-by: Carlos Santos <casantos@datacom.com.br> Reviewed-by: Matt Weber <matthew.weber@rockwellcollins.com> [Arnout: keep dependency on sysklogd] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
56 lines
1.0 KiB
Bash
56 lines
1.0 KiB
Bash
#!/bin/sh
|
|
|
|
DAEMON="syslogd"
|
|
PIDFILE="/var/run/$DAEMON.pid"
|
|
|
|
SYSLOGD_ARGS=""
|
|
|
|
# shellcheck source=/dev/null
|
|
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
|
|
|
# BusyBox' syslogd does not create a pidfile, so pass "-n" in the command line
|
|
# and use "-m" to instruct start-stop-daemon to create one.
|
|
start() {
|
|
printf 'Starting %s: ' "$DAEMON"
|
|
# shellcheck disable=SC2086 # we need the word splitting
|
|
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \
|
|
-- -n $SYSLOGD_ARGS
|
|
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
|
|
rm -f "$PIDFILE"
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
sleep 1
|
|
start
|
|
}
|
|
|
|
case "$1" in
|
|
start|stop|restart)
|
|
"$1";;
|
|
reload)
|
|
# Restart, since there is no true "reload" feature.
|
|
restart;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|reload}"
|
|
exit 1
|
|
esac
|