mirror of
https://github.com/dracutdevs/dracut.git
synced 2024-10-26 16:25:20 +03:00
add initqueue --env and "online" hook
The "online" hook runs whenever a network interface comes online (that is, once it's actually up and configured). The initqueue --env argument is used to set "$netif" to the name of the newly-online network interface.
This commit is contained in:
parent
25aa3c5a6e
commit
6e3cc00f48
@ -35,7 +35,7 @@ fi
|
||||
# export standard hookdirs
|
||||
[[ $hookdirs ]] || {
|
||||
hookdirs="cmdline pre-udev pre-trigger netroot "
|
||||
hookdirs+="initqueue initqueue/settled initqueue/finished initqueue/timeout "
|
||||
hookdirs+="initqueue initqueue/settled initqueue/online initqueue/finished initqueue/timeout "
|
||||
hookdirs+="pre-mount pre-pivot mount "
|
||||
hookdirs+="emergency shutdown-emergency shutdown cleanup "
|
||||
export hookdirs
|
||||
|
@ -31,33 +31,27 @@ fix_bootif() {
|
||||
IFACES=${bondslaves%% *}
|
||||
fi
|
||||
|
||||
ifup='/sbin/ifup $env{INTERFACE}'
|
||||
[ -z "$netroot" ] && ifup="$ifup -m"
|
||||
|
||||
# BOOTIF says everything, use only that one
|
||||
BOOTIF=$(getarg 'BOOTIF=')
|
||||
if [ -n "$BOOTIF" ] ; then
|
||||
BOOTIF=$(fix_bootif "$BOOTIF")
|
||||
if [ -n "$netroot" ]; then
|
||||
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/initqueue --onetime /sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
|
||||
else
|
||||
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/initqueue --onetime /sbin/ifup $env{INTERFACE} -m"\n' "$BOOTIF"
|
||||
fi
|
||||
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="%s"\n' "$BOOTIF" "/sbin/initqueue --onetime $ifup"
|
||||
|
||||
# If we have to handle multiple interfaces, handle only them.
|
||||
elif [ -n "$IFACES" ] ; then
|
||||
for iface in $IFACES ; do
|
||||
if [ -n "$netroot" ]; then
|
||||
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/initqueue --onetime /sbin/ifup $env{INTERFACE}"\n' "$iface"
|
||||
else
|
||||
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/initqueue --onetime /sbin/ifup $env{INTERFACE} -m"\n' "$iface"
|
||||
fi
|
||||
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="%s"\n' "$iface" "/sbin/initqueue --onetime $ifup"
|
||||
done
|
||||
|
||||
# Default: We don't know the interface to use, handle all
|
||||
else
|
||||
if [ -n "$netroot" ]; then
|
||||
printf 'SUBSYSTEM=="net", OPTIONS+="event_timeout=360", RUN+="/sbin/initqueue --onetime /sbin/ifup $env{INTERFACE}"\n'
|
||||
else
|
||||
printf 'SUBSYSTEM=="net", OPTIONS+="event_timeout=360", RUN+="/sbin/initqueue --onetime /sbin/ifup $env{INTERFACE} -m"\n'
|
||||
fi
|
||||
printf 'SUBSYSTEM=="net", RUN+="%s"\n' "/sbin/initqueue --onetime $ifup"
|
||||
fi
|
||||
|
||||
# Run the "online" hook
|
||||
printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n'
|
||||
|
||||
} > /etc/udev/rules.d/60-net.rules
|
||||
|
@ -25,6 +25,8 @@ while [ $# -gt 0 ]; do
|
||||
unique="yes";;
|
||||
--name)
|
||||
name="$2";shift;;
|
||||
--env)
|
||||
env="$2"; shift;;
|
||||
*)
|
||||
break;;
|
||||
esac
|
||||
@ -43,14 +45,11 @@ shift
|
||||
|
||||
[ -x "$exe" ] || exe=$(command -v $exe)
|
||||
|
||||
if [ -n "$onetime" ]; then
|
||||
{
|
||||
echo '[ -e "$job" ] && rm "$job"'
|
||||
echo "$exe $@"
|
||||
} > "/tmp/$$-${job}.sh"
|
||||
else
|
||||
echo "$exe $@" > "/tmp/$$-${job}.sh"
|
||||
fi
|
||||
{
|
||||
[ -n "$onetime" ] && echo '[ -e "$job" ] && rm "$job"'
|
||||
[ -n "$env" ] && echo "$env"
|
||||
echo "$exe $@"
|
||||
} > "/tmp/$$-${job}.sh"
|
||||
|
||||
mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh"
|
||||
[ -z "$qname" ] && >> $hookdir/initqueue/work
|
||||
|
Loading…
Reference in New Issue
Block a user