-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·43 lines (34 loc) · 1.54 KB
/
install.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
#!/bin/bash
# Installs on Google Cloud Platform's Compute Engine for Ubuntu 18.04 LTS
# Make sure script is called with DNS name desired
if [ $# -ne 1 ]; then
echo "Usage: sudo install.sh <DNS_Name>"
fi
# Name the service based on first part of DNS name
SITE=`echo $1 | sed -e 's/\..*//'`
# Install all required system packages
apt update
apt install -y python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools virtualenv nginx python-certbot-nginx
# Install all required python packages
virtualenv -p python3 env
source env/bin/activate
pip install --upgrade -r requirements.txt
# Set up systemd service for site
sed s+PROJECT_USER+$SUDO_USER+ etc/systemd.template | sed s+PROJECT_DIR+$PWD+ > /etc/systemd/system/$SITE.service
# Configure nginx for site
sed s+PROJECT_HOST+$1+ etc/nginx.template | sed s+PROJECT_DIR+$PWD+ > /etc/nginx/sites-available/$SITE
ln -s /etc/nginx/sites-available/$SITE /etc/nginx/sites-enabled
# Change ownership to regular user, but make group www-data so that
# nginx can access. Note: unix socket must be created by nginx in
# current directory so make www-data own the top level directory
chown -R $SUDO_USER $PWD
chgrp -R www-data $PWD
chmod g+wX -R $PWD
chown www-data $PWD
# Restart all services
systemctl start $SITE
systemctl enable $SITE
systemctl restart nginx
certbot --nginx -d $1 -n -m [email protected] --agree-tos --redirect
# must be able to write to. Add user to www-data group.
echo "Installation complete. Please logout and log back in for group and umask changes to take effect"