]>
Commit | Line | Data |
---|---|---|
671fa0bd MT |
1 | #!/bin/bash |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2010 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | function aiccu_init() { | |
23 | log INFO "Initializing aiccu." | |
24 | mkdir -p $(aiccu_config_dir) | |
25 | } | |
26 | ||
27 | init_register aiccu_init | |
28 | ||
29 | function aiccu_config_dir() { | |
30 | local device=${1} | |
31 | ||
32 | echo "${RUN_DIR}/aiccu/${device}" | |
33 | } | |
34 | ||
35 | function aiccu_start() { | |
36 | local device=${1} | |
37 | shift | |
38 | ||
39 | assert isset device | |
40 | ||
41 | local config_dir=$(aiccu_config_dir ${device}) | |
42 | mkdir -p ${config_dir} | |
43 | ||
44 | local config_file=${config_dir}/config | |
45 | aiccu_configure ${device} $@ > ${config_file} | |
46 | ||
47 | aiccu start ${config_file} &>/dev/null | |
48 | local ret=$? | |
49 | ||
50 | case "${ret}" in | |
51 | 0) | |
52 | log DEBUG "Aiccu was successfully started for '${device}'." | |
53 | return ${EXIT_OK} | |
54 | ;; | |
55 | *) | |
56 | error_log "Could not start aiccu properly for '${device}'." | |
57 | ||
58 | error_log "Configuration file dump:" | |
59 | local line | |
60 | while read line; do | |
61 | error_log " ${line}" | |
62 | done < ${config_file} | |
63 | ||
64 | return ${EXIT_ERROR} | |
65 | ;; | |
66 | esac | |
67 | } | |
68 | ||
69 | function aiccu_stop() { | |
70 | local device=${1} | |
71 | ||
72 | assert isset device | |
73 | ||
74 | aiccu stop $(aiccu_config_dir ${device})/config | |
75 | ||
76 | rm -rf $(aiccu_config_dir ${device}) | |
77 | } | |
78 | ||
79 | function aiccu_configure() { | |
80 | local device=${1} | |
81 | ||
82 | assert isset device | |
83 | ||
84 | local user | |
85 | local secret | |
86 | local server | |
87 | local protocol="tic" | |
88 | local tunnel_id | |
89 | ||
90 | while [ $# -gt 0 ]; do | |
91 | case "${1}" in | |
92 | --user=*) | |
93 | user=$(cli_get_val ${1}) | |
94 | ;; | |
95 | --secret=*) | |
96 | secret=$(cli_get_val ${1}) | |
97 | ;; | |
98 | --server=*) | |
99 | server=$(cli_get_val ${1}) | |
100 | ;; | |
101 | --protocol=*) | |
102 | protocol=$(cli_get_val ${1}) | |
103 | ;; | |
104 | --tunnel-id=*) | |
105 | tunnel_id=$(cli_get_val ${1}) | |
106 | ;; | |
107 | esac | |
108 | shift | |
109 | done | |
110 | ||
111 | assert isset user | |
112 | assert isset secret | |
113 | assert isset server | |
114 | assert isset protocol | |
115 | assert isoneof protocol tic tsp l2tp | |
116 | ||
117 | cat <<EOF | |
118 | ## AICCU configuration for ${zone} | |
119 | ||
120 | username ${user} | |
121 | password ${secret} | |
122 | ||
123 | server ${server} | |
124 | protocol ${protocol} | |
125 | ||
126 | $(isset tunnel_id && echo "tunnel_id ${tunnel_id}") | |
127 | ||
128 | ipv6_interface ${device} | |
129 | ||
130 | verbose true | |
131 | daemonize true | |
132 | automatic true | |
133 | ||
134 | pidfile $(aiccu_config_dir ${zone})/pid | |
135 | ||
136 | #setupscript /tmp/aiccu.sh | |
137 | ||
138 | EOF | |
139 | ||
140 | return ${EXIT_OK} | |
141 | } |