diff --git a/.gitignore b/.gitignore index 924a8d8..d4c5b38 100644 --- a/.gitignore +++ b/.gitignore @@ -65,10 +65,8 @@ config/config.conf local_config.yaml user_settings.yaml -# Reference hardlinks -config/config.conf.template.txt -scripts/dock-cleanup.command.txt -config/config.conf.txt +# User-modified scripts +app-setup/templates/transmission-done.sh # Claude Code runtime files .claude/ diff --git a/app-setup/app-setup-templates/mount-nas-media.sh b/app-setup/templates/mount-nas-media.sh similarity index 100% rename from app-setup/app-setup-templates/mount-nas-media.sh rename to app-setup/templates/mount-nas-media.sh diff --git a/app-setup/app-setup-templates/start-plex.sh b/app-setup/templates/start-plex.sh similarity index 100% rename from app-setup/app-setup-templates/start-plex.sh rename to app-setup/templates/start-plex.sh diff --git a/app-setup/app-setup-templates/start-rclone.sh b/app-setup/templates/start-rclone.sh similarity index 100% rename from app-setup/app-setup-templates/start-rclone.sh rename to app-setup/templates/start-rclone.sh diff --git a/app-setup/templates/transmission-done-template.sh b/app-setup/templates/transmission-done-template.sh new file mode 100755 index 0000000..8b13435 --- /dev/null +++ b/app-setup/templates/transmission-done-template.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# transmission-done.sh - Transmission completion script +# Called when a torrent finishes downloading +# +# Environment variables provided by Transmission: +# TR_APP_VERSION, TR_TIME_LOCALTIME, TR_TORRENT_DIR, TR_TORRENT_HASH, +# TR_TORRENT_ID, TR_TORRENT_NAME + +# Log completion +LOG_FILE="${HOME}/.local/state/transmission-completion.log" +mkdir -p "$(dirname "${LOG_FILE}")" +timestamp=$(date '+%Y-%m-%d %H:%M:%S') +echo "${timestamp} - Torrent completed: ${TR_TORRENT_NAME:-unknown}" >>"${LOG_FILE}" + +# Future: FileBot integration will be added here +# filebot -rename "${TR_TORRENT_DIR}/${TR_TORRENT_NAME}" --output /path/to/media/library + +exit 0 diff --git a/app-setup/transmission-setup.sh b/app-setup/transmission-setup.sh index 806059d..5ae3e0c 100755 --- a/app-setup/transmission-setup.sh +++ b/app-setup/transmission-setup.sh @@ -316,30 +316,12 @@ log "✅ Magnet link handler configuration completed successfully" # Create completion script (for FileBot integration later) section "Creating Completion Script" -log "Creating transmission-done.sh completion script..." +log "Copying transmission-done.sh completion script from template..." OPERATOR_LOCAL_BIN="$(dirname "${TRANSMISSION_DONE_SCRIPT}")" -mkdir -p "${OPERATOR_LOCAL_BIN}" -sudo -iu "${OPERATOR_USERNAME}" tee "${TRANSMISSION_DONE_SCRIPT}" >/dev/null <<'EOF' -#!/usr/bin/env bash -# -# transmission-done.sh - Transmission completion script -# Called when a torrent finishes downloading -# -# Environment variables provided by Transmission: -# TR_APP_VERSION, TR_TIME_LOCALTIME, TR_TORRENT_DIR, TR_TORRENT_HASH, -# TR_TORRENT_ID, TR_TORRENT_NAME - -# Log completion -LOG_FILE="${HOME}/.local/state/transmission-completion.log" -mkdir -p "$(dirname "${LOG_FILE}")" -echo "$(date '+%Y-%m-%d %H:%M:%S') - Torrent completed: ${TR_TORRENT_NAME:-unknown}" >> "${LOG_FILE}" - -# Future: FileBot integration will be added here -# filebot -rename "${TR_TORRENT_DIR}/${TR_TORRENT_NAME}" --output /path/to/media/library - -exit 0 -EOF +sudo mkdir -p "${OPERATOR_LOCAL_BIN}" +# Copy template script to destination +sudo cp "${SCRIPT_DIR}/templates/transmission-done.sh" "${TRANSMISSION_DONE_SCRIPT}" sudo chmod +x "${TRANSMISSION_DONE_SCRIPT}" sudo chown -v "${OPERATOR_USERNAME}" "${TRANSMISSION_DONE_SCRIPT}" log "✅ Completion script creation completed successfully" diff --git a/docs/apps/transmission-setup-README.md b/docs/apps/transmission-setup-README.md index f61c850..8406606 100644 --- a/docs/apps/transmission-setup-README.md +++ b/docs/apps/transmission-setup-README.md @@ -169,6 +169,41 @@ defaults read com.apple.LaunchServices/com.apple.launchservices.secure LSHandler - **FileBot**: Completion script prepared for media processing integration - **Plex**: Downloads organized for media library integration +### User Customization + +#### **Custom Completion Scripts** + +The setup creates a default `transmission-done.sh` completion script that logs torrent completion. Users can customize this behavior: + +1. **Before Setup**: Create your own `app-setup/templates/transmission-done.sh` script + - The setup will use your custom script instead of the default template + - Your script will be preserved across repository updates (gitignored) + +2. **After Setup**: Modify the deployed script directly + - Location: `~/.local/bin/transmission-done.sh` (on the server) + - Changes take effect for new torrent completions + - Script runs with full user environment and Transmission variables + +**Available Environment Variables**: + +```bash +TR_APP_VERSION # Transmission version +TR_TIME_LOCALTIME # Completion timestamp +TR_TORRENT_DIR # Download directory path +TR_TORRENT_HASH # Torrent hash identifier +TR_TORRENT_ID # Transmission internal ID +TR_TORRENT_NAME # Torrent display name +``` + +**Common Customizations**: + +- FileBot automatic processing +- Email/notification integration +- Cloud sync triggers +- Custom file organization +- Statistics logging +- Integration with external APIs + ## Research and Development ### Preference Key Research diff --git a/prep-airdrop.sh b/prep-airdrop.sh index e25fbbe..3b69950 100755 --- a/prep-airdrop.sh +++ b/prep-airdrop.sh @@ -746,9 +746,13 @@ if [[ -d "${SCRIPT_SOURCE_DIR}" ]]; then done # Copy template scripts to app-setup/templates - copy_with_manifest "${SCRIPT_SOURCE_DIR}/app-setup/app-setup-templates/mount-nas-media.sh" "app-setup/templates/mount-nas-media.sh" "REQUIRED" || echo "Warning: mount-nas-media.sh not found in app-setup-templates directory" - copy_with_manifest "${SCRIPT_SOURCE_DIR}/app-setup/app-setup-templates/start-plex.sh" "app-setup/templates/start-plex.sh" "OPTIONAL" || echo "Warning: start-plex.sh not found in app-setup-templates directory" - copy_with_manifest "${SCRIPT_SOURCE_DIR}/app-setup/app-setup-templates/start-rclone.sh" "app-setup/templates/start-rclone.sh" "REQUIRED" || echo "Warning: start-rclone.sh not found in app-setup-templates directory" + copy_with_manifest "${SCRIPT_SOURCE_DIR}/app-setup/templates/mount-nas-media.sh" "app-setup/templates/mount-nas-media.sh" "REQUIRED" || echo "Warning: mount-nas-media.sh not found in templates directory" + copy_with_manifest "${SCRIPT_SOURCE_DIR}/app-setup/templates/start-plex.sh" "app-setup/templates/start-plex.sh" "OPTIONAL" || echo "Warning: start-plex.sh not found in templates directory" + copy_with_manifest "${SCRIPT_SOURCE_DIR}/app-setup/templates/start-rclone.sh" "app-setup/templates/start-rclone.sh" "REQUIRED" || echo "Warning: start-rclone.sh not found in templates directory" + if [[ ! -f "${SCRIPT_SOURCE_DIR}/app-setup/templates/transmission-done.sh" ]]; then + cp "${SCRIPT_SOURCE_DIR}/app-setup/templates/transmission-done-template.sh" "${SCRIPT_SOURCE_DIR}/app-setup/templates/transmission-done.sh" + fi + copy_with_manifest "${SCRIPT_SOURCE_DIR}/app-setup/templates/transmission-done.sh" "app-setup/templates/transmission-done.sh" "OPTIONAL" || echo "Warning: transmission-done.sh not found in templates directory" # Copy app setup scripts to app-setup directory echo "Copying app setup scripts..."