Skip to contentSkip to conversation

init scripts: don't test if binaries exist

PATCH New Carlos Santos 3 participants 30 messages Apr 16, 2018

lore
Share & tools
lore
#0 lore raw

cover init scripts: don't test if binaries exist

As discussed in the mailing list, it is useless to test if a binary file exists and/or is executable. Buildroot installs both the executable files and their init scripts as part of the same packages. But if it ever happens for some reason, the error message from start-stop-daemon or from the shell should be pretty clear.

If a variable containing the file name existed (e.g. DAEMON) and was used only once it was replaced by the full path of the binary file. Unused variables resulting from these simplifications were removed too.

Carlos Santos (26):
bind: don't test if the binary exists in the init script
dbus: don't test if the binary exists in the init script
dhcpcd: don't test if the binary exists in the init script
dmraid: don't test if the binary exists in the init script
dnsmasq: don't test if the binary exists in the init script
eudev: don't test if the binary exists in the init script
haveged: don't test if the binary exists in the init script
modem-manager: don't test if the binary exists in the init script
mpd: don't test if the binary exists in the init script
neard: don't test if the binary exists in the init script
netplug: don't test if the binary exists in the init script
netsnmp: don't test if the binaries exist in the init script
network-manager: don't test if the binary exists in the init script
nfs-utils: don't test if the binary exists in the init script
ntp: don't test if the binary exists in the init script
openntpd: don't test if the binary exists in the init script
openvpn: don't test if the binary exists in the init script
proftpd: don't test if the binary exists in the init script
prosody: don't test if the binary exists in the init script
squid: don't test if the binary exists in the init script
tinyhttpd: don't test if the binary exists in the init script
tpm2-abrmd: don't test if the binary exists in the init script
transmission: don't test if the binary exists in the init script
triggerhappy: don't test if the binary exists in the init script
tvheadend: don't test if the binary exists in the init script
upmpdcli: don't test if the binary exists in the init script

 package/bind/S81named                      |  1 -
 package/dbus/S30dbus                       |  3 ---
 package/dhcpcd/S41dhcpcd                   |  1 -
 package/dmraid/S20dmraid                   |  2 --
 package/dnsmasq/S80dnsmasq                 |  1 -
 package/eudev/S10udev                      |  6 +-----
 package/haveged/S21haveged                 |  2 --
 package/modem-manager/S44modem-manager     |  2 --
 package/mpd/S95mpd                         |  1 -
 package/neard/S53neard                     |  6 +-----
 package/netplug/S29netplug                 |  2 --
 package/netsnmp/S59snmpd                   |  3 ---
 package/network-manager/S45network-manager | 10 +---------
 package/nfs-utils/S60nfs                   |  5 -----
 package/ntp/S49ntp                         |  6 +-----
 package/openntpd/S49ntp                    |  1 -
 package/openvpn/S60openvpn                 |  6 +-----
 package/proftpd/S50proftpd                 |  4 +---
 package/prosody/S50prosody                 |  6 +-----
 package/squid/S97squid                     |  1 -
 package/tinyhttpd/S85tinyhttpd             |  1 -
 package/tpm2-abrmd/S80tpm2-abrmd           |  8 ++------
 package/transmission/S92transmission       |  3 ---
 package/triggerhappy/S10triggerhappy       |  6 +-----
 package/tvheadend/S99tvheadend             |  5 +----
 package/upmpdcli/S99upmpdcli               |  6 +-----
 26 files changed, 12 insertions(+), 86 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH 1/26 bind: don't test if the binary exists in the init script

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/bind/S81named | 1 -
 1 file changed, 1 deletion(-)
package/bind/S81named +0 -1
index bc4bb0f246..1da3008ae2 100644
@@ -3,7 +3,6 @@
 CONFIG=/etc/bind/named.conf
 DAEMON=/usr/sbin/named
 
-[ -x $DAEMON ] || exit 0
 [ -f $CONFIG ] || exit 0
 
 case "$1" in
Signature · 1 line
2.14.3
#2 lore raw

PATCH 2/26 dbus: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/dbus/S30dbus | 3 ---
 1 file changed, 3 deletions(-)
package/dbus/S30dbus +0 -3
index b4bcf9c7aa..52646cea2f 100644
@@ -10,9 +10,6 @@
 # pidfile: /var/run/messagebus.pid
 #
 
