]> git.ipfire.org Git - people/ms/network.git/blob - hooks/zones/aiccu
aiccu: Implement optional SSL encrytion.
[people/ms/network.git] / hooks / zones / aiccu
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 IPFire Network Development Team #
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 . /usr/lib/network/header-zone
23
24 HOOK_SETTINGS="HOOK PROTOCOL REQUIRE_TLS USER SECRET SERVER TUNNEL_ID"
25
26 USER=
27 SECRET=
28 SERVER="tic.sixxs.net"
29 PROTOCOL="tic"
30 TUNNEL_ID=
31 REQUIRE_TLS="true"
32
33 function _check() {
34 assert isset USER
35 assert isset SECRET
36 assert isset SERVER
37 assert isset PROTOCOL
38 assert isset REQUIRE_TLS
39 }
40
41 function _parse_cmdline() {
42 local value
43
44 while [ $# -gt 0 ]; do
45 case "$1" in
46 --user=*)
47 USER="$(cli_get_val ${1})"
48 ;;
49 --secret=*)
50 SECRET="$(cli_get_val ${1})"
51 ;;
52 --server=*)
53 SERVER="$(cli_get_val ${1})"
54 ;;
55 --protocol=*)
56 PROTOCOL="$(cli_get_val ${1})"
57 ;;
58 --tunnel-id=*)
59 TUNNEL_ID="$(cli_get_val ${1})"
60 ;;
61 --require-tls=*)
62 REQUIRE_TLS="$(cli_get_val ${1})"
63
64 if enabled val; then
65 REQUIRE_TLS="true"
66 else
67 REQUIRE_TLS="false"
68 fi
69 ;;
70 *)
71 echo "Unknown option: $1" >&2
72 exit ${EXIT_ERROR}
73 ;;
74 esac
75 shift
76 done
77 }
78
79 function _up() {
80 local zone=${1}
81 shift
82
83 assert isset zone
84
85 zone_config_read ${zone}
86
87 aiccu_start ${zone} \
88 --server="${SERVER}" \
89 --protocol="${PROTOCOL}" \
90 --user="${USER}" \
91 --secret="${SECRET}" \
92 --tunnel-id="${TUNNEL_ID}" \
93 --require-tls="${REQUIRE_TLS}"
94
95 exit $?
96 }
97
98 function _down() {
99 local zone=${1}
100 shift
101
102 aiccu_stop ${zone}
103
104 exit ${EXIT_OK}
105 }
106
107 function _status() {
108 local zone=${1}
109 assert isset zone
110
111 cli_device_headline ${zone}
112
113 zone_config_read ${zone}
114
115 cli_headline 2 "Configuration"
116 cli_print_fmt1 2 "User" "${USER}"
117 cli_print_fmt1 2 "Secret" "<hidden>"
118 cli_space
119 cli_print_fmt1 2 "Server" "${SERVER}"
120 cli_print_fmt1 2 "Protocol" "${PROTOCOL}"
121 if isset TUNNEL_ID; then
122 cli_space
123 cli_print_fmt1 2 "Tunnel ID" "${TUNNEL_ID}"
124 fi
125 cli_space
126
127 exit ${EXIT_OK}
128 }