summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-daemons/radvd/files/radvd.init
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2012-11-27 11:25:49 +0000
committerJoe MacDonald <joe.macdonald@windriver.com>2012-11-27 14:43:58 -0500
commit85c1a1a45409ffa064b5da8c8b00e7a5f7d67b83 (patch)
tree41122208e17e86c6364e7c776d1b8296e5f3588f /meta-networking/recipes-daemons/radvd/files/radvd.init
parente762ce3fc044cc64f473c95e096245e439eb3234 (diff)
downloadmeta-openembedded-85c1a1a45409ffa064b5da8c8b00e7a5f7d67b83.tar.gz
radvd: add from OE-Classic, update and tidy up
* Update to 1.9.1 * Add libdaemon to DEPENDS as needed by 1.9+ * Remove empty config file (not really of much use and there's an example config in the -doc package anyway) * Use useradd.bbclass to create user * Handle hardcoded paths in initscript * Add LSB headers to initscript (borrowed from openSUSE) * Set custom LICENSE as it's BSD-Style but not actually one of the standard BSD variants * Add LIC_FILES_CHKSUM * Set SUMMARY (which sets DESCRIPTION) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'meta-networking/recipes-daemons/radvd/files/radvd.init')
-rwxr-xr-xmeta-networking/recipes-daemons/radvd/files/radvd.init124
1 files changed, 124 insertions, 0 deletions
diff --git a/meta-networking/recipes-daemons/radvd/files/radvd.init b/meta-networking/recipes-daemons/radvd/files/radvd.init
new file mode 100755
index 000000000..a48dff8c8
--- /dev/null
+++ b/meta-networking/recipes-daemons/radvd/files/radvd.init
@@ -0,0 +1,124 @@
1#! /bin/sh
2#
3### BEGIN INIT INFO
4# Provides: radvd
5# Required-Start: $remote_fs $named $syslog
6# Required-Stop: $remote_fs $named $syslog
7# Default-Start: 3 5
8# Default-Stop: 0 1 2 6
9# Description: router advertisement daemon
10### END INIT INFO
11
12PATH=/sbin:/bin:/usr/sbin:/usr/bin
13DAEMON=/usr/sbin/radvd
14NAME=radvd
15DESC=radvd
16CONFIG=/etc/radvd.conf
17SAVED_SETTINGS=/var/run/radvd/saved-settings
18PIDFILE=/var/run/radvd/radvd.pid
19OPTIONS="-u radvd -p $PIDFILE"
20
21test -x $DAEMON || exit 0
22
23set -e
24
25# Check for IPv6 support in kernel
26if test \! -e /proc/sys/net/ipv6; then
27 echo "IPv6 support must be enabled in the kernel for $DESC to work."
28 exit
29fi
30
31save_settings()
32{
33 local file=$1
34
35 rm -f $file
36 for if_conf in /proc/sys/net/ipv6/conf/*; do
37 echo -e "$if_conf/forwarding\t `cat $if_conf/forwarding`" >> $file
38 done
39 return 0
40}
41
42restore_settings()
43{
44 file=$1
45
46 if [ ! -f $file ]; then
47 echo "$0: warning: cannot restore settings"
48 return
49 fi
50
51 (
52 while read f value; do
53 if [ -w $f ]; then
54 echo $value > $f
55 fi
56 done
57 ) < $file
58}
59
60chkconfig() {
61 if [ ! -e $CONFIG -o ! -s $CONFIG ]; then
62 echo ""
63 echo "* $CONFIG does not exist or is empty."
64 echo "* See /usr/share/doc/radvd/examples/simple-radvd.conf for a simple"
65 echo "* configuration suitable for most systems, and radvd.conf(5)"
66 echo "* for configuration file syntax. radvd will *not* be started."
67 exit 0
68 fi
69}
70
71case "$1" in
72 start)
73 echo -n "Starting $DESC: "
74 chkconfig
75 save_settings $SAVED_SETTINGS
76
77 # We must enable IPv6 forwarding for radvd to work
78 echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
79
80 # Check for stale pidfile; radvd won't start if one is lying around
81 if [ -f $PIDFILE ] && ! ps `cat $PIDFILE` > /dev/null; then
82 rm -f $PIDFILE
83 fi
84 if ! start-stop-daemon --oknodo --start --pidfile $PIDFILE \
85 --exec $DAEMON -- $OPTIONS; then
86 echo "failed." && exit 1
87 fi
88 echo "$NAME."
89 ;;
90 stop)
91 echo -n "Stopping $DESC: "
92 start-stop-daemon --oknodo --stop --pidfile $PIDFILE \
93 --exec $DAEMON
94 restore_settings $SAVED_SETTINGS
95 rm -f $SAVED_SETTINGS
96 echo "$NAME."
97 ;;
98 reload|force-reload)
99 echo "Reloading $DESC configuration files."
100 start-stop-daemon --stop --signal HUP --quiet --pidfile \
101 $PIDFILE --exec $DAEMON
102 ;;
103 restart)
104 chkconfig
105 echo -n "Restarting $DESC: "
106 if ! start-stop-daemon --stop --quiet --pidfile \
107 $PIDFILE --exec $DAEMON; then
108 # stop failed, so we were not running
109 save_settings $SAVED_SETTINGS
110 echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
111 fi
112 sleep 1
113 start-stop-daemon --start --quiet --pidfile \
114 $PIDFILE --exec $DAEMON -- $OPTIONS
115 echo "$NAME."
116 ;;
117 *)
118 N=/etc/init.d/$NAME
119 echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
120 exit 1
121 ;;
122esac
123
124exit 0