diff --git a/.checkpackageignore b/.checkpackageignore index 9674128894..3e274f391f 100644 --- a/.checkpackageignore +++ b/.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 diff --git a/package/libiio/S99iiod b/package/libiio/S99iiod index df2f763461..b1d56a73fa 100644 --- a/package/libiio/S99iiod +++ b/package/libiio/S99iiod @@ -1,29 +1,55 @@ #!/bin/sh -# Server-side demuxing by default -IIOD_OPTS=-D +DAEMON="iiod" +PIDFILE="/var/run/$DAEMON.pid" -[ -r /etc/default/iiod ] && . /etc/default/iiod +# Server-side demuxing by default +IIOD_OPTS="-D" + +# 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 --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() { + 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() { + stop + start +} 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 $? - ;; - - stop) - echo "Stopping IIO Server Daemon" - start-stop-daemon -K -q -p /var/run/iiod.pid 2>/dev/null - exit $? - ;; - - restart) - $0 stop - sleep 1 - $0 start - ;; - + start|stop|restart) + "$1";; *) echo "Usage: $0 {start|stop|restart}" exit 1