Skip to content

Commit badfd6c

Browse files
Merge pull request #50 from smartwatermelon/transmission-done
Transmission done
2 parents 54fa6fd + 264434c commit badfd6c

File tree

8 files changed

+67
-29
lines changed

8 files changed

+67
-29
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ config/config.conf
6565
local_config.yaml
6666
user_settings.yaml
6767

68-
# Reference hardlinks
69-
config/config.conf.template.txt
70-
scripts/dock-cleanup.command.txt
71-
config/config.conf.txt
68+
# User-modified scripts
69+
app-setup/templates/transmission-done.sh
7270

7371
# Claude Code runtime files
7472
.claude/
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
#
3+
# transmission-done.sh - Transmission completion script
4+
# Called when a torrent finishes downloading
5+
#
6+
# Environment variables provided by Transmission:
7+
# TR_APP_VERSION, TR_TIME_LOCALTIME, TR_TORRENT_DIR, TR_TORRENT_HASH,
8+
# TR_TORRENT_ID, TR_TORRENT_NAME
9+
10+
# Log completion
11+
LOG_FILE="${HOME}/.local/state/transmission-completion.log"
12+
mkdir -p "$(dirname "${LOG_FILE}")"
13+
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
14+
echo "${timestamp} - Torrent completed: ${TR_TORRENT_NAME:-unknown}" >>"${LOG_FILE}"
15+
16+
# Future: FileBot integration will be added here
17+
# filebot -rename "${TR_TORRENT_DIR}/${TR_TORRENT_NAME}" --output /path/to/media/library
18+
19+
exit 0

app-setup/transmission-setup.sh

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -316,30 +316,12 @@ log "✅ Magnet link handler configuration completed successfully"
316316
# Create completion script (for FileBot integration later)
317317
section "Creating Completion Script"
318318

319-
log "Creating transmission-done.sh completion script..."
319+
log "Copying transmission-done.sh completion script from template..."
320320
OPERATOR_LOCAL_BIN="$(dirname "${TRANSMISSION_DONE_SCRIPT}")"
321-
mkdir -p "${OPERATOR_LOCAL_BIN}"
322-
sudo -iu "${OPERATOR_USERNAME}" tee "${TRANSMISSION_DONE_SCRIPT}" >/dev/null <<'EOF'
323-
#!/usr/bin/env bash
324-
#
325-
# transmission-done.sh - Transmission completion script
326-
# Called when a torrent finishes downloading
327-
#
328-
# Environment variables provided by Transmission:
329-
# TR_APP_VERSION, TR_TIME_LOCALTIME, TR_TORRENT_DIR, TR_TORRENT_HASH,
330-
# TR_TORRENT_ID, TR_TORRENT_NAME
331-
332-
# Log completion
333-
LOG_FILE="${HOME}/.local/state/transmission-completion.log"
334-
mkdir -p "$(dirname "${LOG_FILE}")"
335-
echo "$(date '+%Y-%m-%d %H:%M:%S') - Torrent completed: ${TR_TORRENT_NAME:-unknown}" >> "${LOG_FILE}"
336-
337-
# Future: FileBot integration will be added here
338-
# filebot -rename "${TR_TORRENT_DIR}/${TR_TORRENT_NAME}" --output /path/to/media/library
339-
340-
exit 0
341-
EOF
321+
sudo mkdir -p "${OPERATOR_LOCAL_BIN}"
342322

323+
# Copy template script to destination
324+
sudo cp "${SCRIPT_DIR}/templates/transmission-done.sh" "${TRANSMISSION_DONE_SCRIPT}"
343325
sudo chmod +x "${TRANSMISSION_DONE_SCRIPT}"
344326
sudo chown -v "${OPERATOR_USERNAME}" "${TRANSMISSION_DONE_SCRIPT}"
345327
log "✅ Completion script creation completed successfully"

docs/apps/transmission-setup-README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,41 @@ defaults read com.apple.LaunchServices/com.apple.launchservices.secure LSHandler
169169
- **FileBot**: Completion script prepared for media processing integration
170170
- **Plex**: Downloads organized for media library integration
171171

172+
### User Customization
173+
174+
#### **Custom Completion Scripts**
175+
176+
The setup creates a default `transmission-done.sh` completion script that logs torrent completion. Users can customize this behavior:
177+
178+
1. **Before Setup**: Create your own `app-setup/templates/transmission-done.sh` script
179+
- The setup will use your custom script instead of the default template
180+
- Your script will be preserved across repository updates (gitignored)
181+
182+
2. **After Setup**: Modify the deployed script directly
183+
- Location: `~/.local/bin/transmission-done.sh` (on the server)
184+
- Changes take effect for new torrent completions
185+
- Script runs with full user environment and Transmission variables
186+
187+
**Available Environment Variables**:
188+
189+
```bash
190+
TR_APP_VERSION # Transmission version
191+
TR_TIME_LOCALTIME # Completion timestamp
192+
TR_TORRENT_DIR # Download directory path
193+
TR_TORRENT_HASH # Torrent hash identifier
194+
TR_TORRENT_ID # Transmission internal ID
195+
TR_TORRENT_NAME # Torrent display name
196+
```
197+
198+
**Common Customizations**:
199+
200+
- FileBot automatic processing
201+
- Email/notification integration
202+
- Cloud sync triggers
203+
- Custom file organization
204+
- Statistics logging
205+
- Integration with external APIs
206+
172207
## Research and Development
173208

174209
### Preference Key Research

prep-airdrop.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,9 +746,13 @@ if [[ -d "${SCRIPT_SOURCE_DIR}" ]]; then
746746
done
747747

748748
# Copy template scripts to app-setup/templates
749-
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"
750-
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"
751-
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"
749+
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"
750+
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"
751+
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"
752+
if [[ ! -f "${SCRIPT_SOURCE_DIR}/app-setup/templates/transmission-done.sh" ]]; then
753+
cp "${SCRIPT_SOURCE_DIR}/app-setup/templates/transmission-done-template.sh" "${SCRIPT_SOURCE_DIR}/app-setup/templates/transmission-done.sh"
754+
fi
755+
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"
752756

753757
# Copy app setup scripts to app-setup directory
754758
echo "Copying app setup scripts..."

0 commit comments

Comments
 (0)