-# Sanity checks.
-[ -x /usr/bin/dbus-daemon ] || exit 0
-
 # Create needed directories.
 [ -d /var/run/dbus ] || mkdir -p /var/run/dbus
 [ -d /var/lock/subsys ] || mkdir -p /var/lock/subsys
Signature · 1 line
2.14.3
#3 lore raw

PATCH 3/26 dhcpcd: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/dhcpcd/S41dhcpcd | 1 -
 1 file changed, 1 deletion(-)
package/dhcpcd/S41dhcpcd +0 -1
index a2e87ca054..3e5c22f715 100755
@@ -7,7 +7,6 @@ DAEMON=/sbin/dhcpcd
 CONFIG=/etc/dhcpcd.conf
 PIDFILE=/var/run/dhcpcd.pid
 
-[ -x $DAEMON ] || exit 0
 [ -f $CONFIG ] || exit 0
 
 case "$1" in
Signature · 1 line
2.14.3
#4 lore raw

PATCH 4/26 dmraid: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/dmraid/S20dmraid | 2 --
 1 file changed, 2 deletions(-)
package/dmraid/S20dmraid +0 -2
index fd2ad9e845..b3bfdcc84b 100644
@@ -2,8 +2,6 @@
 
 set -e
 
-[ -x /usr/sbin/dmraid ] || exit 0
-
 # try to load module in case that hasn't been done yet
 modprobe dm-mod >/dev/null 2>&1
 
Signature · 1 line
2.14.3
#5 lore raw

PATCH 5/26 dnsmasq: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/dnsmasq/S80dnsmasq | 1 -
 1 file changed, 1 deletion(-)
package/dnsmasq/S80dnsmasq +0 -1
index d2f8b0f6b4..b052259e87 100755
@@ -1,6 +1,5 @@
 #!/bin/sh
 
-[ -x /usr/sbin/dnsmasq ] || exit 0
 [ -f /etc/dnsmasq.conf ] || exit 0
 
 case "$1" in
Signature · 1 line
2.14.3
#6 lore raw

PATCH 6/26 eudev: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits with error code 5 if the binary doesn't exist, which is silly. Buildroot installs both udevd and its init script as part of the same package. But if it ever happens for some reason, the error message "/sbin/udevd: No such file or directory" in the start case should be pretty clear.

Replace the UDEV_BIN variable, which was used only once, by the full path of the binary file.

---
 package/eudev/S10udev | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
package/eudev/S10udev +1 -5
index 47c715c886..4e799d6507 100755
@@ -16,10 +16,6 @@
 #	/dev/zero, /dev/null -- that's needed to boot and run this script.
 #
 
-# Check for missing binaries
-UDEV_BIN=/sbin/udevd
-test -x $UDEV_BIN || exit 5
-
 # Check for config file and read it
 UDEV_CONFIG=/etc/udev/udev.conf
 test -r $UDEV_CONFIG || exit 6
@@ -29,7 +25,7 @@ case "$1" in
     start)
         printf "Populating %s using udev: " "${udev_root:-/dev}"
         [ -e /proc/sys/kernel/hotplug ] && printf '\000\000\000\000' > /proc/sys/kernel/hotplug
-        $UDEV_BIN -d || { echo "FAIL"; exit 1; }
+        /sbin/udevd -d || { echo "FAIL"; exit 1; }
         udevadm trigger --type=subsystems --action=add
         udevadm trigger --type=devices --action=add
         udevadm settle --timeout=30 || echo "udevadm settle failed"
Signature · 1 line
2.14.3
#7 lore raw

PATCH 7/26 haveged: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/haveged/S21haveged | 2 --
 1 file changed, 2 deletions(-)
package/haveged/S21haveged +0 -2
index 3e6ce8678f..4b6e6ced4e 100755
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-[ -x /usr/sbin/haveged ] || exit 0
-
 case "$1" in
 	start)
 		printf "Starting haveged: "
Signature · 1 line
2.14.3
#8 lore raw

PATCH 8/26 modem-manager: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Drop the MODEMMANAGER_BIN variable, which was never initialized.

---
 package/modem-manager/S44modem-manager | 2 --
 1 file changed, 2 deletions(-)
package/modem-manager/S44modem-manager +0 -2
index cf6d89601d..a3f5003aa1 100755
@@ -5,8 +5,6 @@
 
 PIDFILE=/var/run/ModemManager.pid
 
