-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateproject.sh
executable file
·72 lines (55 loc) · 1.1 KB
/
updateproject.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
PYTHON_VER=3
DJANGO_VER=
GIT_REMOTE=
GIT_BRANCH=
VENV_DIR="pyvenv"
SOURCE_DIR="source"
if [ -t 1 ]
then
function message() {
if [ "$1" == "-g" ]
then
shift
color=32
else
color=33
fi
printf "\033[0;${color}m$*\033[0m\n"
}
else
function message() {
[ "$1" == "-g" ] && shift
echo "$*"
}
fi
if [[ -z "$1" ]]
then
echo "No project dir specified" >&2
exit 1
fi
set -e # exit the whole script on first failure
cd "$1"
if [[ ! ( -d "$VENV_DIR" && -d "$SOURCE_DIR" ) ]]
then
echo "given directory $1 doens't look like containing django project" >&2
exit 1
fi
. "${VENV_DIR}/bin/activate" # activate the python virtual environment
cd "$SOURCE_DIR"
CURRENT_GIT_HEAD=`git rev-parse HEAD`
# load new changes from git
git pull
if [[ "$CURRENT_GIT_HEAD" == `git rev-parse HEAD` ]]
then
message -g "no changes in git"
exit 0
fi
# changes in git
# compile gettext messages
python manage.py compilemessages
# update static assets
python manage.py collectstatic --no-input
# migrate the db
python manage.py migrate
message -g "project updated"