* [Buildroot] [PATCH v2 1/8] busybox: update S01logging
@ 2018-09-29 2:49 Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 2/8] busybox: add logging configuration file Carlos Santos
` (7 more replies)
0 siblings, 8 replies; 12+ messages in thread
From: Carlos Santos @ 2018-09-29 2:49 UTC (permalink / raw)
To: buildroot
Reformat and fix syslogd/klogd startup script for better quality and
code style:
- Detect and report start/stop errors (previous version ignored them and
always reported OK).
- Use a separate function for restart.
- Implement reload as restart.
- Support a configuration variable that completely disables the service
and issues a warning message on any invocation.
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
Changes v1->v2
- Implement suggestions made by Nicolas Cavallari and Arnout Vandecappelle
---
package/busybox/S01logging | 82 +++++++++++++++++++++++++-------------
1 file changed, 54 insertions(+), 28 deletions(-)
diff --git a/package/busybox/S01logging b/package/busybox/S01logging
index fcb3e7d236..ddd27bba9a 100644
--- a/package/busybox/S01logging
+++ b/package/busybox/S01logging
@@ -1,40 +1,66 @@
#!/bin/sh
-#
-# Start logging
-#
-SYSLOGD_ARGS=-n
-KLOGD_ARGS=-n
-[ -r /etc/default/logging ] && . /etc/default/logging
+DAEMON="logging"
+SPIDFILE="/var/run/syslogd.pid"
+KPIDFILE="/var/run/klogd.pid"
+SYSLOGD_ARGS=""
+KLOGD_ARGS=""
+ENABLED="yes"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
+
+if [ "$ENABLED" != "yes" ]; then
+ printf '%s is disabled\n' "$DAEMON"
+ exit 0
+fi
+
+# BusyBox' syslogd and klogd do not create pidfiles, so use "-m" to instruct
+# start-stop-daemon to create them. This also means that we must pass "-n" to
+# sylogd and klogd in the command line.
start() {
- printf "Starting logging: "
- start-stop-daemon -b -S -q -m -p /var/run/syslogd.pid --exec /sbin/syslogd -- $SYSLOGD_ARGS
- start-stop-daemon -b -S -q -m -p /var/run/klogd.pid --exec /sbin/klogd -- $KLOGD_ARGS
- echo "OK"
+ printf 'Starting %s: ' "$DAEMON"
+ status=0
+ # shellcheck disable=SC2086 # we need the word splitting
+ start-stop-daemon -b -S -q -m -p "$SPIDFILE" -x /sbin/syslogd -- -n $SYSLOGD_ARGS || status=$?
+ start-stop-daemon -b -S -q -m -p "$KPIDFILE" -x /sbin/klogd -- -n $KLOGD_ARGS || status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
}
stop() {
- printf "Stopping logging: "
- start-stop-daemon -K -q -p /var/run/syslogd.pid
- start-stop-daemon -K -q -p /var/run/klogd.pid
- echo "OK"
+ printf 'Stopping %s: ' "$DAEMON"
+ status=0
+ start-stop-daemon -K -q -p "$SPIDFILE" || status=$?
+ [ "$status" -eq 0 ] && rm -f "$SPIDFILE"
+ start-stop-daemon -K -q -p "$KPIDFILE" || status=$?
+ [ "$status" -eq 0 ] && rm -f "$KPIDFILE"
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
}
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload)
+restart() {
stop
+ sleep 1
start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|reload}"
- exit 1
-esac
+}
-exit $?
+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
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 2/8] busybox: add logging configuration file
2018-09-29 2:49 [Buildroot] [PATCH v2 1/8] busybox: update S01logging Carlos Santos
@ 2018-09-29 2:50 ` Carlos Santos
2018-10-01 13:12 ` Matthew Weber
2018-09-29 2:50 ` [Buildroot] [PATCH v2 3/8] rsyslog: update S01logging Carlos Santos
` (6 subsequent siblings)
7 siblings, 1 reply; 12+ messages in thread
From: Carlos Santos @ 2018-09-29 2:50 UTC (permalink / raw)
To: buildroot
Provide a template to help users to customize syslogd and klogd without
editting the startup script.
syslogd options worth to configure are remote logging (-R), rotation
(-s, -b) and minimal priority level (-l).
klogd minimal priority level (-c) can be configured too, preventing
non-critical kernel messages from appearing on the console.
This file is also useful as an example for init script authors.
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
Changes v1->v2
- Implement suggestions made by Nicolas Cavallari and Arnout Vandecappelle
---
package/busybox/busybox.mk | 2 ++
package/busybox/etc.default.logging | 13 +++++++++++++
2 files changed, 15 insertions(+)
create mode 100644 package/busybox/etc.default.logging
diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index 757086592f..91131c0012 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -252,6 +252,8 @@ define BUSYBOX_INSTALL_LOGGING_SCRIPT
then \
$(INSTALL) -m 0755 -D package/busybox/S01logging \
$(TARGET_DIR)/etc/init.d/S01logging; \
+ $(INSTALL) -m 0644 -D package/busybox/etc.default.logging \
+ $(TARGET_DIR)/etc/default/logging; \
fi
endef
diff --git a/package/busybox/etc.default.logging b/package/busybox/etc.default.logging
new file mode 100644
index 0000000000..6775622779
--- /dev/null
+++ b/package/busybox/etc.default.logging
@@ -0,0 +1,13 @@
+#
+# /etc/default/logging (busybox version)
+#
+
+# Use SYSLOGD_ARGS to pass additional arguments to syslogd (e.g. for log
+# rotation).
+# SYSLOGD_ARGS="" # (default value)
+
+# Use KLOGD_ARGS to pass additional arguments to klogd.
+# KLOGD_ARGS="" # (default value)
+
+# Uncomment the line below to disable this service
+# ENABLED="no"
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 3/8] rsyslog: update S01logging
2018-09-29 2:49 [Buildroot] [PATCH v2 1/8] busybox: update S01logging Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 2/8] busybox: add logging configuration file Carlos Santos
@ 2018-09-29 2:50 ` Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 4/8] rsyslog: add logging configuration file Carlos Santos
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Carlos Santos @ 2018-09-29 2:50 UTC (permalink / raw)
To: buildroot
Reformat and fix rsyslog startup script for better quality and code
style:
- Indent with tabs, not spaces.
- Support a configuration file at /etc/default (an example file will be
added in forthcomming patch).
- Support a configuration variable that completely disables the service
and issues a warning message on any invocation.
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
Changes v1->v2
- Implement suggestions made by Nicolas Cavallari and Arnout Vandecappelle
---
package/rsyslog/S01logging | 68 +++++++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 23 deletions(-)
diff --git a/package/rsyslog/S01logging b/package/rsyslog/S01logging
index 8e4a59c2d5..57a2663fad 100644
--- a/package/rsyslog/S01logging
+++ b/package/rsyslog/S01logging
@@ -1,36 +1,58 @@
#!/bin/sh
+DAEMON="rsyslogd"
+PIDFILE="/var/run/$DAEMON.pid"
+
+RSYSLOGD_ARGS=""
+ENABLED="yes"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
+
+if [ "$ENABLED" != "yes" ]; then
+ printf '%s is disabled\n' "$DAEMON"
+ exit 0
+fi
+
start() {
- printf "Starting rsyslog daemon: "
- start-stop-daemon -S -q -p /var/run/rsyslogd.pid --exec /usr/sbin/rsyslogd
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ printf 'Starting %s: ' "$DAEMON"
+ # shellcheck disable=SC2086 # we need the word splitting
+ start-stop-daemon -S -q -p "$PIDFILE" -x /usr/sbin/rsyslogd -- $RSYSLOGD_ARGS
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
}
stop() {
- printf "Stopping rsyslog daemon: "
- start-stop-daemon -K -q -p /var/run/rsyslogd.pid
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ 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
+ stop
+ sleep 1
+ start
}
case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload)
- restart
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
+ start|stop|restart)
+ "$1";;
+ reload)
+ # Restart, since there is no true "reload" feature (does not
+ # reconfigure/restart on SIGHUP, just closes all open files).
+ restart;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
esac
-
-exit $?
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 4/8] rsyslog: add logging configuration file
2018-09-29 2:49 [Buildroot] [PATCH v2 1/8] busybox: update S01logging Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 2/8] busybox: add logging configuration file Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 3/8] rsyslog: update S01logging Carlos Santos
@ 2018-09-29 2:50 ` Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 5/8] sysklogd: update S01logging Carlos Santos
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Carlos Santos @ 2018-09-29 2:50 UTC (permalink / raw)
To: buildroot
Provide a template to help users to customize rsyslog without editting
the startup script. Also warn about options that must not be used.
Add instructions on how to configure debugging, since it a bit tricky
when rsyslogd runs in background, requiring a separete log file.
This file is also useful as an example for init script authors.
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
Changes v1->v2
- Document that "-n" command line option must not be used.
- Small improvements in comments.
---
package/rsyslog/etc.default.logging | 15 +++++++++++++++
package/rsyslog/rsyslog.mk | 2 ++
2 files changed, 17 insertions(+)
create mode 100644 package/rsyslog/etc.default.logging
diff --git a/package/rsyslog/etc.default.logging b/package/rsyslog/etc.default.logging
new file mode 100644
index 0000000000..5b80a853a5
--- /dev/null
+++ b/package/rsyslog/etc.default.logging
@@ -0,0 +1,15 @@
+#
+# /etc/default/logging (rsyslog version)
+#
+
+# Use RSYSLOGD_ARGS to pass additional arguments to rsyslogd.
+# - Do NOT use "-i pid_file", "-n", nor "-v", since they will break the
+# startup script.
+# - Use "-d" to enable debug (see below). Warning: log files may be HUGE!
+# RSYSLOGD_ARGS="" # (default value)
+
+# You will need this along with "-d".
+# RSYSLOG_DEBUGLOG="/var/log/rsyslogd"; export RSYSLOG_DEBUGLOG
+
+# Uncomment the line below to disable this service
+# ENABLED="no"
diff --git a/package/rsyslog/rsyslog.mk b/package/rsyslog/rsyslog.mk
index 61e08ba765..c80d0696e2 100644
--- a/package/rsyslog/rsyslog.mk
+++ b/package/rsyslog/rsyslog.mk
@@ -74,6 +74,8 @@ endif
define RSYSLOG_INSTALL_INIT_SYSV
$(INSTALL) -m 0755 -D package/rsyslog/S01logging \
$(TARGET_DIR)/etc/init.d/S01logging
+ $(INSTALL) -m 0644 -D package/rsyslog/etc.default.logging \
+ $(TARGET_DIR)/etc/default/logging
endef
# The rsyslog.service is installed by rsyslog, but the link is not created
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 5/8] sysklogd: update S01logging
2018-09-29 2:49 [Buildroot] [PATCH v2 1/8] busybox: update S01logging Carlos Santos
` (2 preceding siblings ...)
2018-09-29 2:50 ` [Buildroot] [PATCH v2 4/8] rsyslog: add logging configuration file Carlos Santos
@ 2018-09-29 2:50 ` Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 6/8] sysklogd: add logging configuration file Carlos Santos
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Carlos Santos @ 2018-09-29 2:50 UTC (permalink / raw)
To: buildroot
Reformat and fix syslogd/klogd startup script for better quality and
code style:
- Implement start, stop, restart and reload as functions, like in other
S01logging 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 a configuration file at /etc/default (an example file will be
added in forthcomming patch).
- Support a configuration variable that completely disables the service
and issues a warning message on any invocation.
- Do not kill syslogd in "reload". Send a SIGHUP signal, instructing it
to perform a re-initialization. Also do not kill klogd. Send a signal
(default 0, which does nothing). Users can configure this signal in
/etc/default/logging to either SIGUSR1 or SIGUSR2.
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
Changes v1->v2
- Implement suggestions made by Arnout Vandecappelle
---
package/sysklogd/S01logging | 90 ++++++++++++++++++++++++++++---------
1 file changed, 70 insertions(+), 20 deletions(-)
diff --git a/package/sysklogd/S01logging b/package/sysklogd/S01logging
index 1cbfe869fa..44af1f9f41 100644
--- a/package/sysklogd/S01logging
+++ b/package/sysklogd/S01logging
@@ -1,25 +1,75 @@
#!/bin/sh
-case "$1" in
- start)
- printf "Starting logging: "
- /sbin/syslogd -m 0
- /sbin/klogd
+DAEMON="sysklogd"
+SPIDFILE="/var/run/syslogd.pid"
+KPIDFILE="/var/run/klogd.pid"
+
+SYSLOGD_ARGS="-m 0"
+KLOGD_ARGS=""
+KLOGD_RELOAD="0"
+ENABLED="yes"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
+
+if [ "$ENABLED" != "yes" ]; then
+ printf '%s is disabled\n' "$DAEMON"
+ exit 0
+fi
+
+start() {
+ printf 'Starting %s: ' "$DAEMON"
+ status=0
+ # shellcheck disable=SC2086 # we need the word splitting
+ start-stop-daemon -S -q -p "$SPIDFILE" -x /sbin/syslogd -- $SYSLOGD_ARGS || status=$?
+ start-stop-daemon -S -q -p "$KPIDFILE" -x /sbin/klogd -- $KLOGD_ARGS || status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
+}
+
+stop() {
+ printf 'Stopping %s: ' "$DAEMON"
+ status=0
+ start-stop-daemon -K -q -p "$SPIDFILE" || status=$?
+ start-stop-daemon -K -q -p "$KPIDFILE" || status=$?
+ if [ "$status" -eq 0 ]; then
echo "OK"
- ;;
- stop)
- printf "Stopping logging: "
- [ -f /var/run/klogd.pid ] && kill `cat /var/run/klogd.pid`
- [ -f /var/run/syslogd.pid ] && kill `cat /var/run/syslogd.pid`
+ else
+ echo "FAIL"
+ fi
+ return "$status"
+}
+
+restart() {
+ stop
+ sleep 1
+ start
+}
+
+# SIGHUP makes syslogd reload its configuration
+# SIGUSR1 makes klogd reload kernel module symbols
+# SIGUSR2 makes klogd reload static kernel symbols and kernel module symbols
+reload() {
+ printf 'Reloading %s: ' "$DAEMON"
+ status=0
+ start-stop-daemon -K -s HUP -q -p "$SPIDFILE" || status=$?
+ start-stop-daemon -K -s "$KLOGD_RELOAD" -q -p "$KPIDFILE" || status=$?
+ if [ "$status" -eq 0 ]; then
echo "OK"
- ;;
- restart|reload)
- $0 stop
- $0 start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
-esac
+ else
+ echo "FAIL"
+ fi
+ return "$status"
+}
-exit $?
+case "$1" in
+ start|stop|restart|reload)
+ "$1";;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
+esac
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 6/8] sysklogd: add logging configuration file
2018-09-29 2:49 [Buildroot] [PATCH v2 1/8] busybox: update S01logging Carlos Santos
` (3 preceding siblings ...)
2018-09-29 2:50 ` [Buildroot] [PATCH v2 5/8] sysklogd: update S01logging Carlos Santos
@ 2018-09-29 2:50 ` Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 7/8] syslog-ng: update S01logging Carlos Santos
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Carlos Santos @ 2018-09-29 2:50 UTC (permalink / raw)
To: buildroot
Provide a template to help users to customize syslogd and klogd without
editting the startup script. Also warn about options that must not be
used.
syslogd options worth to configure are mark interval (-m), remote log
support (-r) and domain list (-s).
Give example of how to configure klogd re-initialization signal.
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
Changes v1->v2:
- Document that the "-n" command line option must not be used.
- Going against the request from Arnout Vandecappelle, keep the klogd reload
configuration. Add a comment explainig why it is still useful. BTW, I work
on a project which requires dynamic installation of kernel modules.
---
package/sysklogd/etc.default.logging | 30 ++++++++++++++++++++++++++++
package/sysklogd/sysklogd.mk | 2 ++
2 files changed, 32 insertions(+)
create mode 100644 package/sysklogd/etc.default.logging
diff --git a/package/sysklogd/etc.default.logging b/package/sysklogd/etc.default.logging
new file mode 100644
index 0000000000..9bf468679a
--- /dev/null
+++ b/package/sysklogd/etc.default.logging
@@ -0,0 +1,30 @@
+#
+# /etc/default/logging (sysklog version)
+#
+
+# Use SYSLOGD_ARGS to pass additional arguments to syslogd.
+# - Do NOT use "-n", "-v", since they will break the startup script.
+# - Do NOT use "-d", since debugging does not work when running in background.
+# SYSLOGD_ARGS="-m 0" # (default value)
+
+# Use KLOGD_ARGS to pass additional arguments to klogd.
+# - Do NOT use "-n", "-o" nor "-v", since they will break the startup script.
+# - Do NOT use "-d", since debugging does not work when running in background.
+# KLOGD_ARGS="-m 0" # (default value)
+
+# KLOGD_RELOAD selects the "S01logging reload" behavior.
+# - "USR1" will cause the kernel module symbols to be reloaded.
+# - "USR2" will cause both the static kernel symbols and the kernel module
+# symbols to be reloaded.
+# - "0" will do nothing.
+# - Do not use any other value here. Use kill(1) for fine-grained control of
+# klogd, as documented in its manual page.
+#
+# Most users will never need to reload klogd in buildroot context because they
+# are not going to dynamically install kernel modules. In the rare cases that
+# this does happen, the user should be smart enough to send a SIGUSR1/2 but
+# let's keep this configurable for documentation purposes.
+# KLOGD_RELOAD="0" # (default value)
+
+# Uncomment the line below to disable this service
+# ENABLED="no"
diff --git a/package/sysklogd/sysklogd.mk b/package/sysklogd/sysklogd.mk
index c4f064c10b..b7e67ffee3 100644
--- a/package/sysklogd/sysklogd.mk
+++ b/package/sysklogd/sysklogd.mk
@@ -25,6 +25,8 @@ endef
define SYSKLOGD_INSTALL_INIT_SYSV
$(INSTALL) -m 755 -D package/sysklogd/S01logging \
$(TARGET_DIR)/etc/init.d/S01logging
+ $(INSTALL) -m 0644 -D package/sysklogd/etc.default.logging \
+ $(TARGET_DIR)/etc/default/logging
endef
define SYSKLOGD_INSTALL_INIT_SYSTEMD
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 7/8] syslog-ng: update S01logging
2018-09-29 2:49 [Buildroot] [PATCH v2 1/8] busybox: update S01logging Carlos Santos
` (4 preceding siblings ...)
2018-09-29 2:50 ` [Buildroot] [PATCH v2 6/8] sysklogd: add logging configuration file Carlos Santos
@ 2018-09-29 2:50 ` Carlos Santos
2018-09-29 3:11 ` Chris Packham
2018-09-29 2:50 ` [Buildroot] [PATCH v2 8/8] syslog-ng: add logging configuration file Carlos Santos
2018-10-01 13:00 ` [Buildroot] [PATCH v2 1/8] busybox: update S01logging Matthew Weber
7 siblings, 1 reply; 12+ messages in thread
From: Carlos Santos @ 2018-09-29 2:50 UTC (permalink / raw)
To: buildroot
Reformat and fix syslog-ng startup script for better quality and code
style:
- Indent with tabs, not spaces.
- Do not kill syslog-ng in "reload". Send a SIGHUP signal, instructing
it to perform a re-initialization.
- Support a configuration file at /etc/default (an example file will be
added in forthcomming patch).
- Support a configuration variable that completely disables the service
and issues a warning message on any invocation.
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
Changes v1->v2:
- Implement changes suggested by Arnout Vandecappelle.
---
package/syslog-ng/S01logging | 73 +++++++++++++++++++++++++-----------
1 file changed, 51 insertions(+), 22 deletions(-)
diff --git a/package/syslog-ng/S01logging b/package/syslog-ng/S01logging
index d7c899a1e3..58e120e5f3 100644
--- a/package/syslog-ng/S01logging
+++ b/package/syslog-ng/S01logging
@@ -1,17 +1,42 @@
#!/bin/sh
+DAEMON="syslog-ng"
+PIDFILE="/var/run/$DAEMON.pid"
+
+SYSLOG_NG_ARGS=""
+ENABLED="yes"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$DAEMON"g ] && . "/etc/default/$DAEMON"
+
+if [ "$ENABLED" != "yes" ]; then
+ printf '%s is disabled\n' "$DAEMON"
+ exit 0
+fi
+
start() {
- printf "Starting syslog-ng daemon: "
- start-stop-daemon -S -q -p /var/run/syslog-ng.pid \
- -x /usr/sbin/syslog-ng -- --pidfile /var/run/syslog-ng.pid
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ printf 'Starting %s: ' "$DAEMON"
+ # shellcheck disable=SC2086 # we need the word splitting
+ start-stop-daemon -S -q -p "$PIDFILE" -x /usr/sbin/syslog-ng -- $SYSLOG_NG_ARGS
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
}
stop() {
- printf "Stopping syslog-ng daemon: "
- start-stop-daemon -K -q -p /var/run/syslog-ng.pid \
- -x /usr/sbin/syslog-ng
- [ $? = 0 ] && echo "OK" || echo "FAIL"
+ 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() {
@@ -20,19 +45,23 @@ restart() {
start
}
+# SIGHUP makes syslog-ng reload its configuration
+reload() {
+ printf 'Stopping %s: ' "$DAEMON"
+ start-stop-daemon -K -s HUP -q -p "$PIDFILE"
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
+}
+
case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload)
- restart
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
+ start|stop|restart|reload)
+ "$1";;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
esac
-
-exit $?
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 8/8] syslog-ng: add logging configuration file
2018-09-29 2:49 [Buildroot] [PATCH v2 1/8] busybox: update S01logging Carlos Santos
` (5 preceding siblings ...)
2018-09-29 2:50 ` [Buildroot] [PATCH v2 7/8] syslog-ng: update S01logging Carlos Santos
@ 2018-09-29 2:50 ` Carlos Santos
2018-09-29 3:14 ` Chris Packham
2018-10-01 13:00 ` [Buildroot] [PATCH v2 1/8] busybox: update S01logging Matthew Weber
7 siblings, 1 reply; 12+ messages in thread
From: Carlos Santos @ 2018-09-29 2:50 UTC (permalink / raw)
To: buildroot
Provide a template to help users to customize syslog-ng without editting
the startup script. Mostly warn about options that must not be used.
This file is also useful as an example for init script authors.
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
Changes v1->v2
- Document that -F/--foreground must not be used
---
package/syslog-ng/etc.default.logging | 14 ++++++++++++++
package/syslog-ng/syslog-ng.mk | 2 ++
2 files changed, 16 insertions(+)
create mode 100644 package/syslog-ng/etc.default.logging
diff --git a/package/syslog-ng/etc.default.logging b/package/syslog-ng/etc.default.logging
new file mode 100644
index 0000000000..eda594aaef
--- /dev/null
+++ b/package/syslog-ng/etc.default.logging
@@ -0,0 +1,14 @@
+#
+# /etc/default/logging (syslog-ng version)
+#
+
+# Use SYSLOG_NG_ARGS to pass additional arguments to rsyslogd.
+# - Do NOT use "-F/--foreground", "--help"/"-h", "--version"/"-V", "--stderr"/"-e",
+# "--syntax-only"/"-s", or "--process-mode=<background|safe-background>", since
+# they will break the startup script.
+# - Do NOT use "--debug"/"-d", since debugging does not work when running in
+# background.
+# SYSLOG_NG_ARGS="" # (default value)
+
+# Uncomment the line below to disable this service
+# ENABLED="no"
diff --git a/package/syslog-ng/syslog-ng.mk b/package/syslog-ng/syslog-ng.mk
index 793fea0972..a837dad841 100644
--- a/package/syslog-ng/syslog-ng.mk
+++ b/package/syslog-ng/syslog-ng.mk
@@ -95,6 +95,8 @@ endif
define SYSLOG_NG_INSTALL_INIT_SYSV
$(INSTALL) -m 0755 -D package/syslog-ng/S01logging \
$(TARGET_DIR)/etc/init.d/S01logging
+ $(INSTALL) -m 0644 -D package/syslog-ng/etc.default.logging \
+ $(TARGET_DIR)/etc/default/logging
endef
# By default syslog-ng installs a number of sample configuration
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 7/8] syslog-ng: update S01logging
2018-09-29 2:50 ` [Buildroot] [PATCH v2 7/8] syslog-ng: update S01logging Carlos Santos
@ 2018-09-29 3:11 ` Chris Packham
0 siblings, 0 replies; 12+ messages in thread
From: Chris Packham @ 2018-09-29 3:11 UTC (permalink / raw)
To: buildroot
On Sat, 29 Sep 2018, 2:50 PM Carlos Santos, <casantos@datacom.com.br> wrote:
> Reformat and fix syslog-ng startup script for better quality and code
> style:
>
> - Indent with tabs, not spaces.
> - Do not kill syslog-ng in "reload". Send a SIGHUP signal, instructing
> it to perform a re-initialization.
> - Support a configuration file at /etc/default (an example file will be
> added in forthcomming patch).
> - Support a configuration variable that completely disables the service
> and issues a warning message on any invocation.
>
> Signed-off-by: Carlos Santos <casantos@datacom.com.br>
> ---
> Changes v1->v2:
> - Implement changes suggested by Arnout Vandecappelle.
> ---
> package/syslog-ng/S01logging | 73 +++++++++++++++++++++++++-----------
> 1 file changed, 51 insertions(+), 22 deletions(-)
>
> diff --git a/package/syslog-ng/S01logging b/package/syslog-ng/S01logging
> index d7c899a1e3..58e120e5f3 100644
> --- a/package/syslog-ng/S01logging
> +++ b/package/syslog-ng/S01logging
> @@ -1,17 +1,42 @@
> #!/bin/sh
>
> +DAEMON="syslog-ng"
> +PIDFILE="/var/run/$DAEMON.pid"
> +
> +SYSLOG_NG_ARGS=""
> +ENABLED="yes"
> +
> +# shellcheck source=/dev/null
> +[ -r "/etc/default/$DAEMON"g ] && . "/etc/default/$DAEMON"
>
Stray 'g'.
+
> +if [ "$ENABLED" != "yes" ]; then
> + printf '%s is disabled\n' "$DAEMON"
> + exit 0
> +fi
> +
> start() {
> - printf "Starting syslog-ng daemon: "
> - start-stop-daemon -S -q -p /var/run/syslog-ng.pid \
> - -x /usr/sbin/syslog-ng -- --pidfile /var/run/syslog-ng.pid
> - [ $? = 0 ] && echo "OK" || echo "FAIL"
> + printf 'Starting %s: ' "$DAEMON"
> + # shellcheck disable=SC2086 # we need the word splitting
> + start-stop-daemon -S -q -p "$PIDFILE" -x /usr/sbin/syslog-ng --
> $SYSLOG_NG_ARGS
> + status=$?
> + if [ "$status" -eq 0 ]; then
> + echo "OK"
> + else
> + echo "FAIL"
> + fi
> + return "$status"
> }
>
> stop() {
> - printf "Stopping syslog-ng daemon: "
> - start-stop-daemon -K -q -p /var/run/syslog-ng.pid \
> - -x /usr/sbin/syslog-ng
> - [ $? = 0 ] && echo "OK" || echo "FAIL"
> + 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() {
> @@ -20,19 +45,23 @@ restart() {
> start
> }
>
> +# SIGHUP makes syslog-ng reload its configuration
> +reload() {
> + printf 'Stopping %s: ' "$DAEMON"
> + start-stop-daemon -K -s HUP -q -p "$PIDFILE"
> + status=$?
> + if [ "$status" -eq 0 ]; then
> + echo "OK"
> + else
> + echo "FAIL"
> + fi
> + return "$status"
> +}
> +
> case "$1" in
> - start)
> - start
> - ;;
> - stop)
> - stop
> - ;;
> - restart|reload)
> - restart
> - ;;
> - *)
> - echo "Usage: $0 {start|stop|restart}"
> - exit 1
> + start|stop|restart|reload)
> + "$1";;
> + *)
> + echo "Usage: $0 {start|stop|restart|reload}"
> + exit 1
> esac
> -
> -exit $?
> --
> 2.17.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180929/cf397922/attachment.html>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 8/8] syslog-ng: add logging configuration file
2018-09-29 2:50 ` [Buildroot] [PATCH v2 8/8] syslog-ng: add logging configuration file Carlos Santos
@ 2018-09-29 3:14 ` Chris Packham
0 siblings, 0 replies; 12+ messages in thread
From: Chris Packham @ 2018-09-29 3:14 UTC (permalink / raw)
To: buildroot
On Sat, 29 Sep 2018, 2:50 PM Carlos Santos, <casantos@datacom.com.br> wrote:
> Provide a template to help users to customize syslog-ng without editting
> the startup script. Mostly warn about options that must not be used.
>
> This file is also useful as an example for init script authors.
>
> Signed-off-by: Carlos Santos <casantos@datacom.com.br>
> ---
> Changes v1->v2
> - Document that -F/--foreground must not be used
> ---
> package/syslog-ng/etc.default.logging | 14 ++++++++++++++
> package/syslog-ng/syslog-ng.mk | 2 ++
> 2 files changed, 16 insertions(+)
> create mode 100644 package/syslog-ng/etc.default.logging
>
> diff --git a/package/syslog-ng/etc.default.logging
> b/package/syslog-ng/etc.default.logging
> new file mode 100644
> index 0000000000..eda594aaef
> --- /dev/null
> +++ b/package/syslog-ng/etc.default.logging
> @@ -0,0 +1,14 @@
> +#
> +# /etc/default/logging (syslog-ng version)
> +#
> +
> +# Use SYSLOG_NG_ARGS to pass additional arguments to rsyslogd.
>
s/rsyslog/syslog-ng/
+# - Do NOT use "-F/--foreground", "--help"/"-h", "--version"/"-V",
> "--stderr"/"-e",
> +# "--syntax-only"/"-s", or
> "--process-mode=<background|safe-background>", since
> +# they will break the startup script.
> +# - Do NOT use "--debug"/"-d", since debugging does not work when running
> in
> +# background.
> +# SYSLOG_NG_ARGS="" # (default value)
> +
> +# Uncomment the line below to disable this service
> +# ENABLED="no"
> diff --git a/package/syslog-ng/syslog-ng.mk b/package/syslog-ng/
> syslog-ng.mk
> index 793fea0972..a837dad841 100644
> --- a/package/syslog-ng/syslog-ng.mk
> +++ b/package/syslog-ng/syslog-ng.mk
> @@ -95,6 +95,8 @@ endif
> define SYSLOG_NG_INSTALL_INIT_SYSV
> $(INSTALL) -m 0755 -D package/syslog-ng/S01logging \
> $(TARGET_DIR)/etc/init.d/S01logging
> + $(INSTALL) -m 0644 -D package/syslog-ng/etc.default.logging \
> + $(TARGET_DIR)/etc/default/logging
> endef
>
> # By default syslog-ng installs a number of sample configuration
> --
> 2.17.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180929/25dc29e2/attachment.html>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 1/8] busybox: update S01logging
2018-09-29 2:49 [Buildroot] [PATCH v2 1/8] busybox: update S01logging Carlos Santos
` (6 preceding siblings ...)
2018-09-29 2:50 ` [Buildroot] [PATCH v2 8/8] syslog-ng: add logging configuration file Carlos Santos
@ 2018-10-01 13:00 ` Matthew Weber
7 siblings, 0 replies; 12+ messages in thread
From: Matthew Weber @ 2018-10-01 13:00 UTC (permalink / raw)
To: buildroot
Carlos,
On Fri, Sep 28, 2018 at 9:50 PM Carlos Santos <casantos@datacom.com.br> wrote:
>
> Reformat and fix syslogd/klogd startup script for better quality and
> code style:
>
> - Detect and report start/stop errors (previous version ignored them and
> always reported OK).
> - Use a separate function for restart.
> - Implement reload as restart.
> - Support a configuration variable that completely disables the service
> and issues a warning message on any invocation.
>
> Signed-off-by: Carlos Santos <casantos@datacom.com.br>
Reviewed-by: Matt Weber <matthew.weber@rockwellcollins.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH v2 2/8] busybox: add logging configuration file
2018-09-29 2:50 ` [Buildroot] [PATCH v2 2/8] busybox: add logging configuration file Carlos Santos
@ 2018-10-01 13:12 ` Matthew Weber
0 siblings, 0 replies; 12+ messages in thread
From: Matthew Weber @ 2018-10-01 13:12 UTC (permalink / raw)
To: buildroot
Carlos,
On Fri, Sep 28, 2018 at 9:50 PM Carlos Santos <casantos@datacom.com.br> wrote:
>
> Provide a template to help users to customize syslogd and klogd without
> editting the startup script.
>
> syslogd options worth to configure are remote logging (-R), rotation
> (-s, -b) and minimal priority level (-l).
>
> klogd minimal priority level (-c) can be configured too, preventing
> non-critical kernel messages from appearing on the console.
>
> This file is also useful as an example for init script authors.
>
> Signed-off-by: Carlos Santos <casantos@datacom.com.br>
> ---
> Changes v1->v2
> - Implement suggestions made by Nicolas Cavallari and Arnout Vandecappelle
> ---
> package/busybox/busybox.mk | 2 ++
> package/busybox/etc.default.logging | 13 +++++++++++++
> 2 files changed, 15 insertions(+)
> create mode 100644 package/busybox/etc.default.logging
>
> diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
> index 757086592f..91131c0012 100644
> --- a/package/busybox/busybox.mk
> +++ b/package/busybox/busybox.mk
> @@ -252,6 +252,8 @@ define BUSYBOX_INSTALL_LOGGING_SCRIPT
> then \
> $(INSTALL) -m 0755 -D package/busybox/S01logging \
> $(TARGET_DIR)/etc/init.d/S01logging; \
> + $(INSTALL) -m 0644 -D package/busybox/etc.default.logging \
> + $(TARGET_DIR)/etc/default/logging; \
> fi
> endef
>
> diff --git a/package/busybox/etc.default.logging b/package/busybox/etc.default.logging
> new file mode 100644
> index 0000000000..6775622779
> --- /dev/null
> +++ b/package/busybox/etc.default.logging
> @@ -0,0 +1,13 @@
> +#
> +# /etc/default/logging (busybox version)
> +#
> +
Would it possibly help the user when determining settings to include
man page links in these example configs or link to the docs in the
source tree?
> +# Use SYSLOGD_ARGS to pass additional arguments to syslogd (e.g. for log
> +# rotation).
> +# SYSLOGD_ARGS="" # (default value)
> +
> +# Use KLOGD_ARGS to pass additional arguments to klogd.
> +# KLOGD_ARGS="" # (default value)
> +
> +# Uncomment the line below to disable this service
> +# ENABLED="no"
> --
> 2.17.1
>
Matt
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2018-10-01 13:12 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-29 2:49 [Buildroot] [PATCH v2 1/8] busybox: update S01logging Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 2/8] busybox: add logging configuration file Carlos Santos
2018-10-01 13:12 ` Matthew Weber
2018-09-29 2:50 ` [Buildroot] [PATCH v2 3/8] rsyslog: update S01logging Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 4/8] rsyslog: add logging configuration file Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 5/8] sysklogd: update S01logging Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 6/8] sysklogd: add logging configuration file Carlos Santos
2018-09-29 2:50 ` [Buildroot] [PATCH v2 7/8] syslog-ng: update S01logging Carlos Santos
2018-09-29 3:11 ` Chris Packham
2018-09-29 2:50 ` [Buildroot] [PATCH v2 8/8] syslog-ng: add logging configuration file Carlos Santos
2018-09-29 3:14 ` Chris Packham
2018-10-01 13:00 ` [Buildroot] [PATCH v2 1/8] busybox: update S01logging Matthew Weber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox