-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·61 lines (51 loc) · 1.18 KB
/
deploy.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
#!/bin/bash -e
#
# @author holman
#
# Shortcut script to deploy Flask web server and compile Sass
APP_FILE=app.py
# dev|prod
ENV=$1
# js|sass or not specified (which compiles everything and deploys server)
DEPLOY_MODE=$2
usage() {
echo "Usage ./deploy.sh [dev|prod] [optional:server]"
exit
}
if [[ $# -lt 1 || ( $ENV != 'dev' && $ENV != 'prod' ) ]]; then usage; fi
# Pull the latest files
pull_latest() {
if [ $ENV == 'dev' ]; then
git pull --no-rebase
elif [ $ENV == 'prod' ]; then
# Don't allow uncommited changes in prod
git pull
fi
bower update
}
deploy_server() {
if [ $ENV == 'dev' ]; then
# Use built in server
python $APP_FILE $ENV
elif [ $ENV == 'prod' ]; then
# Launch uWSGI
echo 'If uWSGI ini file not installed, run:'
echo " 'ln -s /home/holman/src/mtg-cube/uwsgi/mtg-cube.ini " \
"/etc/uwsgi/vassals/'"
sudo stop uwsgi && sudo start uwsgi
fi
}
# Go into script directory (which is the repo directory)
cd "$(dirname "$0")"
if [ $# -lt 2 ]; then
# No deploy mode specified, so run everything
pull_latest
grunt $ENV
deploy_server
else
if [ $DEPLOY_MODE == 'server' ]; then
deploy_server
else
usage
fi
fi