Begin watching git's status too, not just the grep status of not already being up to date. Add more conditional branches so that errors are logged properly.
This commit is contained in:
20
cronjob.sh
20
cronjob.sh
@@ -27,14 +27,24 @@ function reload-project {
|
|||||||
## Main ##
|
## Main ##
|
||||||
|
|
||||||
# Pull any updates, and if the project is already up to date, exit successfully.
|
# Pull any updates, and if the project is already up to date, exit successfully.
|
||||||
git pull | grep -v "up to date"
|
output="`git pull`"
|
||||||
status="$?"
|
git_status="$?"
|
||||||
log "Pull status is '$status'."
|
|
||||||
if [[ $status != 0 ]]; then
|
echo "$output" | grep -v "up to date"
|
||||||
|
grep_status="$?"
|
||||||
|
|
||||||
|
log "Pull status is '$git_status', anything but 'up to date' is '$grep_status'."
|
||||||
|
|
||||||
|
if [[ $git_status != 0 ]]; then
|
||||||
|
log "*** ERROR: Git reported a failure! ***"
|
||||||
|
exit 1
|
||||||
|
elif [[ $git_status == 0 && $grep_status == 0 ]]; then
|
||||||
|
reload-project
|
||||||
|
elif [[ $git_status == 0 && $grep_status != 0 ]]; then
|
||||||
log "Site is already up to date, exiting."
|
log "Site is already up to date, exiting."
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
reload-project
|
log "*** WARNING: Unknown Situation ***"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Reference in New Issue
Block a user