#!/bin/bash set -euo pipefail daemon=$(snapctl get daemon) case "$daemon" in true) # start the daemon if snapctl services "$SNAP_INSTANCE_NAME" | grep -q inactive; then snapctl start --enable "$SNAP_INSTANCE_NAME" 2>&1 || true fi ;; false) # stop the daemon snapctl stop --disable "$SNAP_INSTANCE_NAME" 2>&1 || true ;; *) echo "ERROR: Set 'daemon' to one of true|false" exit 1 ;; esac