[packages] 6scripts: use network.sh to find device names
[packages.git] / ipv6 / 6scripts / files / 6tunnel.init
index 0e955ee..06ca29b 100644 (file)
@@ -1,16 +1,15 @@
 #!/bin/sh /etc/rc.common
+
 START=46
 STOP=46
 
 start_service() {
        local section="$1"
-       
-       include /lib/network
-       scan_interfaces
-       config_load /var/state/network
 
-       config_get LAN lan ifname
-        config_get tnlifname "$section" tnlifname
+       . /lib/functions/network.sh
+
+       network_get_device LAN lan || return 1
+       config_get tnlifname "$section" tnlifname
        config_get remoteip4 "$section" remoteip4
        config_get localip4 "$section" localip4
        config_get localip6 "$section" localip6
@@ -31,13 +30,11 @@ start_service() {
 
 stop_service() {
        local section="$1"
-       
-       include /lib/network
-       scan_interfaces
-       config_load /var/state/network
 
-       config_get LAN lan ifname
-        config_get tnlifname "$section" tnlifname
+       . /lib/functions/network.sh
+
+       network_get_device LAN lan || return 1
+       config_get tnlifname "$section" tnlifname
        config_get remoteip4 "$section" remoteip4
        config_get localip4 "$section" localip4
        config_get localip6 "$section" localip6
@@ -56,13 +53,13 @@ stop_service() {
 start() {
        if ! [ -x /usr/sbin/ip ]; then
                echo "ip is required to setup the tunnel";
-               exit 1;
+               exit 1
        fi
        config_load "6tunnel"
        config_foreach start_service 6tunnel
 }
 
-stop () {
+stop() {
        config_load "6tunnel"
        config_foreach stop_service 6tunnel
 }