diff --git a/scripts/umbrel-os/external-storage/mount b/scripts/umbrel-os/external-storage/mount index 90d4470..6c1b966 100755 --- a/scripts/umbrel-os/external-storage/mount +++ b/scripts/umbrel-os/external-storage/mount @@ -146,7 +146,6 @@ copy_docker_to_external_storage () { main () { $set_status mount started - trap '[[ "$?" != "0" ]] && $set_status mount errored mount-script-exit' EXIT echo "Running external storage mount script..." check_root check_dependencies sed wipefs parted mount sync umount diff --git a/scripts/umbrel-os/service-monitor b/scripts/umbrel-os/service-monitor new file mode 100755 index 0000000..336bc76 --- /dev/null +++ b/scripts/umbrel-os/service-monitor @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +UMBREL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../..)" +STATUS_FILE_PATH="/umbrel-status" + +set_status="/status-server/set-status" + +check_root () { + if [[ $UID != 0 ]]; then + echo "This script must be run as root" + exit 1 + fi +} + +check_umbrel_os () { + [[ -f "/etc/default/umbrel" ]] && source "/etc/default/umbrel" + if [[ -z "${UMBREL_OS:-}" ]]; then + echo "This script must only be run on Umbrel OS" + exit 1 + fi +} + +has_service_failed () { + systemctl is-failed --quiet '*' +} + +has_umbrel_started () { + cat "${STATUS_FILE_PATH}" | grep --silent '^umbrel:completed$' +} + +has_error_been_caught () { + cat "${STATUS_FILE_PATH}" | grep --silent ':errored:' +} + +check_root +check_umbrel_os + +$set_status service-monitor started +echo "Starting service monitor..." + +while true +do + if has_umbrel_started + then + echo "Umbrel successfully started, exiting service monitor!" + exit 0 + fi + if has_service_failed + then + echo "Service failed!" + if has_error_been_caught + then + echo "Error already caught, doing nothing." + else + echo "Error not caught, writing an error." + $set_status service-monitor errored service-failed + fi + echo "Exiting service monitor" + exit 0 + fi + sleep 1 +done diff --git a/scripts/umbrel-os/services/umbrel-service-monitor.service b/scripts/umbrel-os/services/umbrel-service-monitor.service new file mode 100644 index 0000000..322e2fc --- /dev/null +++ b/scripts/umbrel-os/services/umbrel-service-monitor.service @@ -0,0 +1,21 @@ +# Umbrel Service Monitor +# Installed at /etc/systemd/system/umbrel-service-monitor.service + +[Unit] +Description=Service Monitor +After=umbrel-status-server.service + +[Service] +Type=oneshot +Restart=no +ExecStart=/home/umbrel/umbrel/scripts/umbrel-os/service-monitor +TimeoutStartSec=45min +User=root +Group=root +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=service monitor +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/scripts/umbrel-os/status-server/static/index.html b/scripts/umbrel-os/status-server/static/index.html index d813955..088974a 100644 --- a/scripts/umbrel-os/status-server/static/index.html +++ b/scripts/umbrel-os/status-server/static/index.html @@ -76,9 +76,9 @@
The version of UmbrelOS on your microSD card is not compatible with the version of Umbrel on your external drive.
-Error: Mounting external drive failed
-Something went wrong when trying to connect to the external drive.
+Error: System service failed
+Something went wrong when starting Umbrel. Need help? Feel free to jump on our community forum or Telegram chat.