]>
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 | ||
671fa0bd MT |
22 | function aiccu_config_dir() { |
23 | local device=${1} | |
24 | ||
25 | echo "${RUN_DIR}/aiccu/${device}" | |
26 | } | |
27 | ||
28 | function aiccu_start() { | |
29 | local device=${1} | |
30 | shift | |
31 | ||
32 | assert isset device | |
33 | ||
34 | local config_dir=$(aiccu_config_dir ${device}) | |
35 | mkdir -p ${config_dir} | |
36 | ||
37 | local config_file=${config_dir}/config | |
38 | aiccu_configure ${device} $@ > ${config_file} | |
39 | ||
40 | aiccu start ${config_file} &>/dev/null | |
41 | local ret=$? | |
42 | ||
43 | case "${ret}" in | |
44 | 0) | |
45 | log DEBUG "Aiccu was successfully started for '${device}'." | |
46 | return ${EXIT_OK} | |
47 | ;; | |
48 | *) | |
49 | error_log "Could not start aiccu properly for '${device}'." | |
50 | ||
51 | error_log "Configuration file dump:" | |
52 | local line | |
53 | while read line; do | |
54 | error_log " ${line}" | |
55 | done < ${config_file} | |
56 | ||
57 | return ${EXIT_ERROR} | |
58 | ;; | |
59 | esac | |
60 | } | |
61 | ||
62 | function aiccu_stop() { | |
63 | local device=${1} | |
64 | ||
65 | assert isset device | |
66 | ||
67 | aiccu stop $(aiccu_config_dir ${device})/config | |
68 | ||
69 | rm -rf $(aiccu_config_dir ${device}) | |
70 | } | |
71 | ||
72 | function aiccu_configure() { | |
73 | local device=${1} | |
74 | ||
75 | assert isset device | |
76 | ||
77 | local user | |
78 | local secret | |
79 | local server | |
80 | local protocol="tic" | |
81 | local tunnel_id | |
82 | ||
83 | while [ $# -gt 0 ]; do | |
84 | case "${1}" in | |
85 | --user=*) | |
86 | user=$(cli_get_val ${1}) | |
87 | ;; | |
88 | --secret=*) | |
89 | secret=$(cli_get_val ${1}) | |
90 | ;; | |
91 | --server=*) | |
92 | server=$(cli_get_val ${1}) | |
93 | ;; | |
94 | --protocol=*) | |
95 | protocol=$(cli_get_val ${1}) | |
96 | ;; | |
97 | --tunnel-id=*) | |
98 | tunnel_id=$(cli_get_val ${1}) | |
99 | ;; | |
100 | esac | |
101 | shift | |
102 | done | |
103 | ||
104 | assert isset user | |
105 | assert isset secret | |
106 | assert isset server | |
107 | assert isset protocol | |
108 | assert isoneof protocol tic tsp l2tp | |
109 | ||
110 | cat <<EOF | |
111 | ## AICCU configuration for ${zone} | |
112 | ||
113 | username ${user} | |
114 | password ${secret} | |
115 | ||
116 | server ${server} | |
117 | protocol ${protocol} | |
118 | ||
119 | $(isset tunnel_id && echo "tunnel_id ${tunnel_id}") | |
120 | ||
121 | ipv6_interface ${device} | |
122 | ||
123 | verbose true | |
124 | daemonize true | |
125 | automatic true | |
126 | ||
127 | pidfile $(aiccu_config_dir ${zone})/pid | |
128 | ||
129 | #setupscript /tmp/aiccu.sh | |
130 | ||
131 | EOF | |
132 | ||
133 | return ${EXIT_OK} | |
134 | } |