|
|
a0a3b4 |
From 4c83fd10ab2a43272eab59719486064085beb2df Mon Sep 17 00:00:00 2001
|
|
|
a0a3b4 |
From: Harald Hoyer <harald@redhat.com>
|
|
|
a0a3b4 |
Date: Fri, 15 Apr 2016 11:27:20 +0200
|
|
|
a0a3b4 |
Subject: [PATCH] watchdog/module-setup.sh: rewrite
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
- use local variables with _
|
|
|
a0a3b4 |
- use associative array for the kernel modules
|
|
|
a0a3b4 |
- install emergency hook even in the systemd case
|
|
|
a0a3b4 |
- follow device path until /sys is reached
|
|
|
a0a3b4 |
- set kernel version for modprobe checking
|
|
|
a0a3b4 |
---
|
|
|
a0a3b4 |
modules.d/04watchdog/module-setup.sh | 92 ++++++++++++++++++++----------------
|
|
|
a0a3b4 |
1 file changed, 51 insertions(+), 41 deletions(-)
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
diff --git a/modules.d/04watchdog/module-setup.sh b/modules.d/04watchdog/module-setup.sh
|
|
|
1755ca |
index 6b35f9f5..31102f4e 100755
|
|
|
a0a3b4 |
--- a/modules.d/04watchdog/module-setup.sh
|
|
|
a0a3b4 |
+++ b/modules.d/04watchdog/module-setup.sh
|
|
|
a0a3b4 |
@@ -13,54 +13,64 @@ depends() {
|
|
|
a0a3b4 |
install() {
|
|
|
a0a3b4 |
# Do not add watchdog hooks if systemd module is included
|
|
|
a0a3b4 |
# In that case, systemd will manage watchdog kick
|
|
|
a0a3b4 |
- if dracut_module_included "systemd"; then
|
|
|
a0a3b4 |
- return
|
|
|
a0a3b4 |
+ if ! dracut_module_included "systemd"; then
|
|
|
a0a3b4 |
+ inst_hook cmdline 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook cmdline 50 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook pre-trigger 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook initqueue 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook mount 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook mount 50 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook mount 99 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook pre-pivot 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook pre-pivot 99 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook cleanup 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
+ inst_hook cleanup 99 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
fi
|
|
|
a0a3b4 |
- inst_hook cmdline 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook cmdline 50 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook pre-trigger 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook initqueue 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook mount 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook mount 50 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook mount 99 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook pre-pivot 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook pre-pivot 99 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook cleanup 00 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
- inst_hook cleanup 99 "$moddir/watchdog.sh"
|
|
|
a0a3b4 |
inst_hook emergency 02 "$moddir/watchdog-stop.sh"
|
|
|
a0a3b4 |
inst_multiple -o wdctl
|
|
|
a0a3b4 |
}
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
installkernel() {
|
|
|
a0a3b4 |
+ local -A _drivers
|
|
|
a0a3b4 |
+ local _alldrivers _active _wdtdrv _wdtppath _dir
|
|
|
a0a3b4 |
[[ -d /sys/class/watchdog/ ]] || return
|
|
|
a0a3b4 |
- wdtcmdline=""
|
|
|
a0a3b4 |
- for dir in /sys/class/watchdog/*; do
|
|
|
a0a3b4 |
- [[ -d "$dir" ]] || continue
|
|
|
a0a3b4 |
- [[ -f "$dir/state" ]] || continue
|
|
|
a0a3b4 |
- active=$(< "$dir/state")
|
|
|
a0a3b4 |
- ! [[ $hostonly ]] || [[ "$active" = "active" ]] || continue
|
|
|
a0a3b4 |
- # device/modalias will return driver of this device
|
|
|
a0a3b4 |
- wdtdrv=$(< "$dir/device/modalias")
|
|
|
a0a3b4 |
- # There can be more than one module represented by same
|
|
|
a0a3b4 |
- # modalias. Currently load all of them.
|
|
|
a0a3b4 |
- # TODO: Need to find a way to avoid any unwanted module
|
|
|
a0a3b4 |
- # represented by modalias
|
|
|
a0a3b4 |
- wdtdrv=$(modprobe -R $wdtdrv)
|
|
|
a0a3b4 |
- instmods $wdtdrv
|
|
|
a0a3b4 |
- wdtcmdline="$wdtcmdline$(echo $wdtdrv | tr " " ","),"
|
|
|
a0a3b4 |
- # however in some cases, we also need to check that if there is
|
|
|
a0a3b4 |
- # a specific driver for the parent bus/device. In such cases
|
|
|
a0a3b4 |
- # we also need to enable driver for parent bus/device.
|
|
|
a0a3b4 |
- wdtppath=$(readlink -f "$dir/device/..")
|
|
|
a0a3b4 |
- while [ -f "$wdtppath/modalias" ]
|
|
|
a0a3b4 |
- do
|
|
|
a0a3b4 |
- wdtpdrv=$(< "$wdtppath/modalias")
|
|
|
a0a3b4 |
- wdtpdrv=$(modprobe -R $wdtpdrv)
|
|
|
a0a3b4 |
- instmods $wdtpdrv
|
|
|
a0a3b4 |
- wdtcmdline="$wdtcmdline$(echo $wdtpdrv | tr " " ","),"
|
|
|
a0a3b4 |
- wdtppath=$(readlink -f "$wdtppath/..")
|
|
|
a0a3b4 |
- done
|
|
|
a0a3b4 |
+ for _dir in /sys/class/watchdog/*; do
|
|
|
a0a3b4 |
+ [[ -d "$_dir" ]] || continue
|
|
|
a0a3b4 |
+ [[ -f "$_dir/state" ]] || continue
|
|
|
a0a3b4 |
+ _active=$(< "$_dir/state")
|
|
|
a0a3b4 |
+ ! [[ $hostonly ]] || [[ "$_active" = "active" ]] || continue
|
|
|
a0a3b4 |
+ # device/modalias will return driver of this device
|
|
|
a0a3b4 |
+ _wdtdrv=$(< "$_dir/device/modalias")
|
|
|
a0a3b4 |
+ # There can be more than one module represented by same
|
|
|
a0a3b4 |
+ # modalias. Currently load all of them.
|
|
|
a0a3b4 |
+ # TODO: Need to find a way to avoid any unwanted module
|
|
|
a0a3b4 |
+ # represented by modalias
|
|
|
a0a3b4 |
+ _wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null)
|
|
|
a0a3b4 |
+ if [[ $_wdtdrv ]]; then
|
|
|
a0a3b4 |
+ instmods $_wdtdrv
|
|
|
a0a3b4 |
+ for i in $_wdtdrv; do
|
|
|
a0a3b4 |
+ _drivers[$i]=1
|
|
|
a0a3b4 |
+ done
|
|
|
a0a3b4 |
+ fi
|
|
|
a0a3b4 |
+ # however in some cases, we also need to check that if there is
|
|
|
a0a3b4 |
+ # a specific driver for the parent bus/device. In such cases
|
|
|
a0a3b4 |
+ # we also need to enable driver for parent bus/device.
|
|
|
a0a3b4 |
+ _wdtppath=$(readlink -f "$_dir/device/..")
|
|
|
a0a3b4 |
+ while [[ -d "$_wdtppath" ]] && [[ "$_wdtppath" != "/sys" ]]; do
|
|
|
a0a3b4 |
+ _wdtppath=$(readlink -f "$_wdtppath/..")
|
|
|
a0a3b4 |
+ [[ -f "$_wdtppath/modalias" ]] || continue
|
|
|
a0a3b4 |
+
|
|
|
a0a3b4 |
+ _wdtdrv=$(< "$_wdtppath/modalias")
|
|
|
a0a3b4 |
+ _wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null)
|
|
|
a0a3b4 |
+ if [[ $_wdtdrv ]]; then
|
|
|
a0a3b4 |
+ instmods $_wdtdrv
|
|
|
a0a3b4 |
+ for i in $_wdtdrv; do
|
|
|
a0a3b4 |
+ _drivers[$i]=1
|
|
|
a0a3b4 |
+ done
|
|
|
a0a3b4 |
+ fi
|
|
|
a0a3b4 |
+ done
|
|
|
a0a3b4 |
done
|
|
|
a0a3b4 |
# ensure that watchdog module is loaded as early as possible
|
|
|
a0a3b4 |
- [[ $wdtcmdline = "" ]] || echo "rd.driver.pre=$wdtcmdline" > ${initdir}/etc/cmdline.d/00-watchdog.conf
|
|
|
a0a3b4 |
+ _alldrivers="${!_drivers[*]}"
|
|
|
a0a3b4 |
+ [[ $_alldrivers ]] && echo "rd.driver.pre=${_alldrivers// /,}" > ${initdir}/etc/cmdline.d/00-watchdog.conf
|
|
|
a0a3b4 |
}
|