-
Notifications
You must be signed in to change notification settings - Fork 12
/
pressmain.sh
386 lines (283 loc) · 15.1 KB
/
pressmain.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
# FUNCTIONS BELOW ##############################################################
mainbanner () {
touch /var/plexguide/auth.bypass
a7=$(cat /var/plexguide/auth.bypass)
if [[ "$a7" != "good" ]]; then domaincheck7; fi
echo good > /var/plexguide/auth.bypass
if [[ "$a7" != "good" ]]; then domaincheck7; fi
echo good > /var/plexguide/auth.bypass
tld=$(cat /var/plexguide/tld.program)
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 PG Press 📓 Reference: pgpress.pgblitz.com
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💬 PG Press is a Mass WordPress Management System managed by PGBlitz!
[1] WordPress: Deploy a New Site
[2] WordPress: View Deployed Sites
[3] WordPress: Backup & Restore
[4] WordPress: Set a Top Level Domain - [$tld]
[5] WordPress: Destroy a Website
[Z] Exit
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Type a Selection | Press [ENTER] ' typed < /dev/tty
case $typed in
1 )
deploywp
mainbanner ;;
2 )
viewcontainers
mainbanner ;;
3 )
# Checks to That RClone Works
file=$()
if [ ! -d "/mnt/gdrive/plexguide/backup/wordpress" ]; then
# Makes a Test Directory for Checks
rclone mkdir --config /opt/appdata/plexguide/rclone.conf gdrive:/plexguide/backup/wordpress
rclonecheck=$(rclone lsd --config /opt/appdata/plexguide/rclone.conf gdrive:/plexguide/backup/ | grep wordpress)
sleep 1
# Conducts a Check Again; if fails; then exits
if [ "$rclonecheck" == "" ]; then
echo
echo "💬 Unable to find - /mnt/gdrive/plexguide/backup/wordpress"
echo ""
echo "1. Did You Deploy PGClone?"
echo "2. Test by typing ~ ls -la /mnt/gdrive"
echo ""
read -p 'Confirm Info | Press [ENTER] ' typed < /dev/tty
mainbanner; fi
fi
bash /opt/pgpress/pgvault/pgvault.sh
mainbanner ;;
4 )
tldportion
mainbanner ;;
5 )
destroycontainers
mainbanner ;;
z )
exit ;;
Z )
exit ;;
* )
mainbanner ;;
esac
}
deploywp () {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Setting a WordPress ID / SubDomain
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Type the name for the subdomain wordpress instance. Instance can later be
turned to operate at the TLD (Top Level Domain). Keep it all lowercase and
with no breaks in space.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💬 Quitting? TYPE > exit
EOF
read -p '↘️ Type Subdomain | Press [ENTER]: ' subdomain < /dev/tty
if [ "$subdomain" == "exit" ]; then mainbanner; fi
if [ "$subdomain" == "" ]; then deploywp; fi
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Deploying WordPress Instance: $subdomain
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
echo "$subdomain" > /tmp/wp_id
ansible-playbook /opt/pgpress/db.yml
ansible-playbook /opt/pgpress/wordpress.yml
wpdomain=$(cat /var/plexguide/server.domain)
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Site Deployed! Visit - $subdomain.$wpdomain
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '💬 Done? | Press [ENTER] ' typed < /dev/tty
}
viewcontainers () {
docker ps --format '{{.Names}}' | grep "wp-" > /var/plexguide/tmp.containerlist
file="/var/plexguide/tmp.format.containerlist"
if [ ! -e "$file" ]; then rm -rf /var/plexguide/tmp.format.containerlist; fi
touch /var/plexguide/tmp.format.containerlist
cat /var/plexguide/tmp.format.containerlist | cut -c 2- > /var/plexguide/tmp.format.containerlist
num=0
while read p; do
p="${p:3}"
echo -n $p >> /var/plexguide/tmp.format.containerlist
echo -n " " >> /var/plexguide/tmp.format.containerlist
num=$[num+1]
if [ "$num" == 7 ]; then
num=0
echo " " >> /var/plexguide/tmp.format.containerlist
fi
done </var/plexguide/tmp.containerlist
containerlist=$(cat /var/plexguide/tmp.format.containerlist)
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 PG Press 📓 Reference: pgpress.pgblitz.com
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📂 WP Containers Detected Running
$containerlist
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '💬 Done Viewing? | Press [ENTER] ' typed < /dev/tty
}
destroycontainers () {
docker ps --format '{{.Names}}' | grep "wp-" > /var/plexguide/tmp.containerlist
file="/var/plexguide/tmp.format.containerlist"
if [ ! -e "$file" ]; then rm -rf /var/plexguide/tmp.format.containerlist; fi
touch /var/plexguide/tmp.format.containerlist
cat /var/plexguide/tmp.format.containerlist | cut -c 2- > /var/plexguide/tmp.format.containerlist
num=0
while read p; do
p="${p:3}"
echo -n $p >> /var/plexguide/tmp.format.containerlist
echo -n " " >> /var/plexguide/tmp.format.containerlist
num=$[num+1]
if [ "$num" == 7 ]; then
num=0
echo " " >> /var/plexguide/tmp.format.containerlist
fi
done </var/plexguide/tmp.containerlist
containerlist=$(cat /var/plexguide/tmp.format.containerlist)
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 PG Press 📓 Reference: pgpress.pgblitz.com
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📂 WP Containers Detected Running
$containerlist
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
↘️ Quitting? TYPE > exit
EOF
read -p '💬 Destory Which Container? | Press [ENTER]: ' typed < /dev/tty
if [[ "$typed" == "exit" ]]; then mainbanner; fi
if [[ "$typed" == "" ]]; then destroycontainers; fi
destroycheck=$(echo $containerlist | grep "$typed")
if [[ "$destroycheck" == "" ]]; then
echo
read -p '💬 WordPress Contanier Does Not Exist! | Press [ENTER] ' typed < /dev/tty
destroycontainers; fi
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 PG Press - Destroying the WordPress Instance - $typed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
docker stop "wp-${typed}/mysql"
docker stop "wp-${typed}"
docker rm "wp-${typed}/mysql"
docker rm "wp-${typed}"
rm -rf "/opt/appdata/wordpress/${typed}"
echo
read -p "💬 WordPress Instance $typed Removed! | Press [ENTER] " abc < /dev/tty
mainbanner
}
tldportion () {
docker ps --format '{{.Names}}' | grep "wp-" > /var/plexguide/tmp.containerlist
file="/var/plexguide/tmp.format.containerlist"
if [ ! -e "$file" ]; then rm -rf /var/plexguide/tmp.format.containerlist; fi
touch /var/plexguide/tmp.format.containerlist
cat /var/plexguide/tmp.format.containerlist | cut -c 2- > /var/plexguide/tmp.format.containerlist
num=0
while read p; do
p="${p:3}"
echo -n $p >> /var/plexguide/tmp.format.containerlist
echo -n " " >> /var/plexguide/tmp.format.containerlist
num=$[num+1]
if [ "$num" == 7 ]; then
num=0
echo " " >> /var/plexguide/tmp.format.containerlist
fi
done </var/plexguide/tmp.containerlist
containerlist=$(cat /var/plexguide/tmp.format.containerlist)
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 PG Press - Set Top Level Domain 📓 Reference: pgpress.pgblitz.com
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📂 WP Containers Detected Running
$containerlist
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 PG Press - Set Top Level Domain 📓 Reference: pgpress.pgblitz.com
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📂 WP Containers Detected Running
$containerlist
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💬 Quitting? TYPE > exit
EOF
read -p '💪 Type WordPress Site for Top Level Domain | Press [ENTER]: ' typed < /dev/tty
if [[ "$typed" == "exit" ]]; then mainbanner; fi
destroycheck=$(echo $containerlist | grep "$typed")
if [[ "$destroycheck" == "" ]]; then
echo
read -p '💬 WordPress Contanier Does Not Exist! | Press [ENTER] ' typed < /dev/tty
tldportion; fi
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅️ PASS: TLD Application Set
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
sleep 1.5
# Sets Old Top Level Domain
cat /var/plexguide/tld.program > /var/plexguide/old.program
echo "$typed" > /var/plexguide/tld.program
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🍖 NOM NOM - Rebuilding Your Old App & New App Containers!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
sleep 1.5
old=$(cat /var/plexguide/old.program)
new=$(cat /var/plexguide/tld.program)
touch /var/plexguide/tld.type
tldtype=$(cat /var/plexguide/tld.type)
if [[ "$old" != "$new" && "$old" != "NOT-SET" ]]; then
if [[ "$tldtype" == "standard" ]]; then
ansible-playbook /opt/plexguide/containers/$old.yml
elif [[ "$tldtype" == "wordpress" ]]; then
echo "$old" > /tmp/wp_id
ansible-playbook /opt/pgpress/wordpress.yml
echo "$typed" > /tmp/wp_id
fi
fi
# Repair this to Recall Port for It
echo "$new" > /tmp/wp_id
#echo "$port" > /tmp/wp_port
ansible-playbook /opt/pgpress/wordpress.yml
# Notifies that TLD is WordPress
echo "wordpress" > /var/plexguide/tld.type
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅️ Top Level Domain Container is Rebuilt!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Press [ENTER] ' typed < /dev/tty
# Goes Back to Main Banner AutoMatically
}
domaincheck7() {
domaincheck=$(cat /var/plexguide/server.domain)
touch /var/plexguide/server.domain
touch /tmp/portainer.check
rm -r /tmp/portainer.check
wget -q "https://portainer.${domaincheck}" -O /tmp/portainer.check
domaincheck=$(cat /tmp/portainer.check)
if [ "$domaincheck" == "" ]; then
echo
echo "💬 Unable to reach your Subdomain for Portainer!"
echo ""
echo "1. Forget to enable Traefik?"
echo "2. Valdiate if Subdomain is Working?"
echo "3. Validate Portainer is Deployed?"
echo "4. Did you forget to put * wildcare in your DNS?"
echo ""
read -p 'Confirm Info | Press [ENTER] ' typed < /dev/tty
exit; fi
}
mainbanner