-[ -x $MODEMMANAGER_BIN ] || exit 0
-
 start() {
 	printf "Starting ModemManager: "
 	umask 077
Signature · 1 line
2.14.3
#9 lore raw

PATCH 8/26 modem-manager: don't test if the binary exists in the init script

Quoted 7 lines

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Drop the MODEMMANAGER_BIN variable, which was never initialized.

---

...

package/modem-manager/S44modem-manager line 10

Quoted 10 lines

+++ b/package/modem-manager/S44modem-manager

package/modem-manager/S44modem-manager +0 -2
@@ -5,8 +5,6 @@
 
 PIDFILE=/var/run/ModemManager.pid
 
-[ -x $MODEMMANAGER_BIN ] || exit 0
-
 start() {
 	printf "Starting ModemManager: "
 	umask 077

Kind regards,
Petr

#10 lore raw

PATCH 9/26 mpd: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/mpd/S95mpd | 1 -
 1 file changed, 1 deletion(-)
package/mpd/S95mpd +0 -1
index 9f68b45837..a258930b3e 100644
@@ -1,7 +1,6 @@
 #!/bin/sh
 
 # Sanity checks
-test -f /usr/bin/mpd || exit 0
 test -f /etc/mpd.conf || exit 0
 
 start() {
Signature · 1 line
2.14.3
#11 lore raw

PATCH 10/26 neard: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Replace the DAEMON variable, which was used only once, by the full path of the binary file.

---
 package/neard/S53neard | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
package/neard/S53neard +1 -5
index f515668389..4fd4e0aad3 100755
@@ -4,15 +4,11 @@
 #
 
 NAME=neard
-DAEMON=/usr/libexec/nfc/$NAME
-
-# Exit gracefully if the package has been removed
-[ -x $DAEMON ] || exit 0
 
 case "$1" in
   start)
     printf "Starting $NAME: "
-    start-stop-daemon -S -q -p /var/run/${NAME}.pid -x $DAEMON -- -d '*'
+    start-stop-daemon -S -q -p /var/run/${NAME}.pid -x /usr/libexec/nfc/neard -- -d '*'
     echo "OK"
     ;;
   stop)
Signature · 1 line
2.14.3
#12 lore raw

PATCH 11/26 netplug: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/netplug/S29netplug | 2 --
 1 file changed, 2 deletions(-)
package/netplug/S29netplug +0 -2
index d3df9ddff5..03422499d6 100755
@@ -32,8 +32,6 @@ elif [ ! -f /etc/network/interfaces ]; then
 	exit 0
 fi
 
-[ -x /sbin/netplugd ] || exit 0
-
 if [ -f /etc/sysconfig/netplugd ]; then
     . /etc/sysconfig/netplugd
 fi
Signature · 1 line
2.14.3
#13 lore raw

PATCH 12/26 netsnmp: don't test if the binaries exist in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/netsnmp/S59snmpd | 3 ---
 1 file changed, 3 deletions(-)
package/netsnmp/S59snmpd +0 -3
index 4ff844ee3a..96ed8237ac 100755
@@ -14,9 +14,6 @@
 
 export PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
-test -x /usr/sbin/snmpd || exit 0
-test -x /usr/sbin/snmptrapd || exit 0
-
 # Defaults
 export MIBDIRS=/usr/share/snmp/mibs
 SNMPDRUN=yes
Signature · 1 line
2.14.3
#14 lore raw

PATCH 13/26 network-manager: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Replace the NETWORKMANAGER_BIN variable, which was used only once, by the full path of the binary file.

Drop the now useless variables prefix, exec_prefix and sbindir.

---
 package/network-manager/S45network-manager | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
package/network-manager/S45network-manager +1 -9
index bb4bf164a5..bc775d3b20 100755
@@ -3,21 +3,13 @@
 # Allow a few customizations from a config file
 test -r /etc/default/NetworkManager && . /etc/default/NetworkManager
 
-prefix=/usr
-exec_prefix=/usr
-sbindir=${exec_prefix}/sbin
-
-NETWORKMANAGER_BIN=${sbindir}/NetworkManager
-
-[ -x $NETWORKMANAGER_BIN ] || exit 0
-
 PID=`pidof NetworkManager`
 case "$1" in
 	start)
 		printf "Starting NetworkManager ... "
 		[ ! -d /var/run/NetworkManager ] && install -d /var/run/NetworkManager
 		if [ -z "$PID" ]; then
