]> git.ipfire.org Git - people/arne_f/network.git/blame - header-port
Fix weird device CLI command.
[people/arne_f/network.git] / header-port
CommitLineData
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 24HOOK=$(basename ${0})
98f4dae6 25INFO_SETTINGS="HOOK PORT_PARENTS PORT_CHILDREN"
1848564d
MT
26
27while [ $# -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
39done
40
1848564d
MT
41function run() {
42 case "${action}" in
98f4dae6 43 edit|add|create|rem|up|down|status|info)
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
MT
51
52function _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}