radvd-2.15.init 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2016 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. CONFIGFILE=/etc/radvd.conf
  5. PIDFILE=/run/radvd/radvd.pid
  6. SYSCTL_FORWARD=net.ipv6.conf.all.forwarding
  7. extra_started_commands="reload"
  8. depend() {
  9. need net
  10. }
  11. checkconfig() {
  12. if [ ! -f "${CONFIGFILE}" ]; then
  13. eerror "Configuration file ${CONFIGFILE} not found"
  14. return 1
  15. fi
  16. if ! /usr/sbin/radvd -c -C "${CONFIGFILE}" ; then
  17. eerror "Configuration file ${CONFIGFILE} failed test"
  18. return 1
  19. fi
  20. checkpath -d -o radvd:radvd ${PIDFILE%/*}
  21. }
  22. start() {
  23. if [ "${FORWARD}" != "no" ]; then
  24. ebegin "Enabling IPv6 forwarding"
  25. sysctl -w "${SYSCTL_FORWARD}=1" >/dev/null
  26. eend $?
  27. fi
  28. checkconfig || return 1
  29. ebegin "Starting IPv6 Router Advertisement Daemon"
  30. start-stop-daemon --start --exec /usr/sbin/radvd \
  31. --pidfile "${PIDFILE}" \
  32. -- -C "${CONFIGFILE}" -p "${PIDFILE}" -u radvd ${OPTIONS}
  33. eend $?
  34. }
  35. stop() {
  36. ebegin "Stopping IPv6 Router Advertisement Daemon"
  37. start-stop-daemon --stop --exec /usr/sbin/radvd --pidfile "${PIDFILE}"
  38. eend $?
  39. if [ "${FORWARD}" != "no" ]; then
  40. ebegin "Disabling IPv6 forwarding"
  41. sysctl -w "${SYSCTL_FORWARD}=0" > /dev/null
  42. eend $?
  43. fi
  44. }
  45. reload() {
  46. if [ "${FORWARD}" != "no" ]; then
  47. ebegin "Enabling IPv6 forwarding"
  48. sysctl -w "${SYSCTL_FORWARD}=1" >/dev/null
  49. eend $?
  50. fi
  51. checkconfig || return 1
  52. ebegin "Reloading IPv6 Router Advertisement Daemon"
  53. start-stop-daemon --signal HUP \
  54. --exec /usr/sbin/radvd --pidfile "${PIDFILE}"
  55. eend $?
  56. }