-			$NETWORKMANAGER_BIN $NETWORKMANAGER_ARGS
+			/usr/sbin/NetworkManager $NETWORKMANAGER_ARGS
 		fi
 		if [ ! -z "$PID" -o $? -gt 0 ]; then
 			echo "failed!"
Signature · 1 line
2.14.3
#15 lore raw

PATCH 14/26 nfs-utils: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/nfs-utils/S60nfs | 5 -----
 1 file changed, 5 deletions(-)
package/nfs-utils/S60nfs +0 -5
index 893b1e49a6..4183ff6268 100755
@@ -3,11 +3,6 @@
 # nfs           This shell script takes care of starting and stopping
 #               the NFS services. Stolen from RedHat FC5.
 
-[ -x /usr/sbin/rpc.statd ] || exit 0
-[ -x /usr/sbin/rpc.nfsd ] || exit 0
-[ -x /usr/sbin/rpc.mountd ] || exit 0
-[ -x /usr/sbin/exportfs ] || exit 0
-
 mkdir -p /var/lock/subsys
 mkdir -p /run/nfs/sm
 mkdir -p /run/nfs/sm.bak
Signature · 1 line
2.14.3
#16 lore raw

PATCH 15/26 ntp: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Replace the DAEMON variable, which was used only once, by the full path of the binary file.

---
 package/ntp/S49ntp | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
package/ntp/S49ntp +1 -5
index b4047fceda..35e58746b4 100755
@@ -1,10 +1,6 @@
 #! /bin/sh
 
 NAME=ntpd
-DAEMON=/usr/sbin/$NAME
-
-# Gracefully exit if the package has been removed.
-test -x $DAEMON || exit 0
 
 # Read config file if it is present.
 if [ -r /etc/default/$NAME ]
@@ -15,7 +11,7 @@ fi
 case "$1" in
   start)
     printf "Starting $NAME: "
-    start-stop-daemon -S -q -x $DAEMON -- -g
+    start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g
     [ $? = 0 ] && echo "OK" || echo "FAIL"
     ;;
   stop)
Signature · 1 line
2.14.3
#17 lore raw

PATCH 16/26 openntpd: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/openntpd/S49ntp | 1 -
 1 file changed, 1 deletion(-)
package/openntpd/S49ntp +0 -1
index c211ac835e..7ce46eba28 100755
@@ -1,6 +1,5 @@
 #!/bin/sh
 
-[ -x /usr/sbin/ntpd ] || exit 0
 [ -f /etc/ntpd.conf ] || exit 0
 
 case "$1" in
Signature · 1 line
2.14.3
#18 lore raw

PATCH 17/26 openvpn: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Replace the DAEMON variable, which was used only once, by the full path of the binary file.

---
 package/openvpn/S60openvpn | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
package/openvpn/S60openvpn +1 -5
index de82a5095e..bc1ab01c1a 100755
@@ -7,13 +7,11 @@
 
 test $DEBIAN_SCRIPT_DEBUG && set -v -x
 
-DAEMON=/usr/sbin/openvpn
 CONFIG_DIR=/etc/openvpn
-test -x $DAEMON || exit 0
 test -d $CONFIG_DIR || exit 0
 
 start_vpn () {
-    $DAEMON --daemon --writepid /var/run/openvpn.$NAME.pid \
+    /usr/sbin/openvpn --daemon --writepid /var/run/openvpn.$NAME.pid \
             --config $CONFIG_DIR/$NAME.conf --cd $CONFIG_DIR || printf " FAILED->"
     printf " $NAME"
 }
@@ -79,8 +77,6 @@ reload|force-reload)
       printf "(restarted)"
     else
       kill -HUP `cat $PIDFILE` || true
-#    start-stop-daemon --stop --signal HUP --quiet --oknodo \
-#      --exec $DAEMON --pidfile $PIDFILE
     printf " $NAME"
     fi
   done
Signature · 1 line
2.14.3
#19 lore raw

PATCH 18/26 proftpd: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Replace the DAEMON variable, which was used only once, by the full path of the binary file.

---
 package/proftpd/S50proftpd | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
package/proftpd/S50proftpd +1 -3
index 336680a456..3f9070f26a 100755
@@ -1,15 +1,13 @@
 #!/bin/sh
 
