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
/
deploy.sh
executable file
·151 lines (116 loc) · 3.19 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/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 wget unzip php-bcmath php-amqp php-curl php-json php-cli php-zip php-mbstring inotify-tools
# Setup firewall
sudo ufw --force enable
sudo ufw allow ssh
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
# Setup rabbitmq listener
mkdir news
cd rabbit
git clone git@github.com:stonX-IT490/rabbitmq-common.git rabbitmq-dmzHost
cd rabbitmq-dmzHost
./deploy.sh
cd ..
git clone git@github.com:stonX-IT490/rabbitmq-common.git rabbitmq-webDmzHost
cd rabbitmq-webDmzHost
./deploy.sh
cd ..
rabbitDmzHost="<?php
\$config = [
'host' => '$rabbit_ip',
'port' => 5672,
'username' => 'dmz',
'password' => 'stonx_dmz',
'vhost' => 'dmzHost'
];
?>"
rabbitWebDmzHost="<?php
\$config = [
'host' =>'$rabbit_ip',
'port' => 5672,
'username' => 'dmz',
'password' => 'stonx_dmz',
'vhost' => 'webDmzHost'
];
?>"
echo "$rabbitDmzHost" > rabbitmq-dmzHost/config.php
echo "$rabbitWebDmzHost" > rabbitmq-webDmzHost/config.php
cd ..
pwd=`pwd`'/rabbit'
serviceNewsHost="[Unit]
Description=News RabbitMQ Consumer Listener
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/php -f $pwd/newsListener.php
[Install]
WantedBy=multi-user.target"
echo "$serviceNewsHost" > rmq-news.service
sudo cp rmq-news.service /etc/systemd/system/
sudo systemctl start rmq-news
sudo systemctl enable rmq-news
crontab="*/2 9-16 * * 1-5 /usr/bin/php -f $pwd/stockData.php > $pwd/stockData.log 2>&1
30 9 * * 1-5 /usr/bin/php -f $pwd/news.php > $pwd/news.log 2>&1
30 9 * * 1-5 /usr/bin/php -f $pwd/forexAPI.php > $pwd/forex.log 2>&1"
echo "$crontab" > crontab.temp
crontab -r
crontab crontab.temp
rm crontab.temp
# Install check-prod1 in systemd
pwd=`pwd`
serviceCheckProd1="[Unit]
Description=Check if dmz-prod1 is up
[Service]
Type=simple
Restart=always
ExecStart=$pwd/check.sh
[Install]
WantedBy=multi-user.target"
if [ $cluster == "prod" ]; then
read -p "Which host? (prod1, prod2) " vm_type
if [ $vm_type == "prod2" ]; then
echo "$serviceCheckProd1" > check-prod1.service
sudo cp check-prod1.service /etc/systemd/system/
sudo systemctl start check-prod1
sudo systemctl enable check-prod1
fi
fi
# Setup Central Logging
git clone git@github.com:stonX-IT490/logging.git ~/logging
cd ~/logging
git pull
chmod +x deploy.sh
./deploy.sh
cd ~/
# Email Push
git clone git@github.com:stonX-IT490/pushNotification.git ~/pushNotification
cd ~/pushNotification
chmod +x deploy.sh
./deploy.sh
cd ~/