]> git.ipfire.org Git - people/arne_f/network.git/blob - header-port
Fix weird device CLI command.
[people/arne_f/network.git] / header-port
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/functions
23
24 HOOK=$(basename ${0})
25 INFO_SETTINGS="HOOK PORT_PARENTS PORT_CHILDREN"
26
27 while [ $# -gt 0 ]; do
28 case "${1}" in
29 -*)
30 error "Unrecognized option: ${1}"
31 exit ${EXIT_ERROR}
32 ;;
33 *)
34 action=${1}
35 ;;
36 esac
37 shift
38 [ -n "${action}" ] && break
39 done
40
41 function run() {
42 case "${action}" in
43 edit|add|create|rem|up|down|status|info)
44 _${action} $@
45 ;;
46 esac
47
48 error "Port hook '${HOOK}' didn't exit properly."
49 exit ${EXIT_ERROR}
50 }
51
52 function _info() {
53 local port=${1}
54 shift
55
56 assert isset port
57
58 config_read $(port_file ${port})
59
60 local key
61 local val
62 for key in PORT_PARENTS PORT_CHILDREN; do
63 val="${key}_VAR"
64 val=${!val}
65 eval "${key}=\"${!val}\""
66 done
67
68 for key in ${INFO_SETTINGS}; do
69 echo "${key}=\"${!key}\""
70 done
71
72 exit ${ERROR_OK}
73 }