-DAEMON=/usr/sbin/proftpd
 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
 
 start() {
 	printf "Starting ProFTPD: "
-	$DAEMON
+	/usr/sbin/proftpd
 	if [ $? != 0 ]; then
 		echo "FAILED"
 		exit 1
Signature · 1 line
2.14.3
#20 lore raw

PATCH 19/26 prosody: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Replace the DAEMON variable, which was used only once, by the full path of the binary file.

---
 package/prosody/S50prosody | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
package/prosody/S50prosody +1 -5
index 84913a5f83..6fd33671fa 100644
@@ -1,7 +1,6 @@
 #! /bin/sh
 
 NAME=prosody
-DAEMON=/usr/bin/$NAME
 
 # This must match the pidfile field in
 # /etc/prosody/prosody.cfg.lua
@@ -9,15 +8,12 @@ DAEMON=/usr/bin/$NAME
 PIDDIR=/var/run/$NAME
 PIDFILE=$PIDDIR/$NAME.pid
 
-# Gracefully exit if the package has been removed.
-test -x $DAEMON || exit 0
-
 case "$1" in
   start)
     printf "Starting $NAME: "
     mkdir -p $PIDDIR
     chown $NAME:$NAME $PIDDIR
-    start-stop-daemon -S -q -o -x $DAEMON -c $NAME
+    start-stop-daemon -S -q -o -x /usr/bin/prosody -c $NAME
     [ $? = 0 ] && echo "OK" || echo "FAIL"
     ;;
   stop)
Signature · 1 line
2.14.3
#21 lore raw

PATCH 20/26 squid: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/squid/S97squid | 1 -
 1 file changed, 1 deletion(-)
package/squid/S97squid +0 -1
index 535b1d9622..05fb93e317 100755
@@ -1,6 +1,5 @@
 #!/bin/sh
 
-[ -x /usr/sbin/squid ] || exit 0
 [ -f /etc/squid.conf ] || exit 0
 
 case "$1" in
Signature · 1 line
2.14.3
#22 lore raw

PATCH 21/26 tinyhttpd: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/tinyhttpd/S85tinyhttpd | 1 -
 1 file changed, 1 deletion(-)
package/tinyhttpd/S85tinyhttpd +0 -1
index fb512a0375..f3f1de69bf 100755
@@ -3,7 +3,6 @@
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 NAME=tinyhttpd
 
-test -x /usr/sbin/$NAME || exit 0
 mkdir -p /var/www
 
 case "$1" in
Signature · 1 line
2.14.3
#23 lore raw

PATCH 22/26 tpm2-abrmd: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. Buildroot installs both abrmd and its init script as part of the same package. But if it ever happens for some reason, the error message from start-stop-daemon should be pretty clear.

---
 package/tpm2-abrmd/S80tpm2-abrmd | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
