-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·76 lines (63 loc) · 2.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
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
#!/bin/bash
# */vasserballverband/vbvb/install.sh
# Update and upgrade
sudo apt update && sudo apt upgrade -y
# Python 3.6.7 is pre-installed on Ubuntu 18.04 so just install pip3 and tree
sudo apt install -y python3-pip tree
# Install all Django dependencies
sudo -H pip3 install django djangorestframework django_extensions coreapi
# Install Terraform
# We need wget and it's already installed
sudo apt install unzip
wget https://releases.hashicorp.com/terraform/0.11.11/terraform_0.11.11_linux_amd64.zip
unzip terra*
sudo mv terraform /usr/local/bin
terraform version
rm -f terra*
# Install Docker for Jenkins
sudo apt install -y\
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt update
sudo apt install -y docker-ce
# Spin up a container so we may install Jenkins
sudo docker run \
--name "jenkins_container" \
-u root \
--rm \
-d \
-p 8080:8080 \
-p 50000:50000 \
-v jenkins-data:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
jenkinsci/blueocean \
echo "All installations attempted"
# Cleanup
sudo apt autoremove -y
# We now want to
# change ALLOWED_HOSTS in */vasserballverband/vbvb/vbvb/settings.py to your instance's
# public IP. To get the public IP we have to use
EXTERNAL_IP=$(curl -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip)
# because GCP's virtualization of hardware leaves us unable to extract our instances
# IP within its default network.
# the following line deletes the current ALLOWED_HOSTS line
sed -i '/ALLOWED_HOSTS/d' ./vbvb/settings.py
# the following line adds in a new ALLOWED_HOSTS line
sed -i "28iALLOWED_HOSTS = \['wasserballver.band', '$EXTERNAL_IP', '127.0.0.1'\]" ./vbvb/settings.py
# start server
# the Jenkins Admin Password can be found within the docker logs, this is a very fragile and custom script to extract it
# could not get it to work.
JENKINS_ADMIN_PASSWORD=$(sudo docker logs jenkins_container 2>&1 | grep -A 2 "Please use the following" | tail -1)
echo "INFORMATION TO USER FROM vasserballverband TEAM..."
# echo "Jenkins admin password is... $JENKINS_ADMIN_PASSWORD"
echo "This is your external IP... $EXTERNAL_IP"
echo "Run this command 'python3 manage.py runserver 0.0.0.0:8000' to start server"
python3 manage.py runserver 0.0.0.0:8000