watchdog/module-setup.sh: rewrite
- use local variables with _ - use associative array for the kernel modules - install emergency hook even in the systemd case - follow device path until /sys is reached - set kernel version for modprobe checkingmaster
parent
ad438af207
commit
74e2d1e69f
|
@ -14,54 +14,64 @@ depends() {
|
||||||
install() {
|
install() {
|
||||||
# Do not add watchdog hooks if systemd module is included
|
# Do not add watchdog hooks if systemd module is included
|
||||||
# In that case, systemd will manage watchdog kick
|
# In that case, systemd will manage watchdog kick
|
||||||
if dracut_module_included "systemd"; then
|
if ! dracut_module_included "systemd"; then
|
||||||
return
|
inst_hook cmdline 00 "$moddir/watchdog.sh"
|
||||||
|
inst_hook cmdline 50 "$moddir/watchdog.sh"
|
||||||
|
inst_hook pre-trigger 00 "$moddir/watchdog.sh"
|
||||||
|
inst_hook initqueue 00 "$moddir/watchdog.sh"
|
||||||
|
inst_hook mount 00 "$moddir/watchdog.sh"
|
||||||
|
inst_hook mount 50 "$moddir/watchdog.sh"
|
||||||
|
inst_hook mount 99 "$moddir/watchdog.sh"
|
||||||
|
inst_hook pre-pivot 00 "$moddir/watchdog.sh"
|
||||||
|
inst_hook pre-pivot 99 "$moddir/watchdog.sh"
|
||||||
|
inst_hook cleanup 00 "$moddir/watchdog.sh"
|
||||||
|
inst_hook cleanup 99 "$moddir/watchdog.sh"
|
||||||
fi
|
fi
|
||||||
inst_hook cmdline 00 "$moddir/watchdog.sh"
|
|
||||||
inst_hook cmdline 50 "$moddir/watchdog.sh"
|
|
||||||
inst_hook pre-trigger 00 "$moddir/watchdog.sh"
|
|
||||||
inst_hook initqueue 00 "$moddir/watchdog.sh"
|
|
||||||
inst_hook mount 00 "$moddir/watchdog.sh"
|
|
||||||
inst_hook mount 50 "$moddir/watchdog.sh"
|
|
||||||
inst_hook mount 99 "$moddir/watchdog.sh"
|
|
||||||
inst_hook pre-pivot 00 "$moddir/watchdog.sh"
|
|
||||||
inst_hook pre-pivot 99 "$moddir/watchdog.sh"
|
|
||||||
inst_hook cleanup 00 "$moddir/watchdog.sh"
|
|
||||||
inst_hook cleanup 99 "$moddir/watchdog.sh"
|
|
||||||
inst_hook emergency 02 "$moddir/watchdog-stop.sh"
|
inst_hook emergency 02 "$moddir/watchdog-stop.sh"
|
||||||
inst_multiple -o wdctl
|
inst_multiple -o wdctl
|
||||||
}
|
}
|
||||||
|
|
||||||
installkernel() {
|
installkernel() {
|
||||||
|
local -A _drivers
|
||||||
|
local _alldrivers _active _wdtdrv _wdtppath _dir
|
||||||
[[ -d /sys/class/watchdog/ ]] || return
|
[[ -d /sys/class/watchdog/ ]] || return
|
||||||
wdtcmdline=""
|
for _dir in /sys/class/watchdog/*; do
|
||||||
for dir in /sys/class/watchdog/*; do
|
[[ -d "$_dir" ]] || continue
|
||||||
[[ -d "$dir" ]] || continue
|
[[ -f "$_dir/state" ]] || continue
|
||||||
[[ -f "$dir/state" ]] || continue
|
_active=$(< "$_dir/state")
|
||||||
active=$(< "$dir/state")
|
! [[ $hostonly ]] || [[ "$_active" = "active" ]] || continue
|
||||||
! [[ $hostonly ]] || [[ "$active" = "active" ]] || continue
|
# device/modalias will return driver of this device
|
||||||
# device/modalias will return driver of this device
|
_wdtdrv=$(< "$_dir/device/modalias")
|
||||||
wdtdrv=$(< "$dir/device/modalias")
|
# There can be more than one module represented by same
|
||||||
# There can be more than one module represented by same
|
# modalias. Currently load all of them.
|
||||||
# modalias. Currently load all of them.
|
# TODO: Need to find a way to avoid any unwanted module
|
||||||
# TODO: Need to find a way to avoid any unwanted module
|
# represented by modalias
|
||||||
# represented by modalias
|
_wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null)
|
||||||
wdtdrv=$(modprobe -R $wdtdrv)
|
if [[ $_wdtdrv ]]; then
|
||||||
instmods $wdtdrv
|
instmods $_wdtdrv
|
||||||
wdtcmdline="$wdtcmdline$(echo $wdtdrv | tr " " ","),"
|
for i in $_wdtdrv; do
|
||||||
# however in some cases, we also need to check that if there is
|
_drivers[$i]=1
|
||||||
# a specific driver for the parent bus/device. In such cases
|
done
|
||||||
# we also need to enable driver for parent bus/device.
|
fi
|
||||||
wdtppath=$(readlink -f "$dir/device/..")
|
# however in some cases, we also need to check that if there is
|
||||||
while [ -f "$wdtppath/modalias" ]
|
# a specific driver for the parent bus/device. In such cases
|
||||||
do
|
# we also need to enable driver for parent bus/device.
|
||||||
wdtpdrv=$(< "$wdtppath/modalias")
|
_wdtppath=$(readlink -f "$_dir/device/..")
|
||||||
wdtpdrv=$(modprobe -R $wdtpdrv)
|
while [[ -d "$_wdtppath" ]] && [[ "$_wdtppath" != "/sys" ]]; do
|
||||||
instmods $wdtpdrv
|
_wdtppath=$(readlink -f "$_wdtppath/..")
|
||||||
wdtcmdline="$wdtcmdline$(echo $wdtpdrv | tr " " ","),"
|
[[ -f "$_wdtppath/modalias" ]] || continue
|
||||||
wdtppath=$(readlink -f "$wdtppath/..")
|
|
||||||
done
|
_wdtdrv=$(< "$_wdtppath/modalias")
|
||||||
|
_wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null)
|
||||||
|
if [[ $_wdtdrv ]]; then
|
||||||
|
instmods $_wdtdrv
|
||||||
|
for i in $_wdtdrv; do
|
||||||
|
_drivers[$i]=1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
done
|
done
|
||||||
# ensure that watchdog module is loaded as early as possible
|
# ensure that watchdog module is loaded as early as possible
|
||||||
[[ $wdtcmdline = "" ]] || echo "rd.driver.pre=$wdtcmdline" > ${initdir}/etc/cmdline.d/00-watchdog.conf
|
_alldrivers="${!_drivers[*]}"
|
||||||
|
[[ $_alldrivers ]] && echo "rd.driver.pre=${_alldrivers// /,}" > ${initdir}/etc/cmdline.d/00-watchdog.conf
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue