sysv init scripts: fix == bashism
PATCH 1/4 sysv init scripts: fix == bashism
test a == b is not available in e.g. dash.
Command(s) used for editing:
q=\[\"\'\]
operand="${q}?[$]?[a-zA-Z0-9_\?]+${q}?" ## doesn't detect ${VAR}
test_expr="(\[\s+${operand}\s+)==(\s+${operand}\s+\])"
find . -type f -name '[SK][0-9][0-9]*' | \
xargs sed -r -e "s@${test_expr}@\1=\2 at g" -i--- package/acpid/S02acpid | 4 ++-- package/bind/S81named | 4 ++-- package/dhcp/S80dhcp-relay | 4 ++-- package/dhcp/S80dhcp-server | 4 ++-- package/dnsmasq/S80dnsmasq | 4 ++-- package/dropbear/S50dropbear | 4 ++-- package/haveged/S21haveged | 4 ++-- package/inadyn/S70inadyn | 4 ++-- package/openntpd/S49ntp | 4 ++-- package/samba4/S91smb | 10 +++++----- package/shairport-sync/S99shairport-sync | 4 ++-- package/xbmc/S50xbmc | 4 ++-- 12 files changed, 27 insertions(+), 27 deletions(-)
package/acpid/S02acpid +2 -2
@@ -4,12 +4,12 @@ case "$1" in start) echo -n "Starting acpid: " start-stop-daemon -S -q -m -b -p /var/run/acpid.pid --exec /usr/sbin/acpid -- -n - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) echo -n "Stopping acpid: " start-stop-daemon -K -q -p /var/run/acpid.pid - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart) "$0" stop
package/bind/S81named +2 -2
@@ -16,12 +16,12 @@ case "$1" in fi echo -n "Starting domain name daemon: " start-stop-daemon -S -x $DAEMON -- -c $CONFIG -u named - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) echo -n "Stopping domain name daemon: " rndc stop || start-stop-daemon -K -x $DAEMON - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart) $0 stop || true
package/dhcp/S80dhcp-relay +2 -2
@@ -30,12 +30,12 @@ case "$1" in start) echo -n "Starting DHCP relay: " start-stop-daemon -S -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) echo -n "Stopping DHCP relay: " start-stop-daemon -K -x /usr/sbin/dhcrelay - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart | force-reload) $0 stop
package/dhcp/S80dhcp-server +2 -2
@@ -18,12 +18,12 @@ case "$1" in test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/ test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $INTERFACES - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) echo -n "Stopping DHCP server: dhcpd3" start-stop-daemon -K -x /usr/sbin/dhcpd - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart | force-reload) $0 stop
package/dnsmasq/S80dnsmasq +2 -2
@@ -7,12 +7,12 @@ case "$1" in start) echo -n "Starting dnsmasq: " start-stop-daemon -S -x /usr/sbin/dnsmasq - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) echo -n "Stopping dnsmasq: " start-stop-daemon -K -q -x /usr/sbin/dnsmasq - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart|reload) $0 stop
package/dropbear/S50dropbear +2 -2
@@ -13,12 +13,12 @@ start() { umask 077 start-stop-daemon -S -q -p /var/run/dropbear.pid \ --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" } stop() { echo -n "Stopping dropbear sshd: " start-stop-daemon -K -q -p /var/run/dropbear.pid - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" } restart() { stop
package/haveged/S21haveged +2 -2
@@ -6,12 +6,12 @@ case "$1" in start) echo -n "Starting haveged: " start-stop-daemon -S -x /usr/sbin/haveged -- -w 1024 -r 0 - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) echo -n "Stopping haveged: " start-stop-daemon -K -x /usr/sbin/haveged - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart|reload) $0 stop
package/inadyn/S70inadyn +2 -2
@@ -16,12 +16,12 @@ case "$1" in start) echo "Starting inadyn: " start-stop-daemon -S -x /usr/bin/inadyn - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) echo "Stopping inadyn: " start-stop-daemon -q -K -x /usr/bin/inadyn - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" rm -f /var/run/inadyn/inadyn.pid ;; restart)
package/openntpd/S49ntp +2 -2
@@ -7,12 +7,12 @@ case "$1" in start) echo -n "Starting openntpd: " start-stop-daemon -S -x /usr/sbin/ntpd - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) echo -n "Stopping openntpd: " start-stop-daemon -K -x /usr/sbin/ntpd - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart) "$0" stop
package/samba4/S91smb +5 -5
@@ -7,21 +7,21 @@ mkdir -p /var/log/samba start() { echo -n "Starting SMB services: " smbd -D - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" echo -n "Starting NMB services: " nmbd -D - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" } stop() { echo -n "Shutting down SMB services: " kill -9 `pidof smbd` - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" echo -n "Shutting down NMB services: " kill -9 `pidof nmbd` - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" } restart() {
@@ -32,7 +32,7 @@ restart() { reload() { echo -n "Reloading smb.conf file: " kill -HUP `pidof smbd` - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" } case "$1" in
package/shairport-sync/S99shairport-sync +2 -2
@@ -7,12 +7,12 @@ case "$1" in start) echo -n "Starting shairport-sync: " start-stop-daemon -S -q -m -b -p /var/run/shairport-sync.pid --exec /usr/bin/shairport-sync -- $OPTIONS - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) echo -n "Stopping shairport-sync: " start-stop-daemon -K -q -p /var/run/shairport-sync.pid - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart) $0 stop
package/xbmc/S50xbmc +2 -2
@@ -11,12 +11,12 @@ PIDFILE=/var/run/xbmc.pid start() { echo -n "Starting XBMC: " start-stop-daemon -S -q -b -m -p $PIDFILE --exec $BIN -- $XBMC $XBMC_ARGS - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" } stop() { echo -n "Stopping XBMC: " start-stop-daemon -K -q -p $PIDFILE - [ $? == 0 ] && echo "OK" || echo "FAIL" + [ $? = 0 ] && echo "OK" || echo "FAIL" } restart() { stop
Signature · 1 line
2.1.2
PATCH 2/4 sysv init scripts: remove gettext invocations
$"str" is supposed to translate str (depending on the current locale). In ash/dash/..., it cannot be expanded, so commands like
echo $"Usage: $0 start|stop"
are printed as '$Usage: SCRIPT start|stop' in [d]ash, and as 'Usage: SCRIPT start|stop' in bash.
This patch removes the '$' in front of '"'.
Command(s) used for editing:
find . -type f -name '[SK][0-9][0-9]*' | \
xargs sed -r -e 's@[$](["])@\1 at g' -i--- package/busybox/S15watchdog | 2 +- package/inadyn/S70inadyn | 2 +- package/netatalk/S50netatalk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
package/busybox/S15watchdog +1 -1
@@ -13,7 +13,7 @@ case "$1" in restart|reload) ;; *) - echo $"Usage: $0 {start|stop|restart}" + echo "Usage: $0 {start|stop|restart}" exit 1 esac
package/inadyn/S70inadyn +1 -1
@@ -29,7 +29,7 @@ case "$1" in "$0" start ;; *) - echo $"Usage: $0 {start|stop|restart}" + echo "Usage: $0 {start|stop|restart}" exit 1 esac
package/netatalk/S50netatalk +1 -1
@@ -25,7 +25,7 @@ case "$1" in stop ;; *) - echo $"Usage: $0 {start|stop|restart}" + echo "Usage: $0 {start|stop|restart}" exit 1 esac
Signature · 1 line
2.1.2
Thomas Petazzoni
AppliedPATCH 2/4 sysv init scripts: remove gettext invocations
Dear Andr? Erdmann,
Quoted 15 lines · Andr? Erdmann
$"str" is supposed to translate str (depending on the current locale). In ash/dash/..., it cannot be expanded, so commands like
echo $"Usage: $0 start|stop"
are printed as '$Usage: SCRIPT start|stop' in [d]ash, and as 'Usage: SCRIPT start|stop' in bash.
This patch removes the '$' in front of '"'.
Command(s) used for editing:
find . -type f -name '[SK][0-9][0-9]*' | \ xargs sed -r -e 's@[$](["])@\1 at g' -i
Quoted 6 lines
Signed-off-by Andr? Erdmann <[email protected]>--- package/busybox/S15watchdog | 2 +- package/inadyn/S70inadyn | 2 +- package/netatalk/S50netatalk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Applied, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 3/4 sysv init scripts: replace &>/dev/null redirection
In reply to André Erdmann"<command> &>/dev/null" is supposed to redirect all output to /dev/null.
However, in shells that don't support it (dash, ash without bash extensions), a command like "echo a &>/dev/null" is interpreted as
(a) "echo a" in background
(b) write nothing to /dev/null (redirect <empty command> to /dev/null)
This commit replaces "&>..." with ">/dev/null 2>&1".
--- package/network-manager/S45network-manager | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
package/network-manager/S45network-manager +1 -1
@@ -24,7 +24,7 @@ case "$1" in ;; stop) echo -n "Stopping NetworkManager ... " - [ ! -z "$PID" ] && kill $PID &> /dev/null + [ ! -z "$PID" ] && kill $PID > /dev/null 2>&1 if [ $? -gt 0 ]; then echo "failed!" else
Signature · 1 line
2.1.2
Thomas Petazzoni
AppliedPATCH 3/4 sysv init scripts: replace &>/dev/null redirection
Dear Andr? Erdmann,
Quoted 8 lines · Andr? Erdmann
"<command> &>/dev/null" is supposed to redirect all output to
/dev/null.However, in shells that don't support it (dash, ash without bash extensions), a command like "echo a &>/dev/null" is interpreted as
(a) "echo a" in background
(b) write nothing to/dev/null(redirect <empty command> to/dev/null)
Quoted 6 lines
This commit replaces "&>..." with ">/dev/null 2>&1".
Signed-off-by Andr? Erdmann <[email protected]>--- package/network-manager/S45network-manager | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 4/4 sysv init scripts: use symbolic names in trap command
In reply to André ErdmannNot really necessary(*), but checkbashisms complains about "trap with signal numbers".
(*) Quoting man 1p trap:
trap [action condition...]
[...]
The condition can be EXIT, 0 (equivalent to EXIT),
or a signal specified using a symbolic name, without the SIG prefix [...]
XSI-conformant systems also allow numeric signal numbers[...]
Only one file is affected by this commit, and it should be checked whether it really needs to ignore SIGTERM/SIGHUP or if the trap commands can simply be removed:
package/proftpd/S50proftpd
--- package/proftpd/S50proftpd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
package/proftpd/S50proftpd +3 -3
@@ -1,8 +1,8 @@ -#!/bin/sh +#!/bin/sh DAEMON=/usr/sbin/proftpd -trap "" 1 -trap "" 15 +trap "" HUP +trap "" TERM test -f $DAEMON || exit 0 [ ! -d /var/run/proftpd ] && mkdir /var/run/proftpd [ ! -f /var/log/wtmp ] && touch /var/log/wtmp
Signature · 1 line
2.1.2
Thomas Petazzoni
AppliedPATCH 4/4 sysv init scripts: use symbolic names in trap command
Dear Andr? Erdmann,
Quoted 15 lines · Andr? Erdmann
Not really
necessary(*), but checkbashisms complains about "trap with signal numbers".(*) Quoting man 1p trap:
trap [action condition...]
[...]
The condition can be EXIT, 0 (equivalent to EXIT),
or a signal specified using a symbolic name, without the SIG prefix [...]
XSI-conformant systems also allow numeric signal numbers[...]Only one file is affected by this commit, and it should be checked whether it really needs to ignore SIGTERM/SIGHUP or if the trap commands can simply be removed:
Quoted 6 lines
package/proftpd/S50proftpd
Signed-off-by Andr? Erdmann <[email protected]>--- package/proftpd/S50proftpd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Applied, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/4 sysv init scripts: fix == bashism
In reply to André ErdmannQuoted 4 lines · Andr? Erdmann
test a == b is not available in e.g. dash.
Command(s) used for editing:
Quoted 8 lines
q=\[\"\'\] operand="${q}?[$]?[a-zA-Z0-9_\?]+${q}?" ## doesn't detect ${VAR} test_expr="(\[\s+${operand}\s+)==(\s+${operand}\s+\])" find . -type f -name '[SK][0-9][0-9]*' | \ xargs sed -r -e "s@${test_expr}@\1=\2 at g" -iSigned-off-by Andr? Erdmann <[email protected]>
PATCH 1/4 sysv init scripts: fix == bashism
In reply to André ErdmannQuoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Andr?" == Andr? Erdmann <[email protected]> writes:
test a == b is not available in e.g. dash.
Command(s) used for editing:
Quoted 8 lines
q=\[\"\'\] operand="${q}?[$]?[a-zA-Z0-9_\?]+${q}?" ## doesn't detect ${VAR} test_expr="(\[\s+${operand}\s+)==(\s+${operand}\s+\])" find . -type f -name '[SK][0-9][0-9]*' | \ xargs sed -r -e "s@${test_expr}@\1=\2 at g" -iSigned-off-by Andr? Erdmann <[email protected]>
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard