ComicRack_Scripts/Update Missing/update.sh
Frederik Baerentsen e677381d10 updated bash
2022-07-15 09:56:22 +02:00

36 lines
833 B
Bash

#!/bin/bash
d=`date +%Y%m%d`
log2file() {
echo "sh: $1" >> "log/$d.log"
}
error_exit() {
log2file "Error: $1"
exit 1
}
touch "log/$d.log"
echo "log: $d" >> "log/$d.log"
log2file "Starting update.sh"
fromdate=$(ls -1 *_latest.mcl |grep -Eo '[[:digit:]]{8}') || error_exit "cannot latest mcl file"
python2 update_missing.py
#mv "$d"".mcl" "$d""_latest.mcl" || error_exit "cannot cp $d to latest"
mv "$fromdate""_latest.mcl" "archive/""$fromdate"".mcl" || error_exit "cannot mv to archive"
git add "$d""_latest.mcl" "archive/" "log/" >> "log/$d.log" || error_exit "cannot git add"
git rm "$fromdate""_latest.mcl" >> "log/$d.log" || error_exit "cannot git rm"
git commit -m "Updated $d" >> "log/$d.log" || error_exit "cannot git commit"
git push origin master >> "log/$d.log" || error_exit "cannot git push"