-
Notifications
You must be signed in to change notification settings - Fork 57
/
install-govready-q.sh
executable file
·157 lines (126 loc) · 3.46 KB
/
install-govready-q.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
echo "NOTE: THIS SCRIPT (install-govready-q.sh) IS DEPRECATED - please migrate to 'install.py' when possible."
sleep 3
# this script can be used to quickly set up a new GovReady-Q instance
# for local testing, from a freshly-cloned repository.
# Usage:
# $ ./install-govready-q.sh
# $ ./install-govready-q.sh --non-interactive
#
# NOTE: VERY IMPORTANT TO INCLUDE --pip-user WHEN INSTALLING IN
# VIRTUAL PYTHON ENVIRONMENT ASSOCIATED WITH THE USER.
# $ ./install-govready-q.sh --pip-user
# note that this script DOES NOT install libraries from a package manager,
# and does not edit /etc/hosts. those will have to be done manually
# Defaults
##########
# URL browsers go to reach GovReady-Q site
GOVREADYURL="http://localhost:8000"
# run the script be non-interactively?
# default is yes, run interactively
NONINTERACTIVE=
# run pip install with `--user` flag?
PIPUSER=
# some of these commands generate a big wall of text, so we may want visual space
# between them
SPACER="..."
# Parse command-line arguments
##############################
while [ $# -gt 0 ]; do
case "$1" in
--non-interactive)
NONINTERACTIVE=1
shift 1;;
--pip-user)
PIPUSER=1
shift 1;;
-v)
VERBOSE=1
shift 1;;
--)
shift
break
;;
*)
echo "Unrecognized command line option: $1";
exit 1;
esac
done
# make sure we're not running in an environment with the wrong Python
# command names (Docker, for instance, has python3.6 as the command)
function check_has_command() {
which $1 >/dev/null 2>&1
return $?
}
if check_has_command python3 && check_has_command pip3
then
: # we're good
else
echo "ERROR: The commands 'python3' and 'pip3' are not available.";
exit 1;
fi
# indicate mode
if [ $NONINTERACTIVE ];
then
echo "Installing GovReady-Q in non-interactive mode..."
else
echo "Installing GovReady-Q in interactive mode (default)..."
fi
# install basic as local user?
if [ $PIPUSER ];
then
pip3 install --user -r requirements.txt;
else
pip3 install -r requirements.txt;
fi
echo $SPACER
# retrieve static assets
./fetch-vendor-resources.sh
# collect files into static directory
if [ $NONINTERACTIVE ];
then
python3 manage.py collectstatic --no-input
else
python3 manage.py collectstatic
fi
# create the local/environment.json file, if it is missing (it generally will be)
if [ ! -e local/environment.json ];
then
echo "creating DEV environment.json file"
# this is an easy way for us to get a random secret key
SECRET_KEY_LINE="$(python3 manage.py | grep '"secret-key":')"
# need to use a <<- heredoc if we want to have tabs be ignored
cat <<- ENDJSON > local/environment.json
{
"govready-url": "$GOVREADYURL",
"static": "static_root",
$SECRET_KEY_LINE
"debug": true
}
ENDJSON
else
echo "environment.json file already exists, proceeding"
fi
# run various DB setup scripts (schema, core data, etc.)
python3 manage.py migrate
python3 manage.py load_modules
echo $SPACER
echo $SPACER
echo $SPACER
if [ $NONINTERACTIVE ];
then
python3 manage.py first_run --non-interactive
else
python3 manage.py first_run
fi
echo $SPACER
echo "NOTE: THIS SCRIPT (install-govready-q.sh) IS DEPRECATED - please migrate to 'install.py' when possible."
echo ""
echo "***********************************"
echo "* GovReady-Q Server configured... *"
echo "***********************************"
echo ""
echo "To start GovReady-Q, run: "
echo " python3 manage.py runserver"
echo "or"
echo " python manage.py runserver"