|
@@ -0,0 +1,105 @@
|
|
1
|
+#!/bin/sh
|
|
2
|
+# aiccu.sh - AICCU proto
|
|
3
|
+# Copyright (c) 2014 OpenWrt.org
|
|
4
|
+
|
|
5
|
+[ -n "$INCLUDE_ONLY" ] || {
|
|
6
|
+ . /lib/functions.sh
|
|
7
|
+ . /lib/functions/network.sh
|
|
8
|
+ . ../netifd-proto.sh
|
|
9
|
+ init_proto "$@"
|
|
10
|
+}
|
|
11
|
+
|
|
12
|
+proto_aiccu_setup() {
|
|
13
|
+ local cfg="$1"
|
|
14
|
+ local iface="$2"
|
|
15
|
+ local link="aiccu-$cfg"
|
|
16
|
+
|
|
17
|
+ local username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr
|
|
18
|
+ json_get_vars username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr
|
|
19
|
+
|
|
20
|
+ [ -z "$username" -o -z "$password" ] && {
|
|
21
|
+ proto_notify_error "$cfg" "MISSING_USERNAME_OR_PASSWORD"
|
|
22
|
+ proto_block_restart "$cfg"
|
|
23
|
+ return
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ ( proto_add_host_dependency "$cfg" 0.0.0.0 )
|
|
27
|
+
|
|
28
|
+ CFGFILE="/var/etc/${link}.conf"
|
|
29
|
+ PIDFILE="/var/run/${link}.pid"
|
|
30
|
+ mkdir -p /var/run /var/etc
|
|
31
|
+
|
|
32
|
+ echo "username $username" > "$CFGFILE"
|
|
33
|
+ echo "password $password" >> "$CFGFILE"
|
|
34
|
+ echo "ipv6_interface $link" >> "$CFGFILE"
|
|
35
|
+ [ -n "$server" ] && echo "server $server" >> "$CFGFILE"
|
|
36
|
+ [ -n "$protocol" ] && echo "protocol $protocol" >> "$CFGFILE"
|
|
37
|
+ [ -n "$tunnel_id" ] && echo "tunnel_id $tunnel_id" >> "$CFGFILE"
|
|
38
|
+ [ -n "$requiretls" ] && echo "requiretls $requiretls" >> "$CFGFILE"
|
|
39
|
+ [ "$nat" == 1 ] && echo "behindnat true" >> "$CFGFILE"
|
|
40
|
+ [ "$heartbeat" == 1 ] && echo "makebeats true" >> "$CFGFILE"
|
|
41
|
+ [ "$verbose" == 1 ] && echo "verbose true" >> "$CFGFILE"
|
|
42
|
+ echo "defaultroute false" >> "$CFGFILE"
|
|
43
|
+ echo "daemonize true" >> "$CFGFILE"
|
|
44
|
+ echo "pidfile $PIDFILE" >> "$CFGFILE"
|
|
45
|
+
|
|
46
|
+ aiccu start "$CFGFILE"
|
|
47
|
+
|
|
48
|
+ [ "$?" -ne 0 ] && {
|
|
49
|
+ proto_notify_error "$cfg" "AICCU_FAILED_SEE_LOG"
|
|
50
|
+ proto_block_restart "$cfg"
|
|
51
|
+ return
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ proto_init_update "$link" 1
|
|
55
|
+
|
|
56
|
+ local source=""
|
|
57
|
+ [ "$sourcerouting" != "0" ] && source="::/128"
|
|
58
|
+ [ "$defaultroute" != "0" ] && proto_add_ipv6_route "::" 0 "" "" "" "$source"
|
|
59
|
+
|
|
60
|
+ [ -n "$ip6addr" ] && {
|
|
61
|
+ local local6="${ip6addr%%/*}"
|
|
62
|
+ local mask6="${ip6addr##*/}"
|
|
63
|
+ [[ "$local6" = "$mask6" ]] && mask6=
|
|
64
|
+ proto_add_ipv6_address "$local6" "$mask6"
|
|
65
|
+ [ "$defaultroute" != "0" -a "$sourcerouting" != "0" ] && proto_add_ipv6_route "::" 0 "" "" "" "$local6/$mask6"
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ [ -n "$ip6prefix" ] && {
|
|
69
|
+ proto_add_ipv6_prefix "$ip6prefix"
|
|
70
|
+ [ "$defaultroute" != "0" -a "$sourcerouting" != "0" ] && proto_add_ipv6_route "::" 0 "" "" "" "$ip6prefix"
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ proto_send_update "$cfg"
|
|
74
|
+
|
|
75
|
+}
|
|
76
|
+
|
|
77
|
+proto_aiccu_teardown() {
|
|
78
|
+ local cfg="$1"
|
|
79
|
+ local link="aiccu-$cfg"
|
|
80
|
+ CFGFILE="/var/etc/${link}.conf"
|
|
81
|
+
|
|
82
|
+ aiccu stop "$CFGFILE"
|
|
83
|
+}
|
|
84
|
+
|
|
85
|
+proto_aiccu_init_config() {
|
|
86
|
+ no_device=1
|
|
87
|
+ available=1
|
|
88
|
+ proto_config_add_string "username"
|
|
89
|
+ proto_config_add_string "password"
|
|
90
|
+ proto_config_add_string "protocol"
|
|
91
|
+ proto_config_add_string "server"
|
|
92
|
+ proto_config_add_string "ip6addr:ip6addr"
|
|
93
|
+ proto_config_add_string "ip6prefix:ip6addr"
|
|
94
|
+ proto_config_add_string "tunnelid"
|
|
95
|
+ proto_config_add_boolean "requiretls"
|
|
96
|
+ proto_config_add_boolean "defaultroute"
|
|
97
|
+ proto_config_add_boolean "sourcerouting"
|
|
98
|
+ proto_config_add_boolean "nat"
|
|
99
|
+ proto_config_add_boolean "heartbeat"
|
|
100
|
+ proto_config_add_boolean "verbose"
|
|
101
|
+}
|
|
102
|
+
|
|
103
|
+[ -n "$INCLUDE_ONLY" ] || {
|
|
104
|
+ add_protocol aiccu
|
|
105
|
+}
|