diff --git a/Reverse-symlink-script-for-Connect.md b/Reverse-symlink-script-for-Connect.md new file mode 100644 index 0000000..29f106e --- /dev/null +++ b/Reverse-symlink-script-for-Connect.md @@ -0,0 +1,41 @@ +Slightly updated from the Radarr version this works well if you wish to keep seeding torrents however archive them on a device across the network like a NAS. +Copy this to a folder reachable in your Docker config if necessary (i.e., create a config/connect folder) name whatever you like and ensure you chmod 777 so no issues running. +For those running with combined Torrent and Usenet downloaders it's helpful to create a 'torrent' tag for this script and also shows that are torrent eligible - this works for more obscure shows where you'd wan to minimize torrent use. + +``` +#!/bin/bash + +PERMPATH="$sonarr_episodefile_path" +LINKPATH="$sonarr_episodefile_sourcepath" + +if [[ -f "$LINKPATH" ]]; then + sleep 1 +else + exit 0 + # changed from Radarr as Sonarr fails on test unless exit normally +fi + +ORIGFILESIZE=$(stat -c%s "$LINKPATH") +PERMFILESIZE=$(stat -c%s "$PERMPATH") + +sleep 30 + +while [[ $PERMFILESIZE != $ORIGFILESIZE ]]; do + sleep 60 + PERMFILESIZE=$(stat -c%s "$PERMPATH") +done + +if [[ $PERMFILESIZE == $ORIGFILESIZE ]]; then + # Save current time stamps to prevent radarr from identifying our simlink as new, and double-processing it + LINKDIR=$(dirname "$LINKPATH") + FOLDER_DATE=$(date -r "$LINKDIR" +@%s.%N) + FILE_DATE=$(date -r "$LINKPATH" +@%s.%N) + + rm "$LINKPATH" + ln -s "$PERMPATH" "$LINKPATH" + + touch --no-create --no-dereference --date "$FILE_DATE" "$LINKPATH" + touch --no-create --no-dereference --date "$FILE_DATE" "$PERMPATH" + touch --no-create --no-dereference --date "$FOLDER_DATE" "$LINKDIR" +fi +``` \ No newline at end of file