Sfoglia il codice sorgente

package/libiio: refactor iiod init script

* Fix check-package issues and remove .checkpackageignore entry

* Remove fixed wait in "restart", wait for process termination in
  "stop" instead

* Print standard starting/stopping messages

Signed-off-by: Fiona Klute <fiona.klute@gmx.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Fiona Klute 2 settimane fa
parent
commit
6d2dbb4684
2 ha cambiato i file con 44 aggiunte e 19 eliminazioni
  1. 0 1
      .checkpackageignore
  2. 44 18
      package/libiio/S99iiod

+ 0 - 1
.checkpackageignore

@@ -551,7 +551,6 @@ package/libgpiod/0001-build-add-a-configure-switch-for-building-examples.patch l
 package/libgsm/0001-Misc-fixes-from-Archlinux.patch lib_patch.Upstream
 package/libgtk3/0001-Remove-Gdk-dependency-from-gtk-encode-symbolic-svg.patch lib_patch.Upstream
 package/libhdhomerun/0001-dont-strip.patch lib_patch.Upstream
-package/libiio/S99iiod Shellcheck lib_sysv.Variables
 package/libiqrf/0001-cmake-handle-static-library-and-find-required-thread.patch lib_patch.Upstream
 package/libiqrf/0002-use-only-c-language.patch lib_patch.Upstream
 package/libjson/0001-fix-broken-makefile.patch lib_patch.Upstream

+ 44 - 18
package/libiio/S99iiod

@@ -1,29 +1,55 @@
 #!/bin/sh
 
+DAEMON="iiod"
+PIDFILE="/var/run/$DAEMON.pid"
+
 # Server-side demuxing by default
-IIOD_OPTS=-D
+IIOD_OPTS="-D"
 
-[ -r /etc/default/iiod ] && . /etc/default/iiod
+# shellcheck source=/dev/null
+[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
 
-case "$1" in
-	start)
-		echo "Starting IIO Server Daemon"
-		start-stop-daemon -S -b -q -m -p /var/run/iiod.pid -x /usr/sbin/iiod -- $IIOD_OPTS
-		exit $?
-		;;
+start() {
+	printf 'Starting %s: ' "$DAEMON"
+	# shellcheck disable=SC2086 # we need the word splitting
+	start-stop-daemon --start --background --make-pidfile \
+		--pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" \
+		-- $IIOD_OPTS
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
 
-	stop)
-		echo "Stopping IIO Server Daemon"
-		start-stop-daemon -K -q -p /var/run/iiod.pid 2>/dev/null
-		exit $?
-		;;
+stop() {
+	printf 'Stopping %s: ' "$DAEMON"
+	start-stop-daemon --stop --pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+		return "$status"
+	fi
+	while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \
+		--exec "/usr/sbin/$DAEMON"; do
+		sleep 0.1
+	done
+	rm -f "$PIDFILE"
+	return "$status"
+}
 
-	restart)
-		$0 stop
-		sleep 1
-		$0 start
-		;;
+restart() {
+	stop
+	start
+}
 
+case "$1" in
+	start|stop|restart)
+		"$1";;
 	*)
 		echo "Usage: $0 {start|stop|restart}"
 		exit 1