-
Notifications
You must be signed in to change notification settings - Fork 48
/
functions.sh
553 lines (405 loc) · 24.3 KB
/
functions.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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
main() {
local file=$1 val=$2 var=$3
[[ -e $file ]] || printf '%s\n' "$val" > "$file"
printf -v "$var" '%s' "$(<"$file")"
}
blockdeploycheck() {
if [[ $(cat /pg/var/traefik.provider) == "NOT-SET" || $(cat /pg/var/server.domain) == "NOT-SET" || $(cat /pg/var/server.email) == "NOT-SET" ]]; then
echo
read -p 'Blocking Deployment! Must Configure Everything! | Press [ENTER]' typed < /dev/tty
traefikstart
fi
}
delaycheckinterface() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Traefik - DNS Delay Check
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTE: This enables a certain amount of time to be delayed before the
provider validates your Traefik container! Setting it too low may result
in the provider being unable to validate your traefik container, which may
result in MISSING the opportunity to validate your https:// certificates!
Delay the Traefik DNS Check for how many seconds? (Default 90)
EOF
typed2=999999999
while [[ "$typed2" -lt "30" || "$typed2" -gt "120" ]]; do
echo "QUITTING? Type >>> exit"
read -p 'Type Number Between 30 through 120 | Press [ENTER]: ' typed2 < /dev/tty
if [[ "$typed2" == "exit" || "$typed2" == "Exit" || "$typed2" == "EXIT" ]]; then traefikstart; fi
echo
done
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 New DNS Delay Check Value: [$typed2] Seconds
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTE 1: Make all changes first. Traefik must be deployed/redeployed for
this to take affect!
NOTE 2: When deploying Traefik, you will be required to wait at least $typed
seconds as a result of the check.
EOF
echo "$typed2" > /pg/var/server.delaycheck
read -p 'Acknowledge Info | Press [ENTER] ' typed < /dev/tty
}
destroytraefik() {
docker stop traefik 1>/dev/null 2>&1
docker rm traefik 1>/dev/null 2>&1
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Traefik Container Destroyed!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Acknowledge Info | Press [ENTER] ' typed < /dev/tty
}
domaininterface() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Domain Name - Current Domain: $domain
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
QUITTING? Type >>> exit
EOF
read -p 'Input Value | Press [ENTER]: ' typed < /dev/tty
if [[ "$typed" = "exit" || "$typed" = "Exit" || "$typed" = "EXIT" ]]; then traefikstart; fi
if [[ $(echo ${typed} | grep "\.") == "" ]]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Domain Name Invalid - Missing "." - $typed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Acknowledge Info | Press [ENTER] ' typed < /dev/tty
domaininterface; bash /pg/traefik/traefik.sh; exit
fi
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Domain Name - Current Domain: $typed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTE: Traefik must be deployed/redeployed for the domain name changes to
take affect!
EOF
echo $typed > /pg/var/server.domain
read -p 'Acknowledge Info | Press [ENTER] ' typed < /dev/tty
}
deploytraefik() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Deploy Traefik with the Following Values?
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Domain Provider: $provider
Domain Name : $domain
EMail Address : $email
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
pnum=0
mkdir -p /pg/var/prolist
rm -rf /pg/var/prolist/* 1>/dev/null 2>&1
ls -la "/pg/traefik/providers/$provider" | awk '{print $9}' | tail -n +4 > /pg/var/prolist/prolist.sh
while read p; do
let "pnum++"
echo -n "${p} - "
echo -n $(cat "/pg/var/traefik/$provider/$p")
echo
done </pg/var/prolist/prolist.sh
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo
while true; do
echo "Deploy Traefik?"
read -p 'y or n? | Press [ENTER]: ' typed2 < /dev/tty
if [[ "$typed2" == "n" || "$typed2" == "N" || "$typed2" == "No" || "$typed2" == "NO" ]]; then traefikstart; fi
if [[ "$typed2" == "y" || "$typed2" == "Y" || "$typed2" == "Yes" || "$typed2" == "YES" ]]; then
traefikbuilder
traefikstart; fi
echo
done
}
emailinterface() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Current EMail Address: $email
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
QUITTING? Type >>> exit
EOF
read -p 'Input Value | Press [ENTER]: ' typed < /dev/tty
if [[ "$typed" = "exit" || "$typed" = "Exit" || "$typed" = "EXIT" ]]; then traefikstart; fi
### fix bug if user doesn't type .
if [[ $(echo $typed | grep "\.") == "" ]]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 EMail Invalid - Missing "." - $typed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Acknowledge Info | Press [ENTER] ' typed < /dev/tty
emailinterface; bash /pg/traefik/traefik.sh; exit
fi
if [[ $(echo $typed | grep "\@") == "" ]]; then
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 EMail Invalid - Missing "@" - $typed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Acknowledge Info | Press [ENTER] ' typed < /dev/tty
emailinterface; bash /pg/traefik/traefik.sh; exit
fi
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 New EMail Address: $typed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTE: Make all changes first. Traefik must be deployed/redeployed for
the email name changes to take affect!
EOF
echo $typed > /pg/var/server.email
read -p 'Acknowledge Info | Press [ENTER] ' typed < /dev/tty
}
layoutbuilder() {
if [[ "$provider" == "NOT-SET" ]]; then layout=" "; fi
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Traefik - Reverse Proxy Interface Menu
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[1] Top Level Domain App: [$tld]
[2] Domain Provider : [$provider]
[3] Domain Name : [$domain]
[4] EMail Address : [$email]
[5] DNS Delay Check : [$delaycheck] Seconds
EOF
# skips if no provider is set
if [[ $(cat /pg/var/traefik.provider) != "NOT-SET" ]]; then
# Generates Rest of Inbetween Interface
pnum=5
mkdir -p /pg/var/prolist
rm -rf /pg/var/prolist/* 1>/dev/null 2>&1
ls -la "/pg/traefik/providers/$provider" | awk '{print $9}' | tail -n +4 > /pg/var/prolist/prolist.sh
# Set Provider for the Process
provider7=$(cat /pg/var/traefik.provider)
mkdir -p "/pg/var/traefik/$provider7"
while read p; do
let "pnum++"
echo "$p" > "/pg/var/prolist/$pnum"
echo "[$pnum] $p" >> /pg/var/prolist/final.sh
# Generates a Not-Set for the Echo Below
file="/pg/var/traefik/$provider7/$p"
if [ ! -e "$file" ]; then
filler="** NOT SET - "
touch /pg/var/traefik/block.deploy
else filler=""; fi
echo "[$pnum] ${filler}${p}"
done </pg/var/prolist/prolist.sh
fi
# If message.c exists due to incorrect working traefik, this will show
if [ -e "/pg/var/traefikportainer.check/emergency/message.c" ]; then
deployed="DEPLOYED - INCORRECTLY"; fi
# Last Piece of the Interface
tee <<-EOF
[A] Deploy Traefik : [$deployed]
[B] Destroy Traefik
[Z] Exit
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
# Standby
read -p 'Type a Number | Press [ENTER]: ' typed < /dev/tty
# Prompt User To Input Information Based on Greater > 4 & Less Than pnum++
if [[ "$typed" -ge "6" && "$typed" -le "$pnum" ]]; then layoutprompt; fi
}
layoutprompt() {
process5=$(cat /pg/var/prolist/final.sh | grep "$typed" | cut -c 5-)
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Input Value - $process5
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
QUITTING? Type >>> exit
EOF
read -p 'Input Value | Press [ENTER]: ' typed < /dev/tty
if [[ "$typed" = "exit" || "$typed" = "Exit" || "$typed" = "EXIT" ]]; then traefikstart; fi
echo "$typed" > "/pg/var/traefik/$provider7/$process5"
echo
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
read -p 'Information Stored | Press [ENTER] ' typed < /dev/tty
}
postdeploy() {
tempseconds=$(cat /pg/var/server.delaycheck)
delseconds=$[${tempseconds}+10]
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Standby for Traefik Deployment Validation
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTE 1: Do NOT EXIT this interface. Please standby for validation checks!
NOTE 2: Standing by for [$tempseconds] + 10 seconds per the set DNS delay
check! When complete, Portainer will be rebuilt! If that passes,
then we will rebuild the rest of the containers!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
while [[ "$delseconds" -ge "1" ]]; do
delseconds=$[${delseconds}-1]
echo -ne "StandBy - Traefik Validaiton Process: $delseconds Seconds "'\r';
sleep 1; done
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Rebuilding Portainer
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
bash /pg/apps/programs/portainer/start.sh
delseconds=10
domain=$(cat /pg/var/server.domain)
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Portainer Check
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTE 1: Do NOT EXIT this interface. Please standby for validation checks!
NOTE 2: Checking on https://portainer.${domain}'s existance.
Please allow 10 seconds for portainer to boot up.
NOTE 3: Be aware that simple mistakes such as bad input, bad domain, or
not knowing what your doing counts for 75% of the problems.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
while [[ "$delseconds" -ge "1" ]]; do
delseconds=$[${delseconds}-1]
echo -ne "StandBy - Portainer Validation Checks: $delseconds Seconds "'\r';
sleep 1; done
touch /pg/var/traefikportainer.check
wget -q "https://portainer.${domain}" -O "/pg/var/traefikportainer.check"
# If Portainer Detection Failed
if [[ $(cat /pg/var/traefikportainer.check) == "" ]]; then
rm -rf /pg/var/traefikportainer.check
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Portainer Check: FAILED!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SMART TIP: Check Portainer Now! View the Traefik Logs!
REASON 1 - CloudFlare: portainer is not set in the CNAME or A Records
REASON 2 - DuckDNS : Forgot to create a portainer or * - A Record
REASON 3 - Firewall : Everything is blocked
REASON 4 - DelayValue: Set too low; CF users reported using 90 to work
REASON 5 - OverUse : Deployed too much; hit LetsEncrypt Weekly Limit
REASON 6 - User : PG Locally; Route is not enable to reach server
REASON 7 - User : Bad values input or failed to read the wiki
REASON 8 - User : Forgot to point DOMAIN to CORRECT IP ADDRESS
There are multiple reason for failure! Visit the forums, wiki, or discord!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p 'Acknowledge Info | Press [ENTER] ' name < /dev/tty
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Traefik Process Failed!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SMART TIP: When fixed, rerun this process again!
NOTE 1: Possibly unable to reach subdomains
NOTE 2: Subdomains will provide insecure warnings
EOF
read -p 'Try Again! Acknowledge Info | Press [ENTER] ' name < /dev/tty
traefikstart
fi
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Portainer - https://portainer.${domain} detected!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
delseconds=4
while [[ "$delseconds" -ge "1" ]]; do
delseconds=$[${delseconds}-1]
echo -ne "StandBy - Rebuilding Containers in: $delseconds Seconds "'\r';
sleep 1; done
docker ps -a --format "{{.Names}}" > /pg/var/container.running
# Containers to Exempt
sed -i -e "/traefik/d" /pg/var/container.running
sed -i -e "/watchtower/d" /pg/var/container.running
sed -i -e "/wp-*/d" /pg/var/container.running # Exempt WP DataBases
sed -i -e "/x2go*/d" /pg/var/container.running
sed -i -e "/authclient/d" /pg/var/container.running
sed -i -e "/dockergc/d" /pg/var/container.running
sed -i -e "/oauth/d" /pg/var/container.running
sed -i -e "/portainer/d" /pg/var/container.running # Already Rebuilt
count=$(wc -l < /pg/var/container.running)
((count++))
((count--))
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ Traefik - Rebuilding Containers!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
sleep 3
for ((i=1; i<$count+1; i++)); do
app=$(sed "${i}q;d" /pg/var/container.running)
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
↘️ Traefik - Rebuilding [$app]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
sleep 3
#Rebuild Depending on Location
if [ -e "/pg/apps/programs/$app/start.sh" ]; then bash "/pg/apps/programs/$app/start.sh"; fi
done
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
read -p '✅️ Traefik - Containers Rebuilt! Acknowledge Info | Press [ENTER] ' name < /dev/tty
}
providerinterface() {
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Traefik - Select a Provider
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
pnum=0
mkdir -p /pg/var/prolist
rm -rf /pg/var/prolist/* 1>/dev/null 2>&1
ls -la "/pg/traefik/providers" | awk '{print $9}' | tail -n +4 > /pg/var/prolist/prolist.sh
while read p; do
let "pnum++"
echo "$p" > "/pg/var/prolist/$pnum"
echo "[$pnum] $p" >> /pg/var/prolist/final.sh
done </pg/var/prolist/prolist.sh
cat /pg/var/prolist/final.sh
echo
typed2=999999999
while [[ "$typed2" -lt "1" || "$typed2" -gt "$pnum" ]]; do
echo "QUITTING? Type >>> exit"
read -p 'Type Number | Press [ENTER]: ' typed2 < /dev/tty
if [[ "$typed2" == "exit" || "$typed2" == "Exit" || "$typed2" == "EXIT" ]]; then traefikstart; fi
echo
done
echo $(cat /pg/var/prolist/final.sh | grep "$typed2" | cut -c 5- | awk '{print $1}' | head -n 1) > /pg/var/traefik.provider
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 Provider Set!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTE: Make all changes first. Traefik must be deployed/redeployed for
this to take affect!
EOF
read -p 'Acknowledge Info | Press [ENTER] ' typed < /dev/tty
}
traefikbuilder() {
provider=$(cat /pg/var/traefik.provider)
echo "
- name: 'Setting PG ENV'
set_fact:
pg_env:
PUID: '1000'
PGID: '1000'
PROVIDER: $provider" | tee /pg/traefik/provider.yml 1>/dev/null 2>&1
mkdir -p /pg/var/prolist
rm -rf /pg/var/prolist/* 1>/dev/null 2>&1
ls -la "/pg/traefik/providers/$provider" | awk '{print $9}' | tail -n +4 > /pg/var/prolist/prolist.sh
while read p; do
echo -n " ${p}: " >> /pg/traefik/provider.yml
echo $(cat "/pg/var/traefik/$provider/$p") >> /pg/traefik/provider.yml
done </pg/var/prolist/prolist.sh
if [[ $(docker ps --format '{{.Names}}' | grep traefik) == "traefik" ]]; then
docker stop traefik 1>/dev/null 2>&1
docker rm traefik 1>/dev/null 2>&1; fi
file="/pg/data/traefik"
if [ -e "$file" ]; then rm -rf /pg/data/traefik; fi
ansible-playbook /pg/traefik/traefik.yml
postdeploy
}
traefikpaths() {
mkdir -p /pg/var/traefik
}
traefikstatus() {
if [ "$(docker ps --format '{{.Names}}' | grep traefik)" == "traefik" ]; then
deployed="DEPLOYED"; else deployed="NOT DEPLOYED"; fi
}