]> git.ipfire.org Git - network.git/blame - hooks/zones/aiccu
aiccu: Rename variables for credentials to username and password.
[network.git] / 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
MT
32
33function _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
671fa0bd
MT
39}
40
41function _parse_cmdline() {
42 local value
43
44 while [ $# -gt 0 ]; do
45 case "$1" in
5bb66bbe
SS
46 --username=*)
47 USERNAME="$(cli_get_val ${1})"
671fa0bd 48 ;;
5bb66bbe
SS
49 --password=*)
50 PASSWORD="$(cli_get_val ${1})"
671fa0bd
MT
51 ;;
52 --server=*)
20ecb48c 53 SERVER="$(cli_get_val ${1})"
671fa0bd
MT
54 ;;
55 --protocol=*)
20ecb48c 56 PROTOCOL="$(cli_get_val ${1})"
671fa0bd
MT
57 ;;
58 --tunnel-id=*)
20ecb48c
SS
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
671fa0bd
MT
69 ;;
70 *)
71 echo "Unknown option: $1" >&2
72 exit ${EXIT_ERROR}
73 ;;
74 esac
75 shift
76 done
77}
78
79function _up() {
80 local zone=${1}
671fa0bd
MT
81 assert isset zone
82
bfebc08f
SS
83 # Start aiccu on this zone.
84 aiccu_start ${zone}
671fa0bd 85
bfebc08f 86 exit ${EXIT_OK}
671fa0bd
MT
87}
88
89function _down() {
90 local zone=${1}
bfebc08f 91 assert isset zone
671fa0bd 92
bfebc08f 93 # Stop aiccu on this zone.
671fa0bd
MT
94 aiccu_stop ${zone}
95
96 exit ${EXIT_OK}
97}
98
99function _status() {
100 local zone=${1}
671fa0bd
MT
101 assert isset zone
102
3cb2fc42 103 cli_device_headline ${zone}
671fa0bd
MT
104
105 zone_config_read ${zone}
106
3cb2fc42 107 cli_headline 2 "Configuration"
5bb66bbe 108 cli_print_fmt1 2 "User" "${USERNAME}"
3cb2fc42
MT
109 cli_print_fmt1 2 "Secret" "<hidden>"
110 cli_space
111 cli_print_fmt1 2 "Server" "${SERVER}"
112 cli_print_fmt1 2 "Protocol" "${PROTOCOL}"
671fa0bd 113 if isset TUNNEL_ID; then
3cb2fc42
MT
114 cli_space
115 cli_print_fmt1 2 "Tunnel ID" "${TUNNEL_ID}"
671fa0bd 116 fi
3cb2fc42 117 cli_space
671fa0bd
MT
118
119 exit ${EXIT_OK}
120}