Created
December 19, 2024 05:19
-
-
Save junosuarez/be6c0b7a8b511ba3b772c8a937b6698c to your computer and use it in GitHub Desktop.
Revisions
-
junosuarez created this gist
Dec 19, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ #!/bin/bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) $SCRIPT_DIR/hass-svc.sh This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ this is an operator to keep the hass UTM VM started hass-svc.sh - the script which implements healthchecking and restarting svc.log - status log hass-svc.command - wrapper to start hass-svc at login, set in System Settings > Login Items > Open at Login note, this all is convoluted and an imperfect solution, but good enough for now This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ #! /bin/bash VM_NAME=hass INTERVAL_SEC=15 function getStatus() { utmctl status "$VM_NAME" } function isoDate() { date -u +"%Y-%m-%dT%H:%M:%SZ" } function log() { echo "$(isoDate) - $@" | tee -a ~/hass/svc.log } function tryStart() { log fix:try_start utmctl start "$VM_NAME" sleep 1 } function tick() { case "$(getStatus)" in "started") log check:ok ;; "stopped") log check:e_stopped #log dbg:lets do something tryStart tick ;; "paused") log check:e_paused tryStart tick ;; *) log check:e_unknown ;; esac } function main() { log service_monitor_started while true; do tick sleep $INTERVAL_SEC done } main