blob: ad49eed82ad4a47be8cb867143a08a0d55e3808b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
add_watchdog_confs() {
interval=10 # minutes
count=5 # allowed reboots
for service in $(ls $D/lib/systemd/system | grep -o ".*service"); do
if [[ "$service" == *"mapper-wait"* ]]; then
continue
fi
if [ "$service" = "system-watchdog.service" ]; then
continue
fi
if [ "$service" = "systemd-coredump@.service" ]; then
continue
fi
if cat $D/lib/systemd/system/${service} | grep oneshot > /dev/null; then
continue
fi
folder="$D/etc/systemd/system/${service}.d"
mkdir -p "${folder}"
fname="${folder}/watchdog.conf"
echo "[Unit]" > ${fname}
echo "OnFailure=watchdog-reset@${service}.service" >> ${fname}
echo "[Service]" >> "${fname}"
echo "StartLimitInterval=${interval}min" >> "${fname}"
echo "StartLimitBurst=${count}" >> "${fname}"
echo "RestartSec=60" >> "${fname}"
if cat $D/lib/systemd/system/${service} | grep Restart > /dev/null; then
continue
fi
echo "Restart=on-failure" >> "${fname}"
done
}
ROOTFS_POSTINSTALL_COMMAND += "add_watchdog_confs"
|