#!/usr/bin/env bash # Install a launchd agent that re-signs and reinstalls YaMusek every day, so the # 7-day free provisioning profile never lapses. # # ./tools/install-autorefresh.sh [BUNDLE_ID] [DEVICE_NAME_OR_UDID] # # Remove it again with: # launchctl bootout gui/$UID ~/Library/LaunchAgents/com.yamusek.refresh.plist set -euo pipefail cd "$(dirname "$0")/.." REPO="$(pwd)" TEAM="${1:-}" BUNDLE="${2:-com.yamusek.tv}" DEVICE="${3:-}" if [[ -z "$TEAM" ]]; then echo "usage: $0 [BUNDLE_ID] [DEVICE_NAME_OR_UDID]" >&2 exit 2 fi if [[ -z "$DEVICE" ]]; then echo "==> paired devices" xcrun devicectl list devices echo read -r -p "Device name or UDID: " DEVICE fi cat > tools/.autorefresh.env < "$PLIST" < Labelcom.yamusek.refresh ProgramArguments $REPO/tools/auto-refresh.sh StartCalendarInterval Hour4 Minute30 RunAtLoad StandardOutPath${TMPDIR:-/tmp}/yamusek-autorefresh.out StandardErrorPath${TMPDIR:-/tmp}/yamusek-autorefresh.err EOF launchctl bootout "gui/$UID" "$PLIST" 2>/dev/null || true launchctl bootstrap "gui/$UID" "$PLIST" echo echo "Agent installed. It runs daily at 04:30 and quietly skips days when the" echo "Apple TV is off or off-network, so the signature never gets close to expiring." echo "Log: ${TMPDIR:-/tmp}/yamusek-autorefresh.log" echo "Run it once now with: ./tools/auto-refresh.sh"