Last active
November 8, 2020 05:14
-
-
Save jfeilbach/23b60b16c3c209a3b11f731e074bf24f to your computer and use it in GitHub Desktop.
during migration put on cron job to start torrents added to transmission
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
#!/bin/bash | |
NC='\033[0m' # No color | |
Green='\033[0;32m' # Green | |
White='\033[0;37m' # White | |
Red='\033[0;31m' # Red | |
Yellow='\033[0;33m' # Yellow | |
counter='1' | |
cmd=/usr/bin/transmission-remote | |
count=$(${cmd} -l | grep 'Stopped' | wc -l) | |
check=$(${cmd} -l | grep 'Stopped' | awk '{ ORS=" " } ; { print $1 }') | |
if [[ "${count}" = 0 ]]; then | |
echo -e "\n${Yellow}Found ${NC}${White}${count}${NC}${Yellow} torrents ready to be started. Exiting.${NC}\n" | |
/bin/date | |
exit 1 | |
else | |
echo -e "\n${Green}Found ${NC}${White}${count}${NC}${Green} torrents ready to be started...${NC}\n" | |
fi | |
echo -e "\n${Yellow}Found ${NC}${White}${count}${NC}${Yellow} torrents ready to be started...${NC}\n" | |
for x in ${check} ; do | |
status=$(${cmd} -t ${x} -i | grep 'Percent Done: ' | awk '{ print $3 }') | |
name=$(${cmd} -t ${x} -i | grep 'Name: '| head -n 1 | sed 's/.*\:\ //' ) | |
if [[ "${status}" != "100%" ]] ; then | |
echo -e "\n${Red}Warning torrent ${NC}${White}${x}${NC}${Red} not 100% downloaded. Will not start.${NC}\n" | |
echo -e "${Red}Please verify ${White}${name}${NC}\n" | |
break | |
else | |
echo -e "${Green}Torrent ${White}${x}${NC}${Green} is 100% downloaded. Ready to start.${NC}" | |
fi | |
echo -e "Starting torrent ${White}${name}${NC}" | |
${cmd} -t ${x} --start | |
echo -e "Started ${White}${counter}${NC} of ${White}${count}${NC}\n" | |
((counter ++)) | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
step 3 of 3 for migration