Created
September 3, 2021 00:36
-
-
Save xgroleau/a671b67ad735fff934f3e4c91b786dc3 to your computer and use it in GitHub Desktop.
Revisions
-
xgroleau created this gist
Sep 3, 2021 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ #!/bin/bash # see https://github.com/Sonarr/Sonarr/issues/967#issuecomment-228599877 EVENT_TYPE="$radarr_eventtype" LOGFILE="/config/logs/radarr-symlink.log" ERROR_LOGFILE="/config/logs/radarr-symlink.error.log" PERMPATH="$radarr_moviefile_path" LINKPATH="$radarr_moviefile_sourcepath" main() { if [[ $EVENT_TYPE == "Test" ]]; then echo "Test event, exiting" exit 0; fi if [ -f "$LINKPATH" ]; then echo "Normal Queued Import Invoked, Continuing Script" else echo "Manual Import Invoked, Exiting Script" exit 1 fi # Check for usenet USENET_PATH="nzbget" if [[ $SOURCEPATH = *$USENET_PATH* ]]; then echo "Import ignored, since it's a usenet import" exit 1; fi echo "PERMPATH: $PERMPATH" echo "SOURCEPATH: $SOURCEPATH" ORIGFILESIZE=$(stat -c%s "$LINKPATH") PERMFILESIZE=$(stat -c%s "$PERMPATH") echo "Sleep for 30 seconds" sleep 30 echo "Checking if Radarr is still copying the file" while [ $PERMFILESIZE != $ORIGFILESIZE ] do echo "Radarr is still copying the file, wait for 1 minute and try again" sleep 60 PERMFILESIZE=$(stat -c%s "$PERMPATH") done echo "Entering Final File Size Check Phase" if [ $PERMFILESIZE == $ORIGFILESIZE ] then echo "Removing File" rm "$LINKPATH" echo "Creating symlink" ln -s "$PERMPATH" "$LINKPATH" fi echo "Created symlink from source location: $PERMPATH to symlink location $LINKPATH" } main > $LOGFILE 2> $ERROR_LOGFILE