Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
19 changes: 19 additions & 0 deletions app-setup/templates/transmission-done-template.sh
Original file line number Diff line number Diff line change
@@ -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
26 changes: 4 additions & 22 deletions app-setup/transmission-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
35 changes: 35 additions & 0 deletions docs/apps/transmission-setup-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions prep-airdrop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down