Created
February 5, 2019 07:59
-
-
Save demonbane/7c227c6a696229a68c6f098fe7e91b5d to your computer and use it in GitHub Desktop.
Delete directory after Radarr import
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 characters
#!/usr/bin/env bash | |
# log all output from here on out to a log file. Comment this line out if testing from command-line | |
exec >> /path/to/store/log-file | |
printf '\nclean-radarr-import.sh called at %b\n\n' "$(date)" | |
# For debugging, print every radarr environment variable passed to the script | |
# if you don't want it, just delete these 3 lines | |
for i in ${!radarr*}; do | |
printf '%b="%b"\n' "$i" "${!i}" | |
done | |
if [ "${radarr_eventtype}" = "Download" ]; then | |
printf 'Processing "%b"...\n' "${radarr_moviefile_sourcefolder}" | |
# no rush, make sure there's plenty of time for any Radarr actions to finish | |
sleep 10 | |
if [ -d "${radarr_moviefile_sourcefolder}" -a ! -f "${radarr_moviefile_sourcepath}" ]; then | |
printf 'Removing "%b"... ' "${radarr_moviefile_sourcefolder}" | |
rm -rv "${radarr_moviefile_sourcefolder}" | |
else | |
printf 'Tests failed\n' | |
ls -alh "${radarr_moviefile_sourcefolder}" | |
fi | |
fi | |
printf '=%.0s' {1..45} | |
printf '\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment