]> git.ipfire.org Git - network.git/blame - src/functions/functions.hotplug
hostapd: Dump config file in debug mode
[network.git] / src / functions / functions.hotplug
CommitLineData
b8026986
MT
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2014 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 22hotplug_assert_in_hotplug_event() {
b8026986
MT
23 assert [ -n "${IN_HOTPLUG_EVENT}" ]
24}
25
1c6a4e30 26hotplug_action() {
b8026986
MT
27 hotplug_assert_in_hotplug_event
28
29 echo "${ACTION}"
30}
31
1c6a4e30 32hotplug_propagate_all_ports() {
b8026986
MT
33 hotplug_assert_in_hotplug_event
34
35 # Create configured child devices.
36 local port
37 for port in $(ports_get_all); do
38 port_hotplug_event "${port}"
39 local ret="${?}"
40
41 # Log warning for crashed hooks
42 case "${ret}" in
43 ${EXIT_OK}|${EXIT_NOT_HANDLED})
44 : # do nothing
45 ;;
46 *)
47 log WARNING "Unknown exit code for port '${port}': ${ret}"
48 ;;
49 esac
50 done
51}
52
1c6a4e30 53hotplug_propagate_all_zones() {
2a969c27
MT
54 hotplug_assert_in_hotplug_event
55
56 local zone
57 for zone in $(zones_get_all); do
58 zone_hotplug_event "${zone}"
59 local ret="${?}"
60
61 # Log warning for crashed hooks
62 case "${ret}" in
63 ${EXIT_OK}|${EXIT_NOT_HANDLED})
64 : # do nothing
65 ;;
66 *)
67 log WARNING "Unknown exit code for zone '${zone}': ${ret}"
68 ;;
69 esac
70 done
71}
72
9b47451e
MT
73hotplug_event_interface_is_zone() {
74 hotplug_assert_in_hotplug_event
75
76 local zone="${1}"
77 assert isset zone
78
9b47451e
MT
79 [ "${zone}" = "${INTERFACE}" ]
80}
81
1c6a4e30 82hotplug_event_port_is_interface() {
b8026986
MT
83 hotplug_assert_in_hotplug_event
84
85 local port="${1}"
86 assert isset port
87
88 [ "${port}" = "${INTERFACE}" ]
89}
90
1c6a4e30 91hotplug_event_interface_is_slave_of_port() {
b8026986
MT
92 hotplug_assert_in_hotplug_event
93
94 local port="${1}"
95 assert isset port
96
97 # Return false if INTERFACE is not set
98 isset INTERFACE || return ${EXIT_FALSE}
99
100 local slaves="$(port_get_slaves "${port}")"
2a969c27
MT
101 list_match "${INTERFACE}" ${slaves}
102}
103
1c6a4e30 104hotplug_event_interface_is_port_of_zone() {
2a969c27
MT
105 hotplug_assert_in_hotplug_event
106
107 local zone="${1}"
108 assert isset zone
109
110 # Return false if INTERFACE is not set
111 isset INTERFACE || return ${EXIT_FALSE}
112
113 local ports="$(zone_get_ports "${zone}")"
114 list_match "${INTERFACE}" ${ports}
b8026986
MT
115}
116
1c6a4e30 117hotplug_event_port_uses_phy() {
b8026986
MT
118 hotplug_assert_in_hotplug_event
119
120 local port="${1}"
121 assert isset port
122
123 # Return false if PHY is not set
124 isset PHY || return ${EXIT_FALSE}
125
126 # Returns true if port uses PHY
127 port_uses_phy "${port}" "${PHY}"
128}