From 7d780de91688cc78a07ffd695f9cefcc752aeaf1 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Tue, 6 Sep 2022 09:43:13 -0400 Subject: [PATCH] 1.0.002 - Add Extras.bash post processing script! --- root/scripts/AutoConfig.bash | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/root/scripts/AutoConfig.bash b/root/scripts/AutoConfig.bash index 8cc0560..3b793cb 100644 --- a/root/scripts/AutoConfig.bash +++ b/root/scripts/AutoConfig.bash @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.001" +scriptVersion="1.0.002" if [ -z "$arrUrl" ] || [ -z "$arrApiKey" ]; then arrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" @@ -102,4 +102,16 @@ else log "Complete" fi +if curl -s "$arrUrl/api/v3/notification" -H "X-Api-Key: ${arrApiKey}" | jq -r .[].name | grep "Extras.bash" | read; then + log "Extras.bash already added to Sonarr custom scripts" +else + log "Adding Extras.bash to Sonarr custom scripts" + # Send a command to check file path, to prevent error with adding... + updateArr=$(curl -s "$arrUrl/api/v3/filesystem?path=%2Fconfig%2Fextended%2Fscripts%2FExtras.bash&allowFoldersWithoutTrailingSlashes=true&includeFiles=true" -H "X-Api-Key: ${arrApiKey}") + + # Add Extras.bash + updateArr=$(curl -s "$arrUrl/api/v3/notification?" -X POST -H "Content-Type: application/json" -H "X-Api-Key: ${arrApiKey}" --data-raw '{"onGrab":false,"onDownload":true,"onUpgrade":true,"onRename":true,"onSeriesDelete":true,"onEpisodeFileDelete":true,"onEpisodeFileDeleteForUpgrade":true,"onHealthIssue":false,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnDownload":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnSeriesDelete":true,"supportsOnEpisodeFileDelete":true,"supportsOnEpisodeFileDeleteForUpgrade":true,"supportsOnHealthIssue":true,"supportsOnApplicationUpdate":true,"includeHealthWarnings":false,"name":"Extras.bash","fields":[{"name":"path","value":"/config/extended/scripts/Extras.bash"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"https://wiki.servarr.com/sonarr/supported#customscript","message":{"message":"Testing will execute the script with the EventType set to Test, ensure your script handles this correctly","type":"warning"},"tags":[]}') + log "Complete" +fi + exit