]>
Commit | Line | Data |
---|---|---|
8065d37b MT |
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 | ||
1c6a4e30 | 22 | he_tunnelbroker_endpoint_update() { |
8065d37b MT |
23 | local username |
24 | local password | |
25 | local tunnel_id | |
26 | ||
27 | while [ $# -gt 0 ]; do | |
28 | case "${1}" in | |
29 | --username=*) | |
30 | username="$(cli_get_val ${1})" | |
31 | ;; | |
32 | --password=*) | |
33 | password="$(cli_get_val ${1})" | |
34 | ;; | |
35 | --tunnel-id=*) | |
36 | tunnel_id="$(cli_get_val ${1})" | |
37 | ;; | |
38 | esac | |
39 | shift | |
40 | done | |
41 | ||
42 | assert isset username | |
43 | assert isset password | |
44 | assert isset tunnel_id | |
45 | ||
46 | # Send HTTP request. | |
47 | local response=$(http_GET --username="${username}" --password="${password}" \ | |
0279597f | 48 | "https://ipv4.tunnelbroker.net/nic/update" "hostname=${tunnel_id}") |
8065d37b MT |
49 | |
50 | log DEBUG "Server response: ${response}" | |
51 | ||
52 | case "${response}" in | |
53 | "-ERROR: This tunnel is already associated with this IP address.*") | |
54 | # This is not really an error, because the right IP address is | |
55 | # already configured. | |
56 | ;; | |
57 | "-ERROR:*") | |
58 | log ERROR "Tunnel endpoint address update not successful for tunnel ${tunnel_id}" | |
59 | return ${EXIT_ERROR} | |
60 | ;; | |
61 | esac | |
62 | ||
63 | log INFO "Tunnel endpoint address has been updated for tunnel ${tunnel_id}" | |
64 | return ${EXIT_OK} | |
65 | } |