You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.3 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=50
  3. USE_PROCD=1
  4. ARGS=""
  5. append_prefix_off_link() {
  6. ARGS="$ARGS -a $1"
  7. }
  8. append_prefix_on_link() {
  9. ARGS="$ARGS -p $1"
  10. }
  11. append_dns() {
  12. ARGS="$ARGS --rdnss $1"
  13. }
  14. start_instance() {
  15. local cfg="$1" enabled device ifname default_lifetime
  16. ARGS=""
  17. config_get_bool enabled $cfg 'enabled' 1
  18. config_get device $cfg 'device'
  19. config_get ifname $cfg 'ifname'
  20. config_get default_lifetime $cfg 'default_lifetime'
  21. if [ "$enabled" != "1" ]; then
  22. exit 0
  23. fi
  24. if [ -n "$device" ] && [ -n "$ifname" ]; then
  25. echo "either set device or ifname" >&2
  26. exit 1
  27. fi
  28. if [ -z "$device" ] && [ -z "$ifname" ]; then
  29. echo "either set device or ifname" >&2
  30. exit 1
  31. fi
  32. if [ -z "$ifname" ]; then
  33. network_get_device 'ifname' "$ifname"
  34. fi
  35. if [ -z "$ifname" ]; then
  36. echo "no valid device or ifname set" >&2
  37. exit 1
  38. fi
  39. if [ -n "$default_lifetime" ]; then
  40. ARGS="$ARGS --default-lifetime $default_lifetime"
  41. fi
  42. ARGS="$ARGS -i $ifname"
  43. config_list_foreach $cfg 'prefix_off_link' append_prefix_off_link
  44. config_list_foreach $cfg 'prefix_on_link' append_prefix_on_link
  45. config_list_foreach $cfg "dns" append_dns
  46. procd_open_instance
  47. procd_set_param command /usr/sbin/uradvd $ARGS
  48. procd_set_param respawn
  49. procd_close_instance
  50. }
  51. start_service() {
  52. config_load uradvd
  53. config_foreach start_instance interface
  54. }