#!/bin/sh # The long-running half of this test project: a service that does nothing # except say so, once every ten seconds, forever. # # It writes into its own data directory -- the one resources.ron names -- so # that Uninstall's "remove data" toggle has something real to remove, and so # that the directory exists to be shown in the dialog. Its *log* is not # written here: a managed service's output is captured by Dev Updater's # service script, which is what the runtime log tab reads. # # Takes the build mode as its one argument, ahead of whatever subcommand # the service contract appends -- which is how a command written once # learns which mode it is running in. It ticks at a different rate in # each, so that a mode switch is checkable from a phone: the runtime log # is the only place the difference shows. set -eu MODE="${1:-release}" case "$MODE" in release) INTERVAL=10 ;; debug) INTERVAL=2 ;; *) echo "unknown mode: $MODE (expected release or debug)" >&2 exit 2 ;; esac DATA="${XDG_DATA_HOME:-$HOME/.local/share}/dutest-service" mkdir -p "$DATA" echo "started at $(date -Is), writing to $DATA, ticking every ${INTERVAL}s in $MODE" count=0 while true; do count=$((count + 1)) echo "$(date -Is) tick $count" >>"$DATA/ticks.log" # Colour, so the runtime log tab has escapes to render too -- the same # reason breakable/build.sh writes them. printf 'tick \033[1;32m%s\033[0m -- still here\n' "$count" sleep "$INTERVAL" done