]>
Commit | Line | Data |
---|---|---|
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 PASSWORD PROTOCOL REQUIRE_TLS USERNAME SERVER TUNNEL_ID" | |
25 | ||
26 | USERNAME= | |
27 | PASSWORD= | |
28 | SERVER="tic.sixxs.net" | |
29 | PROTOCOL="tic" | |
30 | TUNNEL_ID= | |
31 | REQUIRE_TLS="true" | |
32 | ||
33 | function hook_check_settings() { | |
34 | assert isset USERNAME | |
35 | assert isset PASSWORD | |
36 | assert isset SERVER | |
37 | assert isset PROTOCOL | |
38 | assert isset REQUIRE_TLS | |
39 | ||
40 | # Check if a supported protocol has been given. | |
41 | if ! list_match "${PROTOCOL}" ${AICCU_SUPPORTED_PROTOCOLS}; then | |
42 | log ERROR "This protocol is not supported by aiccu: ${PROTOCOL}" | |
43 | log ERROR "Valid protocols are: ${AICCU_SUPPORTED_PROTOCOLS}" | |
44 | return ${EXIT_ERROR} | |
45 | fi | |
46 | } | |
47 | ||
48 | function hook_parse_cmdline() { | |
49 | local value | |
50 | ||
51 | while [ $# -gt 0 ]; do | |
52 | case "$1" in | |
53 | --username=*) | |
54 | USERNAME="$(cli_get_val ${1})" | |
55 | ;; | |
56 | --password=*) | |
57 | PASSWORD="$(cli_get_val ${1})" | |
58 | ;; | |
59 | --server=*) | |
60 | SERVER="$(cli_get_val ${1})" | |
61 | ;; | |
62 | --protocol=*) | |
63 | PROTOCOL="$(cli_get_val ${1})" | |
64 | ;; | |
65 | --tunnel-id=*) | |
66 | TUNNEL_ID="$(cli_get_val ${1})" | |
67 | ;; | |
68 | --require-tls=*) | |
69 | REQUIRE_TLS="$(cli_get_val ${1})" | |
70 | ||
71 | if enabled val; then | |
72 | REQUIRE_TLS="true" | |
73 | else | |
74 | REQUIRE_TLS="false" | |
75 | fi | |
76 | ;; | |
77 | *) | |
78 | echo "Unknown option: $1" >&2 | |
79 | exit ${EXIT_ERROR} | |
80 | ;; | |
81 | esac | |
82 | shift | |
83 | done | |
84 | } | |
85 | ||
86 | function hook_up() { | |
87 | local zone=${1} | |
88 | assert isset zone | |
89 | ||
90 | # Start aiccu on this zone. | |
91 | aiccu_start ${zone} | |
92 | ||
93 | exit ${EXIT_OK} | |
94 | } | |
95 | ||
96 | function hook_down() { | |
97 | local zone=${1} | |
98 | assert isset zone | |
99 | ||
100 | # Stop aiccu on this zone. | |
101 | aiccu_stop ${zone} | |
102 | ||
103 | exit ${EXIT_OK} | |
104 | } | |
105 | ||
106 | function hook_status() { | |
107 | local zone=${1} | |
108 | assert isset zone | |
109 | ||
110 | cli_device_headline ${zone} | |
111 | ||
112 | zone_settings_read "${zone}" | |
113 | ||
114 | cli_headline 2 "Configuration" | |
115 | cli_print_fmt1 2 "User" "${USERNAME}" | |
116 | cli_print_fmt1 2 "Secret" "<hidden>" | |
117 | cli_space | |
118 | cli_print_fmt1 2 "Server" "${SERVER}" | |
119 | cli_print_fmt1 2 "Protocol" "${PROTOCOL}" | |
120 | if isset TUNNEL_ID; then | |
121 | cli_space | |
122 | cli_print_fmt1 2 "Tunnel ID" "${TUNNEL_ID}" | |
123 | fi | |
124 | cli_space | |
125 | ||
126 | exit ${EXIT_OK} | |
127 | } |