]>
Commit | Line | Data |
---|---|---|
5b20e43a MT |
1 | #!/bin/bash |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
1848564d | 5 | # Copyright (C) 2010 Michael Tremer & Christian Schmidt # |
5b20e43a 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 | ||
5b20e43a MT |
22 | . /lib/network/functions |
23 | ||
1848564d | 24 | HOOK=$(basename ${0}) |
98f4dae6 | 25 | INFO_SETTINGS="HOOK PORT_PARENTS PORT_CHILDREN" |
1848564d MT |
26 | |
27 | while [ $# -gt 0 ]; do | |
5b20e43a | 28 | case "${1}" in |
1848564d MT |
29 | -*) |
30 | error "Unrecognized option: ${1}" | |
31 | exit ${EXIT_ERROR} | |
5b20e43a MT |
32 | ;; |
33 | *) | |
34 | action=${1} | |
1848564d | 35 | ;; |
5b20e43a MT |
36 | esac |
37 | shift | |
1848564d | 38 | [ -n "${action}" ] && break |
5b20e43a MT |
39 | done |
40 | ||
1848564d MT |
41 | function run() { |
42 | case "${action}" in | |
8895cf8f | 43 | edit|add|create|rem|up|down|status|info|hotplug) |
1848564d MT |
44 | _${action} $@ |
45 | ;; | |
46 | esac | |
5b20e43a | 47 | |
1848564d | 48 | error "Port hook '${HOOK}' didn't exit properly." |
5b20e43a | 49 | exit ${EXIT_ERROR} |
1848564d | 50 | } |
98f4dae6 | 51 | |
8895cf8f MT |
52 | function _hotplug() { |
53 | exit ${EXIT_ERROR} | |
54 | } | |
55 | ||
98f4dae6 MT |
56 | function _info() { |
57 | local port=${1} | |
58 | shift | |
59 | ||
60 | assert isset port | |
61 | ||
62 | config_read $(port_file ${port}) | |
63 | ||
64 | local key | |
65 | local val | |
66 | for key in PORT_PARENTS PORT_CHILDREN; do | |
67 | val="${key}_VAR" | |
68 | val=${!val} | |
69 | eval "${key}=\"${!val}\"" | |
70 | done | |
71 | ||
72 | for key in ${INFO_SETTINGS}; do | |
73 | echo "${key}=\"${!key}\"" | |
74 | done | |
75 | ||
76 | exit ${ERROR_OK} | |
77 | } |