I have a bash script. I need a modification for safety.
my original bash script:
mv /home/script/backup /home/script/backup2
mysql -u user -ppassword -Ddatabase --batch --skip-column-names -e 'select id, url from videos where url like "%http%" limit 1' |
while read id url
do youtube-dl -o "/home/script/uploads/$id.mp4" -f 18/17/22/mp4 "$url"
done
mysql -u user -ppassword -Ddatabase -e "UPDATE videos SET url=CONCAT(id,'.mp4') WHERE url LIKE '%http%' limit 1" ;
mysql -u user -ppassword -Ddatabase -e "UPDATE videos SET source_id='1' WHERE source_id in (3) limit 1";
mv /home/script/backup2 /home/script/backup
exit
I need this bash script:
mv /home/script/backup /home/script/backup2
mysql -u user -ppassword -Ddatabase --batch --skip-column-names -e 'select id, url from videos where url like "%http%" limit 1' |
while read id url
do youtube-dl -o "/home/script/uploads/$id.mp4" -f 18/17/22/mp4 "$url"
done
here: I want to check the file size. if it is greater than 10 KB I want to run the following all commands.
mysql -u user -ppassword -Ddatabase -e "UPDATE videos SET url=CONCAT(id,'.mp4') WHERE url LIKE '%http%' limit 1" ;
mysql -u user -ppassword -Ddatabase -e "UPDATE videos SET source_id='1' WHERE source_id in (3) limit 1";
mv /home/script/backup2 /home/script/backup
exit
If less than 10 KB or not found a file, I want to run only this command.
mv /home/script/backup2 /home/script/backup
exit