xref: /OK3568_Linux_fs/buildroot/package/radvd/S50radvd (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2
3DAEMON="radvd"
4PIDFILE="/var/run/$DAEMON.pid"
5
6RADVD_ARGS="-m syslog"
7
8# shellcheck source=/dev/null
9[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
10
11[ -f /etc/radvd.conf ] || exit 0
12
13[ -f /proc/sys/net/ipv6/conf/all/forwarding ] || {
14	echo "Error: radvd requires IPv6 forwarding support."
15	exit 1
16}
17
18start() {
19	printf 'Starting %s: ' "$DAEMON"
20	echo "1" > /proc/sys/net/ipv6/conf/all/forwarding
21	# shellcheck disable=SC2086 # we need the word splitting
22	start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
23		-- $RADVD_ARGS
24	status=$?
25	if [ "$status" -eq 0 ]; then
26		echo "OK"
27	else
28		echo "FAIL"
29	fi
30	return "$status"
31}
32
33stop() {
34	printf 'Stopping %s: ' "$DAEMON"
35	start-stop-daemon -K -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON"
36	status=$?
37	if [ "$status" -eq 0 ]; then
38		echo "OK"
39	else
40		echo "FAIL"
41	fi
42	return "$status"
43}
44
45restart() {
46	stop
47	sleep 1
48	start
49}
50
51case "$1" in
52	start|stop)
53		"$1";;
54	restart|reload)
55		restart;;
56	*)
57		echo "Usage: $0 {start|stop|restart|reload}"
58		exit 1
59esac
60