ipv6-up.sample 815 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. #
  3. # This script is called with the following parameters:
  4. # interface tty speed local-address remote-address ipparam
  5. #
  6. # Start router advertisements on this link.
  7. # Based on radvd 0.5.0 behaviour
  8. DEVICE="$1"
  9. CFGFILE="/etc/radvd.conf-$DEVICE"
  10. PIDFILE="/var/run/radvd-$DEVICE.pid"
  11. EXEFILE="/usr/sbin/radvd"
  12. if [ -x "$EXEFILE" -a -f "$CFGFILE" ]; then
  13. touch "$PIDFILE"
  14. if [ ! -f "$PIDFILE" ]; then
  15. echo "error: $PIDFILE is not a regular file. Aborting"
  16. exit 0
  17. fi
  18. PID="$(cat "$PIDFILE")"
  19. if [ -n "$PID" ]; then
  20. ps h "$PID" >/dev/null 2>&1 && exit 0
  21. fi
  22. # radvd 0.5.0 doesn't write a pid-file so we do it here
  23. # enabling debugging keeps radvd in foreground, putting it
  24. # on background gives us the PID.
  25. "$EXEFILE" -d 1 -C "$CFGFILE" &
  26. echo $! >"$PIDFILE"
  27. fi