Files
YaMusek/tools/install-autorefresh.sh
Thorgathis acd50280bc Yandex Music client for Apple TV
tvOS 17+ SwiftUI client for the unofficial Yandex Music API: rotor stations
with feedback, library, search, artist and album pages, synced lyrics, and
system Now Playing integration.
2026-09-17 20:38:19 +03:00

70 lines
1.9 KiB
Bash
Executable File

#!/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 <TEAM_ID> [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 <TEAM_ID> [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 <<EOF
TEAM=$TEAM
BUNDLE=$BUNDLE
DEVICE=$DEVICE
EOF
chmod 600 tools/.autorefresh.env
PLIST="$HOME/Library/LaunchAgents/com.yamusek.refresh.plist"
mkdir -p "$(dirname "$PLIST")"
cat > "$PLIST" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>com.yamusek.refresh</string>
<key>ProgramArguments</key>
<array>
<string>$REPO/tools/auto-refresh.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key><integer>4</integer>
<key>Minute</key><integer>30</integer>
</dict>
<key>RunAtLoad</key><false/>
<key>StandardOutPath</key><string>${TMPDIR:-/tmp}/yamusek-autorefresh.out</string>
<key>StandardErrorPath</key><string>${TMPDIR:-/tmp}/yamusek-autorefresh.err</string>
</dict>
</plist>
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"