]> git.ipfire.org Git - people/stevee/network.git/blob - header-port
Add systemd unit files for networking.
[people/stevee/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 . /usr/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|hotplug|hotplug_rename)
44 _${action} $@
45 ;;
46 esac
47
48 error "Port hook '${HOOK}' didn't exit properly."
49 exit ${EXIT_ERROR}
50 }
51
52 # This function is called after a device has been plugged
53 # into the system and got its correct name.
54 # The function is intended to create child ports and things
55 # like that.
56 function _hotplug() {
57 exit ${EXIT_OK}
58 }
59
60 # This function gets called when a device is plugged in
61 # to determine the right name.
62 # The first argument is the port which should be tested
63 # against the second argument which is the device that
64 # has been plugged in.
65 function _hotplug_rename() {
66 exit ${EXIT_FALSE}
67 }
68
69 function _info() {
70 local port=${1}
71 shift
72
73 assert isset port
74
75 config_read $(port_file ${port})
76
77 local key
78 local val
79 for key in PORT_PARENTS PORT_CHILDREN; do
80 val="${key}_VAR"
81 val=${!val}
82 eval "${key}=\"${!val}\""
83 done
84
85 for key in ${INFO_SETTINGS}; do
86 echo "${key}=\"${!key}\""
87 done
88
89 exit ${ERROR_OK}
90 }