package/tpm2-abrmd/S80tpm2-abrmd +2 -6
index 3db5e6fa1d..d54c220c04 100755
@@ -3,14 +3,10 @@
 my_name="$0"
 
 check_required_files() {
-	[ -x "$1" ] || {
+	[ -f "$1" ] || {
 		echo "$my_name: $1 is missing"
 		exit 1
 	}
-	[ -z "$2" ] || [ -f "$2" ] || {
-		echo "$my_name: $2 is missing"
-		exit 1
-	}
 }
 
 check_device() {
@@ -50,7 +46,7 @@ stop() {
 	echo "OK"
 }
 
-check_required_files /usr/sbin/tpm2-abrmd /etc/dbus-1/system.d/tpm2-abrmd.conf
+check_required_files /etc/dbus-1/system.d/tpm2-abrmd.conf
 
 # defaults
 DAEMON_OPTS="--tcti=device --logger=syslog --max-connections=20 --max-transient-objects=20 --fail-on-loaded-trans"
Signature · 1 line
2.14.3
#24 lore raw

PATCH 23/26 transmission: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

---
 package/transmission/S92transmission | 3 ---
 1 file changed, 3 deletions(-)
package/transmission/S92transmission +0 -3
index e5976b0cfb..29d7cd5863 100644
@@ -51,9 +51,6 @@ DAEMON=$(which $NAME)
 PIDFILE=/var/run/$NAME.pid
 SCRIPTNAME=/etc/init.d/$NAME
 
-# Exit if the package is not installed
-[ -x "$DAEMON" ] || exit 0
-
 # Read configuration variable file if it is present
 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
Signature · 1 line
2.14.3
#25 lore raw

PATCH 24/26 triggerhappy: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Replace the DAEMON variable, which was used only once, by the full path of the binary file.

---
 package/triggerhappy/S10triggerhappy | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
package/triggerhappy/S10triggerhappy +1 -5
index 3253e910b1..4853873067 100755
@@ -1,18 +1,14 @@
 #!/bin/sh
 
 NAME=thd
-DAEMON=/usr/sbin/$NAME
 PIDFILE=/var/run/$NAME.pid
 DAEMON_ARGS="--daemon --triggers /etc/triggerhappy/triggers.d --socket /var/run/thd.socket --pidfile $PIDFILE --user nobody /dev/input/event*"
 
-# Sanity checks
-test -x $DAEMON || exit 0
-
 [ -r /etc/default/triggerhappy ] && . /etc/default/triggerhappy
 
 start() {
         printf "Starting $NAME: "
-        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS \
+        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec /usr/sbin/thd -- $DAEMON_ARGS \
                 && echo "OK" || echo "FAIL"
 }
 
Signature · 1 line
2.14.3
#26 lore raw

PATCH 25/26 tvheadend: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Replace the DAEMON variable, which was used only once, by the full path of the binary file.

---
 package/tvheadend/S99tvheadend | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
package/tvheadend/S99tvheadend +1 -4
index 65669ce404..fc125a2305 100644
@@ -5,11 +5,8 @@
 
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
 NAME=tvheadend
-DAEMON=/usr/bin/$NAME
 PIDFILE=/var/run/$NAME.pid
 
-[ -f "${DAEMON}" -a -x "${DAEMON}" ] || exit 0
-
 # Read configuration variable file if it is present
 [ -r "/etc/default/${NAME}" ] && . "/etc/default/${NAME}"
 
@@ -29,7 +26,7 @@ fi
 case "$1" in
     start)
         printf "Starting TVHeadend daemon: "
-        if start-stop-daemon -S -q -p ${PIDFILE} -m --exec "${DAEMON}" -- ${ARGS}; then
+        if start-stop-daemon -S -q -p ${PIDFILE} -m --exec /usr/bin/tvheadend -- ${ARGS}; then
             printf "OK\n"
         else
             printf "failed\n"
Signature · 1 line
2.14.3
#27 lore raw

PATCH 26/26 upmpdcli: don't test if the binary exists in the init script

In reply to Carlos Santos

The test doesn't make sense. It just exits without any error if the binary doesn't exist, which is silly.

Replace the DAEMON variable, which was used only once, by the full path of the binary file.

---
 package/upmpdcli/S99upmpdcli | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
package/upmpdcli/S99upmpdcli +1 -5
index 71d19a58e5..c1586eb05d 100644
@@ -1,17 +1,13 @@
 #!/bin/sh
 
 NAME=upmpdcli
-DAEMON=/usr/bin/$NAME
 CONFFILE=/etc/$NAME.conf
 PIDFILE=/var/run/$NAME.pid
 DAEMON_ARGS="-D -c $CONFFILE"
 
-# Sanity checks
-test -f $DAEMON || exit 0
-
 start() {
         printf "Starting $NAME: "
-        start-stop-daemon --start --quiet --background --exec $DAEMON \
+        start-stop-daemon --start --quiet --background --exec /usr/bin/upmpdcli \
                 -- $DAEMON_ARGS \
                 && echo "OK" || echo "FAIL"
 }
Signature · 1 line
2.14.3
#28 lore raw

cover init scripts: don't test if binaries exist

In reply to Carlos Santos

Hello,

Quoted 19 lines · Carlos Santos

Carlos Santos (26):
bind: don't test if the binary exists in the init script
dbus: don't test if the binary exists in the init script
dhcpcd: don't test if the binary exists in the init script
dmraid: don't test if the binary exists in the init script
dnsmasq: don't test if the binary exists in the init script
eudev: don't test if the binary exists in the init script
haveged: don't test if the binary exists in the init script
modem-manager: don't test if the binary exists in the init script
mpd: don't test if the binary exists in the init script
neard: don't test if the binary exists in the init script
netplug: don't test if the binary exists in the init script
netsnmp: don't test if the binaries exist in the init script
network-manager: don't test if the binary exists in the init script
nfs-utils: don't test if the binary exists in the init script
ntp: don't test if the binary exists in the init script
openntpd: don't test if the binary exists in the init script
openvpn: don't test if the binary exists in the init script
proftpd: don't test if the binary exists in the init script

Quoted 8 lines

prosody: don't test if the binary exists in the init script
squid: don't test if the binary exists in the init script
tinyhttpd: don't test if the binary exists in the init script
tpm2-abrmd: don't test if the binary exists in the init script
transmission: don't test if the binary exists in the init script
triggerhappy: don't test if the binary exists in the init script
tvheadend: don't test if the binary exists in the init script
upmpdcli: don't test if the binary exists in the init script

Thanks, series applied to master!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#29 lore raw

cover init scripts: don't test if binaries exist

In reply to Carlos Santos

Hi Carlos,

Quoted 5 lines

As discussed in the mailing list, it is useless to test if a binary file exists and/or is executable. Buildroot installs both the executable files and their init scripts as part of the same packages. But if it ever happens for some reason, the error message from start-stop-daemon or from the shell should be pretty clear.

This originated from Debian, where removing package keeps init files (among other files), that's why it's checked.
But for Buildroot it's really useless and confusing.

Quoted 3 lines

If a variable containing the file name existed (e.g. DAEMON) and was used only once it was replaced by the full path of the binary file. Unused variables resulting from these simplifications were removed too.

LGTM.

Kind regards,
Petr

Quoted 55 lines

Carlos Santos (26):
bind: don't test if the binary exists in the init script
dbus: don't test if the binary exists in the init script
dhcpcd: don't test if the binary exists in the init script
dmraid: don't test if the binary exists in the init script
dnsmasq: don't test if the binary exists in the init script
eudev: don't test if the binary exists in the init script
haveged: don't test if the binary exists in the init script
modem-manager: don't test if the binary exists in the init script
mpd: don't test if the binary exists in the init script
neard: don't test if the binary exists in the init script
netplug: don't test if the binary exists in the init script
netsnmp: don't test if the binaries exist in the init script
network-manager: don't test if the binary exists in the init script
nfs-utils: don't test if the binary exists in the init script
ntp: don't test if the binary exists in the init script
openntpd: don't test if the binary exists in the init script
openvpn: don't test if the binary exists in the init script
proftpd: don't test if the binary exists in the init script
prosody: don't test if the binary exists in the init script
squid: don't test if the binary exists in the init script
tinyhttpd: don't test if the binary exists in the init script
tpm2-abrmd: don't test if the binary exists in the init script
transmission: don't test if the binary exists in the init script
triggerhappy: don't test if the binary exists in the init script
tvheadend: don't test if the binary exists in the init script
upmpdcli: don't test if the binary exists in the init script

 package/bind/S81named                      |  1 -
 package/dbus/S30dbus                       |  3 ---
 package/dhcpcd/S41dhcpcd                   |  1 -
 package/dmraid/S20dmraid                   |  2 --
 package/dnsmasq/S80dnsmasq                 |  1 -
 package/eudev/S10udev                      |  6 +-----
 package/haveged/S21haveged                 |  2 --
 package/modem-manager/S44modem-manager     |  2 --
 package/mpd/S95mpd                         |  1 -
 package/neard/S53neard                     |  6 +-----
 package/netplug/S29netplug                 |  2 --
 package/netsnmp/S59snmpd                   |  3 ---
 package/network-manager/S45network-manager | 10 +---------
 package/nfs-utils/S60nfs                   |  5 -----
 package/ntp/S49ntp                         |  6 +-----
 package/openntpd/S49ntp                    |  1 -
 package/openvpn/S60openvpn                 |  6 +-----
 package/proftpd/S50proftpd                 |  4 +---
 package/prosody/S50prosody                 |  6 +-----
 package/squid/S97squid                     |  1 -
 package/tinyhttpd/S85tinyhttpd             |  1 -
 package/tpm2-abrmd/S80tpm2-abrmd           |  8 ++------
 package/transmission/S92transmission       |  3 ---
 package/triggerhappy/S10triggerhappy       |  6 +-----
 package/tvheadend/S99tvheadend             |  5 +----
 package/upmpdcli/S99upmpdcli               |  6 +-----
 26 files changed, 12 insertions(+), 86 deletions(-)