This repository has been archived by the owner on May 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·123 lines (97 loc) · 2.97 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
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
#!/bin/bash
read -p "Which cluster? (prod, qa, dev) " cluster
rabbit_ip="broker"
check=$( getent hosts | grep -e broker )
if [ "$check" == "" ]; then
if [ $cluster == "dev" ]; then
echo "10.4.90.102 broker" | sudo tee -a /etc/hosts
fi
if [ $cluster == "qa" ]; then
echo "10.4.90.152 broker" | sudo tee -a /etc/hosts
fi
if [ $cluster == "prod" ]; then
echo "10.4.90.52 broker" | sudo tee -a /etc/hosts
echo "10.4.90.62 broker" | sudo tee -a /etc/hosts
fi
fi
# Update repos
sudo apt update
# Do full upgrade of system
sudo apt full-upgrade -y
# Remove leftover packages and purge configs
sudo apt autoremove -y --purge
# Install required packages
sudo apt install -y ufw php-amqp php-bcmath php-cli php-common php-curl php-fpm php-json php-mbstring php-mysql php-readline php-opcache php-gmp php-zip nginx wget unzip inotify-tools
# Setup firewall
sudo ufw --force enable
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw default deny incoming
sudo ufw default allow outgoing
# Install zerotier
sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
curl -s https://install.zerotier.com | sudo bash
# RabbitMQ
cd src/lib/
git clone [email protected]:stonX-IT490/rabbitmq-common.git
cd rabbitmq-common
./deploy.sh
cd ..
git clone [email protected]:stonX-IT490/rabbitmq-common.git rabbitmq-webDmzHost
cd rabbitmq-webDmzHost
./deploy.sh
cd ..
rabbitWebHost="<?php
\$config = [
'host' =>'$rabbit_ip',
'port' => 5672,
'username' => 'webserver',
'password' => 'stonx_websrv',
'vhost' => 'webHost'
];
?>"
rabbitWebDmzHost="<?php
\$config = [
'host' => '$rabbit_ip',
'port' => 5672,
'username' => 'webserver',
'password' => 'stonx_websrv',
'vhost' => 'webDmzHost'
];
?>"
echo "$rabbitWebHost" > rabbitmq-common/config.php
echo "$rabbitWebDmzHost" > rabbitmq-webDmzHost/config.php
cd ../../
# Stop nginx
sudo systemctl stop nginx
# Setup Self Signed Cert
if [ $cluster != "prod" ]; then
sudo openssl req -subj '/CN=stonX/OU=IT 490/O=NJIT/C=US' -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
sudo openssl dhparam -out /etc/ssl/dhparam.pem 2048
fi
# Copy config over
sudo cp -r config/nginx/. /etc/nginx/
if [ $cluster == "prod" ]; then
sudo cp -r config/nginx/site.prod.conf /etc/nginx/site.conf
fi
sudo chown -R root:root /etc/nginx
sudo find /etc/nginx -type d -exec chmod 755 {} \;
sudo find /etc/nginx -type f -exec chmod 644 {} \;
sudo nginx -t
# Copy website source
sudo rm -rf root /var/www/html/*
sudo cp -r src/. /var/www/html/
sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html -type d -exec chmod 755 {} \;
sudo find /var/www/html -type f -exec chmod 644 {} \;
# Start nginx
sudo systemctl start nginx
# Setup Central Logging
git clone [email protected]:stonX-IT490/logging.git ~/logging
cd /home/webserver/logging
chmod +x deploy.sh
./deploy.sh
cd /home/webserver/
# Reload systemd
sudo systemctl daemon-reload