ComicRack_Scripts/Update Missing/update.sh

43 lines
1.0 KiB
Bash
Raw Normal View History

2022-07-08 10:29:37 +02:00
#!/bin/bash
2022-07-08 11:22:30 +02:00
2022-07-15 09:53:26 +02:00
d=`date +%Y%m%d`
2022-07-08 11:22:30 +02:00
2022-07-15 10:43:24 +02:00
prj_root=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$prj_root"
2022-07-15 09:53:26 +02:00
log2file() {
2022-07-15 10:43:24 +02:00
echo "sh: $1" >> "$prj_root/log/$d.log"
2022-07-15 09:53:26 +02:00
}
2022-07-08 10:29:37 +02:00
2022-07-15 09:53:26 +02:00
error_exit() {
log2file "Error: $1"
exit 1
}
2022-07-12 12:07:49 +02:00
2022-07-15 10:43:24 +02:00
touch "$prj_root/log/$d.log"
echo "log: $d" >> "$prj_root/log/$d.log"
2022-07-08 10:29:37 +02:00
2022-07-15 09:53:26 +02:00
log2file "Starting update.sh"
fromdate=$(ls -1 *_latest.mcl |grep -Eo '[[:digit:]]{8}') || error_exit "cannot latest mcl file"
2022-07-08 10:29:37 +02:00
2022-07-15 10:43:24 +02:00
echo $fromdate
2022-07-15 09:21:05 +02:00
python2 update_missing.py
2022-07-08 10:38:46 +02:00
2022-07-15 10:02:14 +02:00
log2file "Moving old file to archive"
2022-07-15 10:43:24 +02:00
mv "$prj_root/$fromdate""_latest.mcl" "$prj_root/archive/""$fromdate"".mcl" || error_exit "cannot mv to archive"
2022-07-15 09:21:05 +02:00
2022-07-15 10:02:14 +02:00
log2file "git add"
2022-07-31 12:47:14 +02:00
git add "*_latest.mcl" "Deleted_Comics.txt" "archive/*" "log/*" >> "log/$d.log" || error_exit "cannot git add"
2022-07-15 09:56:22 +02:00
2022-07-15 10:43:24 +02:00
#log2file "git rm"
#git rm "$fromdate""_latest.mcl" >> "log/$d.log" || error_exit "cannot git rm"
2022-07-15 09:21:05 +02:00
2022-07-15 10:02:14 +02:00
log2file "git commit"
2022-07-15 09:53:26 +02:00
git commit -m "Updated $d" >> "log/$d.log" || error_exit "cannot git commit"
2022-07-15 09:21:05 +02:00
2022-07-15 10:02:14 +02:00
log2file "git push"
2022-07-15 09:53:26 +02:00
git push origin master >> "log/$d.log" || error_exit "cannot git push"
2022-07-08 10:29:37 +02:00