-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathdeploy.sh
executable file
·71 lines (53 loc) · 1.82 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
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Roundware Server is released under the GNU Affero General Public License v3.
# See COPYRIGHT.txt, AUTHORS.txt, and LICENSE.txt in the project root directory.
# Upgrade/Deployment for Roundware Server (http://www.roundware.org/)
# Tested with Ubuntu 14.04 LTS 64 bit
#
# Use this to update production code.
# Enable exit on error
set -e
set -v
# Store the script start path
SOURCE_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Check if we are installing via vagrant (assuming standard Vagrant /vagrant share)
if [ -d "/vagrant" ]; then
echo "Found Vagrant."
FOUND_VAGRANT=true
fi
# Default user name.
USERNAME="roundware"
# Use vagrant username/directories used when available.
if [ "$FOUND_VAGRANT" = true ]; then
# Change the user to the vagrant default.
USERNAME="vagrant"
fi
cp $SOURCE_PATH/files/home-user-profile /home/$USERNAME/.profile
# Set paths/directories
WWW_PATH="/var/www/roundware"
CODE_PATH="$WWW_PATH/source"
VENV_PATH="$WWW_PATH"
# Install/Update the production code
# TODO: Better deployment method.
rm -rf $CODE_PATH
mkdir -p $CODE_PATH
cp -R $SOURCE_PATH/. $CODE_PATH
# Activate the environment
source $VENV_PATH/bin/activate
# Set python path to use production code
export PYTHONPATH=$CODE_PATH
# Install upgrade pip
python -m pip install -U pip wheel setuptools
# Install Roundware requirements
python -m pip install -r $CODE_PATH/requirements.txt --upgrade
if [ $ROUNDWARE_DEV ]; then
python -m pip install -r $CODE_PATH/requirements/dev.txt --upgrade
fi
# Set $USERNAME to own WWW_PATH files
chown $USERNAME:$USERNAME -R $WWW_PATH
# Run database migrations
su - $USERNAME -c "$CODE_PATH/roundware/manage.py migrate --noinput"
# Collect static files for production
su - $USERNAME -c "$CODE_PATH/roundware/manage.py collectstatic --noinput"
systemctl restart apache2
echo "Deploy Complete"