diff --git a/README.md b/README.md index fba6b81..501f691 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ In `AUTOCONFIG` mode (default), the only manual manipulation you'll only have to - Deemix as an indexer - Deemix as a download client - Flac2Custom script connection if `FLAC2CUSTOM_ARGS` is set + - clean-downloads script connection to keep your downloads folder *clean* after each imports In case you don't want the automagical part (which is really the only value of this image), just set `AUTOCONFIG` environment variable to `false`. diff --git a/root/etc/services.d/setup/run b/root/etc/services.d/setup/run index 63d3d10..00cbefd 100644 --- a/root/etc/services.d/setup/run +++ b/root/etc/services.d/setup/run @@ -98,7 +98,21 @@ if [ "$AUTOCONFIG" = "true" ]; then echo "[autoconfig] FLAC2CUSTOM_ARGS is set" if ! isPresent "flac2" "notification"; then echo "[autoconfig] Configuring flac2custom.sh custom script" - apiCall "POST" "notification" '{"onGrab":false,"onReleaseImport":true,"onUpgrade":true,"onRename":false,"onHealthIssue":false,"onDownloadFailure":false,"onImportFailure":false,"onTrackRetag":false,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnReleaseImport":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnHealthIssue":true,"includeHealthWarnings":false,"supportsOnDownloadFailure":false,"supportsOnImportFailure":false,"supportsOnTrackRetag":true,"supportsOnApplicationUpdate":true,"name":"Flac2Custom","fields":[{"name":"path","value":"/usr/local/bin/flac2custom.sh"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#customscript","message":{"message":"Testing will execute the script with the EventType set to Test, ensure your script handles this correctly","type":"warning"},"tags":[]}' + apiCall "POST" "notification" '{"onGrab":false,"onReleaseImport":true,"onUpgrade":true,"onRename":false,"onHealthIssue":false,"onDownloadFailure":false,"onImportFailure":false,"onTrackRetag":false,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnReleaseImport":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnHealthIssue":true,"includeHealthWarnings":false,"supportsOnDownloadFailure":false,"supportsOnImportFailure":false,"supportsOnTrackRetag":true,"supportsOnApplicationUpdate":true,"name":"Flac2Custom","fields":[{"name":"path","value":"/usr/local/bin/flac2custom.sh"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"","message":{"message":"","type":"warning"},"tags":[]}' fi fi fi + +echo " +---------------------------------------------------------------------- +Utilities SETUP +---------------------------------------------------------------------- +AUTOCONFIG=$AUTOCONFIG +---------------------------------------------------------------------- +" +if [ "$AUTOCONFIG" = "true" ]; then + if ! isPresent "Clean Downloads" "notification"; then + echo "[autoconfig] Configuring flac2custom.sh custom script" + apiCall "POST" "notification" '{"onGrab":false,"onReleaseImport":true,"onUpgrade":true,"onRename":false,"onHealthIssue":false,"onDownloadFailure":false,"onImportFailure":false,"onTrackRetag":false,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnReleaseImport":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnHealthIssue":true,"includeHealthWarnings":false,"supportsOnDownloadFailure":false,"supportsOnImportFailure":false,"supportsOnTrackRetag":true,"supportsOnApplicationUpdate":true,"name":"Clean Downloads","fields":[{"name":"path","value":"/usr/local/bin/clean-downloads.sh"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"","message":{"message":"","type":"warning"},"tags":[]}' + fi +fi diff --git a/root/usr/local/bin/clean-downloads.sh b/root/usr/local/bin/clean-downloads.sh new file mode 100644 index 0000000..d058e2d --- /dev/null +++ b/root/usr/local/bin/clean-downloads.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +echo "Info|Lidarr event: $lidarr_eventtype" >&2 + +# Handle Lidarr Test event +if [[ "$lidarr_eventtype" = "Test" ]]; then + echo "Info|Script was test executed successfully." >&2 + exit 0 +fi + +echo "Info|Cleaning empty folders" >&2 +find /downloads -type d -empty -print -delete >&2