forked from rapyd-cloud/rapyd-vz-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrapyd-monarx-installer.sh
201 lines (145 loc) · 4.61 KB
/
rapyd-monarx-installer.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash
source /etc/profile
# must be run as sudo su -
# must pass in vzenvironmentname , vzuid , vznodeid
#load parameters
VZENVNAME=$1
VZUID=$2
VZNODEID=$3
if [ -z "$VZENVNAME" ]
then
exit 9991
fi
if [ -z "$VZUID" ]
then
exit 9992
fi
if [ -z "$VZNODEID" ]
then
exit 99993
fi
# setup defaults
IS_TESTING=false
IS_STAGING=false
IS_DEVELOPER=false
# remove any old monarx-agent configuration file
cd /etc/
rm -f monarx-agent.conf
# create monarx-agent configuration file
echo "#########################################################################" > monarx-agent.conf
echo "# Rapyd Monarx Customer Deployment" >> monarx-agent.conf
echo "#########################################################################" > monarx-agent.conf
echo "client_id=id_live_vAcPku6RwAUoemSNFKRbZMX2" >> monarx-agent.conf
echo "client_secret=sk_live_sb4s7Wvvvh2DIx4L6gH5KHwS" >> monarx-agent.conf
echo "host_id=$VZNODEID-$VZENVNAME" >> monarx-agent.conf
echo "exclude_dirs=/virtfs" >> monarx-agent.conf
echo "exclude_dirs=/(clam_|\.)?quarantine" >> monarx-agent.conf
echo "exclude_users=^virtfs$" >> monarx-agent.conf
echo "user_base=/var/www/webroot/ROOT/" >> monarx-agent.conf
echo "user_base=/usr/local/lsws/" >> monarx-agent.conf
echo "user_base=/tmp/" >> monarx-agent.conf
echo "user_base=/home/litespeed/" >> monarx-agent.conf
echo "tags=$HOSTNAME" >> monarx-agent.conf
echo "tags=$VZNODEID" >> monarx-agent.conf
echo "tags=$VZENVNAME" >> monarx-agent.conf
echo "tags=UID:$VZUID" >> monarx-agent.conf
echo "tags=NODEID:$VZNODEID" >> monarx-agent.conf
echo "tags=ENVNAME:$VZENVNAME" >> monarx-agent.conf
if [[ "$RAPYD_PLAN" == *"STAGING"* ]]
then
IS_STAGING=true
fi
if [[ "$VZENVNAME" == *"-staging"* ]]
then
IS_STAGING=true
fi
if [[ "$VZENVNAME" == "stg-"* ]]
then
IS_STAGING=true
fi
if [[ "$HOSTNAME" == *"rapydapps.cloud"* ]]
then
echo "tags=rapydapps.cloud" >> monarx-agent.conf
fi
if [[ "$HOSTNAME" == *"rapyd.cloud"* ]]
then
echo "tags=rapyd.cloud" >> monarx-agent.conf
IS_STAGING=true
IS_TESTING=true
fi
if [[ "$HOSTNAME" == *"developbb.dev"* ]]
then
echo "tags=developbb.dev" >> monarx-agent.conf
IS_STAGING=true
IS_DEVELOPER=true
fi
totalk=$(awk '/MemTotal:/{print $2}' /proc/meminfo)
devmemlimit=2100000
if [[ $totalk -lt $devmemlimit ]]
then
IS_DEVELOPER=true
fi
if [[ "$RAPYD_PLAN" == *"DEVELOPER"* ]]
then
IS_DEVELOPER=true
fi
if [[ "$RAPYD_PLAN" == "DEV"* ]]
then
IS_DEVELOPER=true
fi
if [[ "$IS_TESTING" = true ]]
then
echo "tags=test" >> monarx-agent.conf
echo "tags=testing" >> monarx-agent.conf
fi
if [[ "$IS_STAGING" = true ]]
then
echo "tags=staging" >> monarx-agent.conf
fi
if [[ "$IS_DEVELOPER" = true ]]
then
echo "tags=dev" >> monarx-agent.conf
echo "tags=developer" >> monarx-agent.conf
fi
echo "tags=litespeed" >> monarx-agent.conf
echo "tags=vz" >> monarx-agent.conf
echo "#########################################################################" >> monarx-agent.conf
now=$(date)
echo "# deployed: $now" >> monarx-agent.conf
echo "#########################################################################" >> monarx-agent.conf
if grep -a 'AlmaLinux' /etc/system-release ; then
# work out what we need to do here for AlmaLinux
cd ~
# force stop monarx if it happens to be running
sudo systemctl stop monarx-agent
# install the repository repo and pgp key
cd /tmp
sudo curl -o /etc/yum.repos.d/monarx.repo https://repository.monarx.com/repository/monarx-yum/linux/yum/el/9/x86_64/monarx.repo
sudo rpm --import https://repository.monarx.com/repository/monarx/publickey/monarxpub.gpg
# install monarx
sudo yum install monarx-protect-autodetect -y
# force stop monarx if it happens to be running
sudo systemctl stop monarx-agent
# force update monarx
sudo yum update monarx-agent -y
# force restart
sudo systemctl restart monarx-agent
else
# assume this is the current Centos 7 based platform install
cd ~
# force stop monarx if it happens to be running
sudo systemctl stop monarx-agent
# install the repository repo and pgp key
cd /tmp
sudo curl -o /etc/yum.repos.d/monarx.repo https://repository.monarx.com/repository/monarx-yum/linux/yum/el/7/x86_64/monarx.repo
sudo rpm --import https://repository.monarx.com/repository/monarx/publickey/monarxpub.gpg
# install monarx
sudo yum install monarx-protect-autodetect -y
# force stop monarx if it happens to be running
sudo systemctl stop monarx-agent
# force update monarx
sudo yum update monarx-agent -y
# force restart
sudo systemctl restart monarx-agent
fi
# end of monarx main deployer