Files
buildroot/package/linux-tools/S10hyperv
Benjamin DeCamp 4f1d3b786d package/linux-tools/S10hyperv: fix invalid return value
In both start() and stop(), ret is only assigned on failure. When
hypervkvpd starts or stops successfully, return "$ret" expands to an
empty string and causes:

  /etc/init.d/S10hyperv: return: line 31: Illegal number:

Those double quotes were added in Buildroot commit [1], to fix a
new ShellCheck warning at that time. This was not a complete fix.

Only removing the double quote would reintroduce the ShellCheck
warning. This would also reintroduce a check-package error.

Since a bare return is equivalent to a "return 0", this commit
also initializes with ret=0. Doing so will tell ShellCheck "ret" is
an integer. Therefore, the ShellCheck warning will no longer be
reported.

This commit fixes the invalid return value by removing the double
quotes and initialzing "ret=0".

[1] c4173d8b08

Signed-off-by: Benjamin DeCamp <benjamin8532@protonmail.com>
[Julien:
 - add "ret=0" initialization in script to fix check-package error
 - add extra info in the commit log
]
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit 667335cd18)
Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
2026-08-28 15:57:20 +02:00

73 lines
1.2 KiB
Bash

#!/bin/sh
PROGS="@PROGS@"
PIDDIR="/var/run"
DAEMON="hyperv"
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
# only continue if we are in a HyperV platform
[ -e "/sys/bus/vmbus" ] || exit 0
start_one() {
printf 'Starting %s: ' "$1"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -b -m -S -q -p "$PIDDIR/$1.pid" -x "/usr/sbin/$1" -- -n
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return $status
}
start() {
ret=0
# shellcheck disable=SC2086 # we need the word splitting
for prog in ${PROGS}; do
start_one "${prog}" || ret=$?
done
return $ret
}
stop_one() {
printf 'Stopping %s: ' "$1"
start-stop-daemon -K -q -p "$PIDDIR/$1.pid"
status=$?
if [ "$status" -eq 0 ]; then
rm -f "$PIDDIR/$1.pid"
echo "OK"
else
echo "FAIL"
fi
return $status
}
stop() {
ret=0
# shellcheck disable=SC2086 # we need the word splitting
for prog in ${PROGS}; do
stop_one "${prog}" || ret=$?
done
return $ret
}
restart() {
stop
sleep 1
start
}
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