diff options
| author | Carlos Santos <casantos@datacom.com.br> | 2018-11-06 22:49:11 -0200 |
|---|---|---|
| committer | Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> | 2018-12-10 22:15:51 +0100 |
| commit | b3c76a435b16c5031a1519810f93972c42869ae0 (patch) | |
| tree | 49458de946b4c56754154e676b766be331ce8f39 /package/sysklogd/S02klogd | |
| parent | 5e5c2e2194bc776842a917e6b54a164b8093f42f (diff) | |
| download | buildroot-b3c76a435b16c5031a1519810f93972c42869ae0.tar.gz buildroot-b3c76a435b16c5031a1519810f93972c42869ae0.zip | |
sysklogd: rewrite init script
- Split it into S01syslogd and S02klogd to make every init script be
called the same as the executable it starts.
- Implement start, stop, restart and reload as functions, like in other
init scripts, using start-stop-daemon.
- Indent with tabs, not spaces.
- Detect and report start/stop errors (previous version ignored them and
always reported OK).
- Support /etc/default/$DAEMON configuration files.
- Do not kill syslogd in "reload". Send a SIGHUP signal, instructing it
to perform a re-initialization.
- Do not kill klogd in "reload". Send a signal (default 0, which does
nothing). Users can configure this signal in /etc/default/klogd to
either SIGUSR1 or SIGUSR2.
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
Reviewed-by: Matt Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Diffstat (limited to 'package/sysklogd/S02klogd')
| -rw-r--r-- | package/sysklogd/S02klogd | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/package/sysklogd/S02klogd b/package/sysklogd/S02klogd new file mode 100644 index 0000000000..93f39e1f0e --- /dev/null +++ b/package/sysklogd/S02klogd @@ -0,0 +1,65 @@ +#!/bin/sh + +DAEMON="klogd" +PIDFILE="/var/run/$DAEMON.pid" + +KLOGD_ARGS="" + +KLOGD_RELOAD="0" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +start() { + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \ + -- $KLOGD_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 + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +restart() { + stop + sleep 1 + start +} + +# SIGUSR1 makes klogd reload kernel module symbols +# SIGUSR2 makes klogd reload static kernel symbols and kernel module symbols +reload() { + printf 'Reloading %s: ' "$DAEMON" + start-stop-daemon -K -s "$KLOGD_RELOAD" -q -p "$PIDFILE" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +case "$1" in + start|stop|restart|reload) + "$1";; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac |

