xref: /OK3568_Linux_fs/buildroot/package/linux-tools/S10hyperv (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2
3PROGS="@PROGS@"
4PIDDIR="/var/run"
5
6# shellcheck source=/dev/null
7[ -r "/etc/default/hyperv" ] && . "/etc/default/hyperv"
8
9start_one() {
10	printf 'Starting %s: ' "$1"
11	# shellcheck disable=SC2086 # we need the word splitting
12	start-stop-daemon -b -m -S -q -p "$PIDDIR/$1.pid" -x "/sbin/$1" -- -n
13	status=$?
14	if [ "$status" -eq 0 ]; then
15		echo "OK"
16	else
17		echo "FAIL"
18	fi
19	return $status
20}
21
22start() {
23	# shellcheck disable=SC2086 # we need the word splitting
24	for prog in ${PROGS}; do
25		start_one "${prog}" || ret=$?
26	done
27	return "$ret"
28}
29
30stop_one() {
31	printf 'Stopping %s: ' "$1"
32	start-stop-daemon -K -q -p "$PIDDIR/$1.pid"
33	status=$?
34	if [ "$status" -eq 0 ]; then
35		rm -f "$PIDDIR/$1.pid"
36		echo "OK"
37	else
38		echo "FAIL"
39	fi
40	return $status
41}
42
43stop() {
44	# shellcheck disable=SC2086 # we need the word splitting
45	for prog in ${PROGS}; do
46		stop_one "${prog}" || ret=$?
47	done
48	return "$ret"
49}
50
51restart() {
52	stop
53	sleep 1
54	start
55}
56
57case "$1" in
58	start|stop|restart)
59		"$1";;
60	reload)
61		# Restart, since there is no true "reload" feature.
62		restart;;
63	*)
64		echo "Usage: $0 {start|stop|restart|reload}"
65		exit 1
66esac
67