diff --git a/profiles/templates/homeassistant/check-crashed/.calculate_directory b/profiles/templates/homeassistant/check-crashed/.calculate_directory new file mode 100644 index 0000000..ae03782 --- /dev/null +++ b/profiles/templates/homeassistant/check-crashed/.calculate_directory @@ -0,0 +1 @@ +# Calculate env=install ac_install_merge==on mergepkg(www-servers/nginx)!= append=skip diff --git a/profiles/templates/homeassistant/check-crashed/check-crashed b/profiles/templates/homeassistant/check-crashed/check-crashed new file mode 100644 index 0000000..a1dcda8 --- /dev/null +++ b/profiles/templates/homeassistant/check-crashed/check-crashed @@ -0,0 +1,18 @@ +# Calculate chmod=755 path=/var/calculate/bin +#!/bin/bash +# The daemon restarts the services that have crashed. +# List the tracked services in /etc/conf.d/check-crashed + +RC_MONITOR_RESTART=$@; + +while true; do + for svc in $(rc-status --crashed) ; do + for chk in $RC_MONITOR_RESTART ; do + if [ "$chk" = "$svc" ] ; then + rc-service $svc -- --nodeps restart + continue 2 + fi + done + done + sleep 1 +done diff --git a/profiles/templates/homeassistant/check-crashed/conf.check-crashed b/profiles/templates/homeassistant/check-crashed/conf.check-crashed new file mode 100644 index 0000000..f069d78 --- /dev/null +++ b/profiles/templates/homeassistant/check-crashed/conf.check-crashed @@ -0,0 +1,2 @@ +# Calculate format=openrc path=/etc/conf.d name=#-cut(1,.)-# +RC_MONITOR_RESTART="zigbee2mqtt homeassistant" diff --git a/profiles/templates/homeassistant/check-crashed/init.check-crashed b/profiles/templates/homeassistant/check-crashed/init.check-crashed new file mode 100644 index 0000000..989406c --- /dev/null +++ b/profiles/templates/homeassistant/check-crashed/init.check-crashed @@ -0,0 +1,7 @@ +# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=# +#!/sbin/openrc-run + +pidfile="/run/check_crashed.pid" +command="/var/calculate/bin/check-crashed" +command_args="${RC_MONITOR_RESTART}" +command_background=1 diff --git a/profiles/templates/homeassistant/check-crashed/runlevel.check-crashed b/profiles/templates/homeassistant/check-crashed/runlevel.check-crashed new file mode 100644 index 0000000..d96c623 --- /dev/null +++ b/profiles/templates/homeassistant/check-crashed/runlevel.check-crashed @@ -0,0 +1 @@ +# Calculate path=/etc/runlevels/default name=#-cut(1,.)-# link=/etc/init.d/#-cut(1,.)-# protected symbolic