]> git.ipfire.org Git - people/ms/network.git/blame - src/hooks/zones/aiccu
Use autotools.
[people/ms/network.git] / src / hooks / zones / aiccu
CommitLineData
671fa0bd
MT
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
20ecb48c 5# Copyright (C) 2013 IPFire Network Development Team #
671fa0bd
MT
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
f41fa3d7 22. /usr/lib/network/header-zone
671fa0bd 23
5bb66bbe 24HOOK_SETTINGS="HOOK PASSWORD PROTOCOL REQUIRE_TLS USERNAME SERVER TUNNEL_ID"
671fa0bd 25
5bb66bbe
SS
26USERNAME=
27PASSWORD=
671fa0bd
MT
28SERVER="tic.sixxs.net"
29PROTOCOL="tic"
30TUNNEL_ID=
20ecb48c 31REQUIRE_TLS="true"
671fa0bd 32
2181765d 33function hook_check() {
5bb66bbe
SS
34 assert isset USERNAME
35 assert isset PASSWORD
671fa0bd
MT
36 assert isset SERVER
37 assert isset PROTOCOL
20ecb48c 38 assert isset REQUIRE_TLS
f5c92542
SS
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
671fa0bd
MT
46}
47
2181765d 48function hook_parse_cmdline() {
671fa0bd
MT
49 local value
50
51 while [ $# -gt 0 ]; do
52 case "$1" in
5bb66bbe
SS
53 --username=*)
54 USERNAME="$(cli_get_val ${1})"
671fa0bd 55 ;;
5bb66bbe
SS
56 --password=*)
57 PASSWORD="$(cli_get_val ${1})"
671fa0bd
MT
58 ;;
59 --server=*)
20ecb48c 60 SERVER="$(cli_get_val ${1})"
671fa0bd
MT
61 ;;
62 --protocol=*)
20ecb48c 63 PROTOCOL="$(cli_get_val ${1})"
671fa0bd
MT
64 ;;
65 --tunnel-id=*)
20ecb48c
SS
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
671fa0bd
MT
76 ;;
77 *)
78 echo "Unknown option: $1" >&2
79 exit ${EXIT_ERROR}
80 ;;
81 esac
82 shift
83 done
84}
85
2181765d 86function hook_up() {
671fa0bd 87 local zone=${1}
671fa0bd
MT
88 assert isset zone
89
bfebc08f
SS
90 # Start aiccu on this zone.
91 aiccu_start ${zone}
671fa0bd 92
bfebc08f 93 exit ${EXIT_OK}
671fa0bd
MT
94}
95
2181765d 96function hook_down() {
671fa0bd 97 local zone=${1}
bfebc08f 98 assert isset zone
671fa0bd 99
bfebc08f 100 # Stop aiccu on this zone.
671fa0bd
MT
101 aiccu_stop ${zone}
102
103 exit ${EXIT_OK}
104}
105
2181765d 106function hook_status() {
671fa0bd 107 local zone=${1}
671fa0bd
MT
108 assert isset zone
109
3cb2fc42 110 cli_device_headline ${zone}
671fa0bd
MT
111
112 zone_config_read ${zone}
113
3cb2fc42 114 cli_headline 2 "Configuration"
5bb66bbe 115 cli_print_fmt1 2 "User" "${USERNAME}"
3cb2fc42
MT
116 cli_print_fmt1 2 "Secret" "<hidden>"
117 cli_space
118 cli_print_fmt1 2 "Server" "${SERVER}"
119 cli_print_fmt1 2 "Protocol" "${PROTOCOL}"
671fa0bd 120 if isset TUNNEL_ID; then
3cb2fc42
MT
121 cli_space
122 cli_print_fmt1 2 "Tunnel ID" "${TUNNEL_ID}"
671fa0bd 123 fi
3cb2fc42 124 cli_space
671fa0bd
MT
125
126 exit ${EXIT_OK}
127}