ensure it's started before ratvd
[openwrt/svn-archive/archive.git] / ipv6 / aiccu / files / aiccu.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3 START=51
4
5 config_cb() {
6 local cfg_type="$1"
7 local cfg_name="$2"
8
9 case "$cfg_type" in
10 aiccu)
11 append cfgs_sections "$cfg_name" "$N"
12 ;;
13 esac
14 }
15
16 start() {
17 config_load aiccu
18 for cfgs_section in $cfgs_sections; do
19 config_get username $cfgs_section username
20 config_get password $cfgs_section password
21 config_get server $cfgs_section server
22 config_get protocol $cfgs_section protocol
23 config_get interface $cfgs_section interface
24 config_get tunnel_id $cfgs_section tunnel_id
25 config_get_bool requiretls $cfgs_section requiretls 0
26 config_get_bool defaultroute $cfgs_section defaultroute 1
27 config_get_bool nat $cfgs_section nat 1
28 config_get_bool heartbeat $cfgs_section heartbeat 1
29 mkdir -p /tmp/run
30 echo "username $username" > /tmp/run/aiccu-${cfgs_section}.conf
31 echo "password $password" >> /tmp/run/aiccu-${cfgs_section}.conf
32 [ -n "$server" ] && echo "server $server" >> /tmp/run/aiccu-${cfgs_section}.conf
33 [ -n "$protocol" ] && echo "protocol $protocol" >> /tmp/run/aiccu-${cfgs_section}.conf
34 [ -n "$interface" ] && echo "ipv6_interface $interface" >> /tmp/run/aiccu-${cfgs_section}.conf
35 [ -n "$tunnel_id" ] && echo "tunnel_id $tunnel_id" >> /tmp/run/aiccu-${cfgs_section}.conf
36 [ "$requiretls" = "1" ] && echo "requiretls true" >> /tmp/run/aiccu-${cfgs_section}.conf
37 [ "$defaultroute" != "1" ] && echo "defaultroute false >> /tmp/run/aiccu-${cfgs_section}.conf
38 [ "$nat" = "1" ] && echo "behindnat true >> /tmp/run/aiccu-${cfgs_section}.conf
39 [ "$heartbeat" != "1" ] && echo "makebeats false" >> /tmp/run/aiccu-${cfgs_section}.conf
40 echo 'daemonize true' >> /tmp/run/aiccu-${cfgs_section}.conf
41 echo "pidfile /var/run/aiccu-${cfgs_section}.pid" >> /tmp/run/aiccu-${cfgs_section}.conf
42
43 aiccu start /tmp/run/aiccu-$cfgs_section.conf
44 done
45 }
46
47 stop() {
48 config_load aiccu
49 for cfgs_section in $cfgs_sections; do
50 aiccu stop /tmp/run/aiccu-$cfgs_section.conf
51 done
52 }