-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hotplug: load default/networking for hotplug itfs
* [email protected] is be able to show debug and verbose logs if set in the default file. (-d -v) * ifupdown2-hotplug load default before processing (excluding EXCLUDE_INTERFACES and adding -v -d --syslog on an init.d system.
- Loading branch information
Showing
2 changed files
with
45 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,22 +49,39 @@ wait_for_interface() { | |
done | ||
} | ||
|
||
process_exclusions() { | ||
set -- $EXCLUDE_INTERFACES | ||
exclusions="" | ||
for d; do | ||
exclusions="-X $d $exclusions" | ||
done | ||
echo $exclusions | ||
} | ||
|
||
net_ifup() { | ||
. /etc/default/networking 2>/dev/null || true | ||
|
||
exclusions=$(process_exclusions) | ||
|
||
# exit if the interface is not configured as allow-hotplug (querying does not require a lock) | ||
if ! $(/sbin/ifquery --allow=hotplug -l 2>/dev/null | grep -w -q "^$INTERFACE$"); then | ||
# exit if the interface is not configured as allow-hotplug or excluded (querying does not require a lock) | ||
if ! $(/sbin/ifquery --allow=hotplug -l $exclusions 2>/dev/null | grep -w -q "^$INTERFACE$"); then | ||
exit 0 | ||
fi | ||
|
||
if [ -d /run/systemd/system ]; then | ||
exec systemctl --no-block start $(systemd-escape --template [email protected] $INTERFACE) | ||
fi | ||
|
||
EXTRA_ARGS= | ||
[ "$VERBOSE" = yes ] && EXTRA_ARGS=-v | ||
[ "$DEBUG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS -d" | ||
[ "$SYSLOG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS --syslog" | ||
|
||
# Take the lock and wait for lo before exec ifup. | ||
( | ||
flock 9 | ||
wait_for_interface lo | ||
exec ifup $INTERFACE -L 9 | ||
exec ifup $EXTRA_ARGS $HOTPLUG_ARGS -L 9 $INTERFACE | ||
) 9>$LOCKFILE | ||
} | ||
|
||
|
@@ -76,15 +93,24 @@ net_ifdown() { | |
exit 0 | ||
fi | ||
|
||
# exit if the interface is not configured as allow-hotplug (querying does not require a lock) | ||
if ! $(/sbin/ifquery --allow=hotplug -l 2>/dev/null | grep -w -q "^$INTERFACE$"); then | ||
. /etc/default/networking 2>/dev/null || true | ||
|
||
exclusions=$(process_exclusions) | ||
|
||
# exit if the interface is not configured as allow-hotplug or excluded (querying does not require a lock) | ||
if ! $(/sbin/ifquery --allow=hotplug -l $exclusions 2>/dev/null | grep -w -q "^$INTERFACE$"); then | ||
exit 0 | ||
fi | ||
|
||
EXTRA_ARGS= | ||
[ "$VERBOSE" = yes ] && EXTRA_ARGS=-v | ||
[ "$DEBUG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS -d" | ||
[ "$SYSLOG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS --syslog" | ||
|
||
# Take the lock and exec ifdown. | ||
( | ||
flock 9 | ||
exec ifdown $INTERFACE -L 9 | ||
exec ifdown $EXTRA_ARGS $INTERFACE -L 9 | ||
) 9>$LOCKFILE | ||
} | ||
|
||
|