From f8e2d6253f0e5624385ab161a194998d4c4c2deb Mon Sep 17 00:00:00 2001 From: a10kiloham <295361+a10kiloham@users.noreply.github.com> Date: Tue, 28 Apr 2020 08:17:06 +0100 Subject: [PATCH] Created Reverse symlink script for Connect (markdown) --- Reverse-symlink-script-for-Connect.md | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Reverse-symlink-script-for-Connect.md 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