forked from ekratia/ekratia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_python_dependencies.sh
executable file
·47 lines (42 loc) · 1.98 KB
/
install_python_dependencies.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
#!/bin/bash
#Creates a virtualenv if it does not exist and uses it
if [ ! -d ~/.envs/django-app ] ; then
virtualenv ~/.envs/django-app
fi
source ~/.envs/django-app/bin/activate
pip --version >/dev/null 2>&1 || {
echo >&2 -e "\npip is required but it's not installed."
echo >&2 -e "You can install it by running the following command:\n"
echo >&2 "wget https://bootstrap.pypa.io/get-pip.py; chmod +x get-pip.py; sudo ./get-pip.py"
echo >&2 -e "\n"
echo >&2 -e "\nFor more information, see pip documentation: https://pip.pypa.io/en/latest/"
exit 1;
}
virtualenv --version >/dev/null 2>&1 || {
echo >&2 -e "\nvirtualenv is required but it's not installed."
echo >&2 -e "You can install it by running the following command:\n"
echo >&2 "sudo pip install virtualenv"
echo >&2 -e "\n"
echo >&2 -e "\nFor more information, see virtualenv documentation: https://virtualenv.pypa.io/en/latest/"
exit 1;
}
if [ -z "$VIRTUAL_ENV" ]; then
echo >&2 -e "\nYou need activate a virtualenv first"
echo >&2 -e 'If you do not have a virtualenv created, run the following command to create and automatically activate a new virtualenv named "venv" on current folder:\n'
echo >&2 -e "virtualenv venv"
echo >&2 -e "\nTo leave/disable the currently active virtualenv, run the following command:\n"
echo >&2 "deactivate"
echo >&2 -e "\nTo activate the virtualenv again, run the following command:\n"
echo >&2 "source venv/bin/activate"
echo >&2 -e "\nFor more information, see virtualenv documentation: https://virtualenv.pypa.io/en/latest/"
echo >&2 -e "\n"
exit 1;
else
echo >&2 -e "$VIRTUAL_ENV"
pip install -r /srv/app/requirements.txt
cp /home/ubuntu/.env /srv/app/
cd /srv/app/
python /srv/app/manage.py migrate --settings=config.settings.production
python /srv/app/manage.py compilemessages
python /srv/app/manage.py collectstatic --settings=config.settings.production --noinput > /dev/null 2> /dev/null < /dev/null &
fi