forked from StratoSource/StratoSource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cronjob.sh
executable file
·56 lines (40 loc) · 1.27 KB
/
cronjob.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
#
# Script invoked by cron to process a snapshot
# arg1 is the repo name
# arg2 is the branch name
#
LOG_NAME=/tmp/$1_$2_$(date +%Y%M%d%H%M%S)_pull.log
BASEDIR=$(dirname $0)
REPO=$1
BRANCH=$2
# Execute function error() receiving ERROR or TERM signal
#
trap onexit INT ERR
function onexit()
{
cd $BASEDIR/stratosource >>$LOG_NAME 2>&1
local exit_status=${1:-$?}
echo Exiting with status $exit_status
if [ $exit_status -eq "99" ]
then
python manage.py storelog $REPO $BRANCH $LOG_NAME d
exit 0
fi
python manage.py storelog $REPO $BRANCH $LOG_NAME e
exit $exit_status
}
echo Starting Snapshot of $REPO $BRANCH >>$LOG_NAME 2>&1
cd $BASEDIR >>$LOG_NAME 2>&1
./pre-cronjob.sh $REPO $BRANCH >>$LOG_NAME 2>&1
cd $BASEDIR/stratosource >>$LOG_NAME 2>&1
python manage.py storelog $REPO $BRANCH $LOG_NAME r
python manage.py download $REPO $BRANCH >>$LOG_NAME 2>&1
python manage.py storelog $REPO $BRANCH $LOG_NAME r
python manage.py commit $REPO $BRANCH >>$LOG_NAME 2>&1
python manage.py storelog $REPO $BRANCH $LOG_NAME r
python manage.py sfdiff $REPO $BRANCH >>$LOG_NAME 2>&1
python manage.py storelog $REPO $BRANCH $LOG_NAME r
cd $BASEDIR >>$LOG_NAME 2>&1
./post-cronjob.sh $REPO $BRANCH >>$LOG_NAME 2>&1
onexit 99