mirror of
https://gitee.com/open-loongarch/buildroot-2024.08.git
synced 2026-10-29 06:27:14 +08:00
first commit: base 2024.08
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#!/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() {
|
||||
# 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() {
|
||||
# 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
|
||||
Reference in New Issue
Block a user