Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Commit

Permalink
Add script for updating timetables from crontab
Browse files Browse the repository at this point in the history
  • Loading branch information
davidschlachter committed May 13, 2020
1 parent be293a1 commit e38e43f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions course-download/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/local/bin/bash

sleep 10

if pgrep -q chrom; then
echo "$(date): chrome is already running - exiting update.sh"
exit 1
fi

export MM_CHARSET=UTF-8
export LC_COLLATE=C
export LANG=en_US.UTF-8
export PYTHONIOENCODING=utf8

cd /home/selenium/schedule-generator/course-download && /usr/local/bin/git pull >> /home/selenium/timetables-updater.log 2>&1
mv db_activities.csv db_activities.csv.old ; mv db_courses.csv db_courses.csv.old ; mv db_sections.csv db_sections.csv.old

/usr/local/bin/python2.7 updateDatabase.py -v >> /home/selenium/timetables-updater.log 2>&1

if [ $? -eq 0 ]; then
rm *.old
/bin/rm -f /home/selenium/schedgen/latest.tar.gz /home/selenium/schedgen/archive/courses-`/bin/date +%F`.tar.gz
/usr/bin/tar -czf /home/selenium/schedgen/archive/courses-`/bin/date +%F`.tar.gz *.csv
/bin/cp /home/selenium/schedgen/archive/courses-`date +%F`.tar.gz /home/selenium/schedgen/latest.tar.gz
else
/bin/echo "Update on `/bin/date` failed" >> /home/selenium/timetables-updater.log
mv db_activities.csv.old db_activities.csv ; mv db_courses.csv.old db_courses.csv ; mv db_sections.csv.old db_sections.csv
fi

0 comments on commit e38e43f

Please sign in to comment.