]> git.ipfire.org Git - people/arne_f/network.git/blob - hooks/zones/aiccu
network: Initial support for IPv6 tunnels with aiccu.
[people/arne_f/network.git] / hooks / zones / aiccu
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
22 . /lib/network/header-zone
23
24 HOOK_SETTINGS="HOOK PROTOCOL USER SECRET SERVER TUNNEL_ID"
25
26 USER=
27 SECRET=
28 SERVER="tic.sixxs.net"
29 PROTOCOL="tic"
30 TUNNEL_ID=
31
32 function _check() {
33 assert isset USER
34 assert isset SECRET
35 assert isset SERVER
36 assert isset PROTOCOL
37 }
38
39 function _parse_cmdline() {
40 local value
41
42 while [ $# -gt 0 ]; do
43 case "$1" in
44 --user=*)
45 USER=$(cli_get_val ${1})
46 ;;
47 --secret=*)
48 SECRET=$(cli_get_val ${1})
49 ;;
50 --server=*)
51 SERVER=$(cli_get_val ${1})
52 ;;
53 --protocol=*)
54 PROTOCOL=$(cli_get_val ${1})
55 ;;
56 --tunnel-id=*)
57 TUNNEL_ID=$(cli_get_val ${1})
58 ;;
59 *)
60 echo "Unknown option: $1" >&2
61 exit ${EXIT_ERROR}
62 ;;
63 esac
64 shift
65 done
66 }
67
68 function _up() {
69 local zone=${1}
70 shift
71
72 assert isset zone
73
74 zone_config_read ${zone}
75
76 aiccu_start ${zone} \
77 --server="${SERVER}" \
78 --protocol="${PROTOCOL}" \
79 --user="${USER}" \
80 --secret="${SECRET}" \
81 --tunnel-id="${TUNNEL_ID}"
82
83 exit $?
84 }
85
86 function _down() {
87 local zone=${1}
88 shift
89
90 aiccu_stop ${zone}
91
92 exit ${EXIT_OK}
93 }
94
95 function _status() {
96 local zone=${1}
97
98 assert isset zone
99
100 cli_status_headline ${zone}
101
102 zone_config_read ${zone}
103
104 cli_headline " Configuration:"
105 printf "${DEVICE_PRINT_LINE1}" "User:" "${USER}"
106 printf "${DEVICE_PRINT_LINE1}" "Secret:" "<hidden>"
107 echo
108 printf "${DEVICE_PRINT_LINE1}" "Server:" "${SERVER}"
109 printf "${DEVICE_PRINT_LINE1}" "Protocol:" "${PROTOCOL}"
110 if isset TUNNEL_ID; then
111 echo
112 printf "${DEVICE_PRINT_LINE1}" "Tunnel ID:" "${TUNNEL_ID}"
113 fi
114 echo
115 printf "${DEVICE_PRINT_LINE1}" "Use default route?" "$(enabled DEFAULTROUTE && echo "enabled" || echo "disabled")"
116 printf "${DEVICE_PRINT_LINE1}" "Use peer DNS?" "$(enabled PEERDNS && echo "enabled" || echo "disabled")"
117
118 # Exit if zone is down
119 if ! zone_is_up ${zone}; then
120 echo # Empty line
121 exit ${EXIT_ERROR}
122 fi
123
124 cli_headline " Protocol information:"
125 printf "${DEVICE_PRINT_LINE1}" "MTU:" "$(device_get_mtu ${zone})"
126 echo
127
128 exit ${EXIT_OK}
129 }
130
131 run $@