1 #!/bin/sh /etc/rc.common
2 # Copyright (c) 2011-2012 OpenWrt.org
6 grep -qs "^ *$1:" /proc/net/dev && {
14 config_get ifn "$1" ifname
15 [ -z "$ifn" ] && return 1
27 SERVICE_PID_FILE="/var/run/6relayd-$cfg.pid"
28 [ -f "$SERVICE_PID_FILE" ] && {
29 if grep -q 6relayd "/proc/$(cat $SERVICE_PID_FILE)/cmdline"; then
32 rm -f "$SERVICE_PID_FILE"
37 config_get networks "$cfg" network
38 for net in $networks; do
39 resolve_network "$net" || {
45 config_get ifnames "$cfg" ifname
46 for ifn in $ifnames; do
51 config_get rd "$cfg" rd
52 [ -n "$rd" ] && append args "-R$rd"
55 config_get dhcpv6 "$cfg" dhcpv6
56 [ -n "$dhcpv6" ] && append args "-D$dhcpv6"
59 config_get ndp "$cfg" ndp
60 [ "$ndp" == "relay" ] && append args "-N -r"
62 local always_rewrite_dns
63 config_get_bool always_rewrite_dns "$cfg" always_rewrite_dns 0
64 [ $always_rewrite_dns -eq 1 ] && append args "-n"
66 # In server mode the first interface needs to be passed twice
67 [ "$mode" == "server" ] && {
68 for iface in $ifaces; do
69 ifaces="$iface $ifaces"
74 service_start /usr/sbin/6relayd $args $ifaces
78 for pid in /var/run/6relayd-*.pid; do
79 SERVICE_PID_FILE="$pid"
80 service_stop /usr/sbin/6relayd
81 rm -f "$SERVICE_PID_FILE"
88 config_foreach start_6relayd relay relay
89 config_foreach start_6relayd server server