packages/net/olsrd: nuke now obsolete patches
[openwrt/svn-archive/archive.git] / ipv6 / gw6c / files / gw6c.init
1 #!/bin/sh /etc/rc.common
2 #Copyright (C) 2007 RoadRunner.cx
3 START=52
4
5 genconf() {
6
7 [ -f /etc/config/gw6c ] || {
8 echo "You are missing configuration file /etc/config/gw6c"
9 return 0
10 }
11
12 config_load "gw6c"
13
14 config_get DISABLED basic disabled
15
16 [ "$DISABLED" == "1" ] && {
17 echo "You haven't edited your configuration file. Gateway6 is disabled."
18 return 0
19 }
20
21 config_get USERID basic userid
22 config_get PASSWORD basic passwd
23 config_get SERVER basic server
24 config_get AUTH_METHOD basic auth_method
25
26 config_get HOST_TYPE routing host_type
27 config_get PREFIX_LEN routing prefixlen
28 config_get IF_PREFIX routing ifprefix
29 config_get DNS_SERVER routing dns_server
30
31 config_get GW6C_CONF advanced gw6c_conf
32 config_get GW6C_DIR advanced gw6c_dir
33 config_get AUTO_RETRY advanced auto_retry
34 config_get RETRY_DELAY advanced retry_delay
35 config_get KEEPALIVE advanced keepalive
36 config_get KEEPALIVE_INTERVAL advanced interval
37 config_get TUNNEL_MODE advanced if_tunnel_mode
38 config_get IF_V6V4 advanced if_v6v4
39 config_get IF_V6UDPV4 advanced if_v6udpv4
40 config_get IF_V4V6 advanced if_v4v6
41 config_get CLIENT_V4 advanced client_v4
42 config_get CLIENT_V6 advanced client_v6
43 config_get TEMPLATE advanced template
44 config_get PROXY_CLIENT advanced proxy_client
45
46 config_get BROKER_LIST broker broker_list
47 config_get LAST_SERVER broker last_server
48 config_get ALWAYS_SAMESERV broker always_same_serv
49
50 config_get LOG_CONSOLE logging log_console
51 config_get LOG_STDERR logging log_stderr
52 config_get LOG_FILE logging log_file
53 config_get LOG_SYSLOG logging log_syslog
54 config_get LOG_FILENAME logging log_filename
55 config_get LOG_ROTATE logging log_rotation
56 config_get LOG_MAXSIZE logging log_maxsize
57 config_get SYSLOG_FACILITY logging syslog_facility
58
59 cat >$GW6C_CONF <<EOF
60 userid=$USERID
61 passwd=$PASSWORD
62 server=$SERVER
63 auth_method=$AUTH_METHOD
64 host_type=$HOST_TYPE
65 prefixlen=$PREFIX_LEN
66 if_prefix=$IF_PREFIX
67 dns_server=$DNS_SERVER
68 gw6_dir=$GW6C_DIR
69 auto_retry_connect=$AUTO_RETRY
70 retry_delay=$RETRY_DELAY
71 keepalive=$KEEPALIVE
72 keepalive_interval=$KEEPALIVE_INTERVAL
73 tunnel_mode=$TUNNEL_MODE
74 if_tunnel_v6v4=$IF_V6V4
75 if_tunnel_v6udpv4=$IF_V6UDPV4
76 if_tunnel_v4v6=$IF_V4V6
77 client_v4=$CLIENT_V4
78 client_v6=$CLIENT_V6
79 template=$TEMPLATE
80 proxy_client=$PROXY_CLIENT
81 broker_list=$BROKER_LIST
82 last_server=$LAST_SERVER
83 always_use_same_server=$ALWAYS_SAMESERV
84 log_console=$LOG_CONSOLE
85 log_stderr=$LOG_STDERR
86 log_file=$LOG_FILE
87 log_syslog=$LOG_SYSLOG
88 log_filename=$LOG_FILENAME
89 log_rotation=$LOG_ROTATE
90 log_rotation_size=$LOG_MAXSIZE
91 syslog_facility=$SYSLOG_FACILITY
92 EOF
93 }
94
95 start() {
96 genconf
97 if [ -z "$GW6C_CONF" ] || [ ! -f "$GW6C_CONF" ]; then
98 echo "Gateway6 client cannot start."
99 else
100 echo "Starting Gateway6 client."
101 /usr/sbin/gw6c -f "$GW6C_CONF"
102 fi
103 }
104
105 stop() {
106 [ `ps ax|grep -v grep|grep -c gw6c` != "0" ] && {
107 killall -q gw6c
108 [ `ps ax|grep -v grep|grep -c radvd` != "0" ] && killall -q radvd
109 echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
110 }
111 }