-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprepare-debian.sh
executable file
·869 lines (867 loc) · 40.1 KB
/
prepare-debian.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
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
#!/bin/bash
#
# ----------------------------------------------------------------------------
# Script to update OS (Debian) packages required for these scripts
# ============================================================================
# Created: 2024-05-31, by [email protected]
# Last modified: 2025-01-20, by [email protected]
# ----------------------------------------------------------------------------
# __ ___ ____ _ _ ___ _ _ ____
# \ \ / / \ | _ \| \ | |_ _| \ | |/ ___|_
# \ \ /\ / / _ \ | |_) | \| || || \| | | _(_)
# \ V V / ___ \| _ <| |\ || || |\ | |_| |_
# \_/\_/_/ \_\_| \_\_| \_|___|_| \_|\____(_)
#
# NOTE: This is the ONLY script of the "wgasm" project,
# ---- that actually REQUIRES that it be run either directly as
# the "root" user, or a user with similar 'sudo' privileges.
#
# ----------------------------------------------------------------------------
#
# Figure-out where the scripts folder is located ...
#
SCRIPTS_FOLDER="$( dirname -- "$( readlink -f -- "$0"; )"; )";
#
# Define some ANSI color escape sequences ...
#
ANSI_OFF="\033[0m";
ANSI_BLACK="\033[0;30m";
ANSI_RED="\033[0;31m";
ANSI_GREEN="\033[0;32m";
ANSI_BROWN="\033[0;33m";
ANSI_BLUE="\033[0;34m";
ANSI_PURPLE="\033[0;35m";
ANSI_CYAN="\033[0;36m";
ANSI_GRAYLT="\033[0;37m";
ANSI_GRAYDK="\033[1;30m";
ANSI_REDLT="\033[1;31m";
ANSI_GREENLT="\033[1;32m";
ANSI_YELLOW="\033[1;33m";
ANSI_BLUELT="\033[1;34m";
ANSI_PURPLELT="\033[1;35m";
ANSI_CYANLT="\033[1;36m";
ANSI_WHITE="\033[1;37m"
#
# Capture the time the scipt started in date-serial form ...
#
SCRIPT_DATESERIAL_START=$(date +%s);
#
# Dispaly standard output beginning message ...
#
DIVIDERLINE="+-----------------------------------------------------------------------------+";
OUPUTCONTENT="Begin: ${ANSI_CYANLT}${0##*/}${ANSI_OFF}, at ${ANSI_WHITE}$(date)${ANSI_OFF}";
DIVIDERLINE_LENGTH=${#DIVIDERLINE};
OUPUTCONTENT_NOANSI=$(echo -e "$OUPUTCONTENT" | ansi2txt);
OUPUTCONTENT_LENGTH=${#OUPUTCONTENT_NOANSI};
PAD_LENGTH=$(( $DIVIDERLINE_LENGTH - $(( $OUPUTCONTENT_LENGTH + 4 )) ));
OUTPUTPAD=$(printf '%*s' $PAD_LENGTH);
PADDED_OUTPUT="| $OUPUTCONTENT$OUTPUTPAD |";
PADDED_OUTPUT_NOANSI="| $OUPUTCONTENT_NOANSI$OUTPUTPAD |";
if [ -t 1 ]; then
echo -e "$DIVIDERLINE\n$PADDED_OUTPUT\n$DIVIDERLINE";
else
echo -e "$DIVIDERLINE\n$PADDED_OUTPUT_NOANSI\n$DIVIDERLINE";
fi;
#
# Check for Nike-Mode ("Just Do-It!") ...
#
PARAMETER="$1";
if [[ $PARAMETER != "" ]]; then
case $PARAMETER in
nike|-nike|--nike)
NIKE_MODE=true;
MESSAGE="${ANSI_PURPLELT}WARNING:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}Running in \"${ANSI_PURPLELT}Just Do-It! / Nike-Mode${ANSI_WHITE}\"${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
;;
*)
NIKE_MODE=false;
MESSAGE="${ANSI_YELLOW}WARNING:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}Ignoring unrecognized command-line parameter: \"${ANSI_YELLOW}$PARAMETER${ANSI_WHITE}\"${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
;;
esac;
else
NIKE_MODE=false;
MESSAGE="${ANSI_GREENLT}Update:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}No command-line parameter passed, disabling \"${ANSI_PURPLELT}Just Do-It! / Nike-Mode${ANSI_WHITE}\"${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
fi;
#
# Check if the user IS 'root' or HAS 'sudo' ...
#
if ! [[ $USER == "root" ]]; then
SUDO_DETECTION_COMMAND="sudo -v &> /dev/null && echo \"true\" || echo \"false\"";
SUDO_CHECK=${SUDO_DETECTION_COMMAND};
if ! [[ $SUDO_CHECK == true ]]; then
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}This script requires 'root' or equivelant 'sudo' access privileges!${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
exit 1;
fi;
fi;
#
# Verify that this is a Debian-family Linux distribution ...
#
COMPATIBLE_OS=false
OS_DETECTION_COMMAND="uname -a";
OS_DETECTION=$($OS_DETECTION_COMMAND);
echo "Distro Detection Command: $OS_DETECTION_COMMAND";
echo "Distro Detection Output (Mixed-Case): $OS_DETECTION";
OS_DETECTION=$(echo "$OS_DETECTION" | tr '[:upper:]' '[:lower:]');
echo "Distro Detection Output (Lower-Case): $OS_DETECTION";
if [[ $OS_DETECTION == *"debian"* ]]; then
echo -e "Distro Detected: ${ANSI_GREENLT}Debian${ANSI_OFF}";
COMPATIBLE_OS=true
fi;
if [[ $OS_DETECTION == *"mint"* ]]; then
echo -e "Distro Detected: ${ANSI_GREENLT}Mint${ANSI_OFF}";
COMPATIBLE_OS=true
fi;
if [[ $OS_DETECTION == *"antix"* ]]; then
echo -e "Distro Detected: ${ANSI_GREENLT}antiX${ANSI_OFF}";
COMPATIBLE_OS=true
fi;
if [[ $OS_DETECTION == *"elxr"* ]]; then
echo -e "Distro Detected: ${ANSI_GREENLT}eLxr${ANSI_OFF}";
COMPATIBLE_OS=true
fi;
if [[ $OS_DETECTION == *"ubuntu"* ]]; then
echo -e "Distro Detected: ${ANSI_GREENLT}Ubuntu${ANSI_OFF}";
COMPATIBLE_OS=true
fi;
if ! [[ $COMPATIBLE_OS == true ]]; then
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}A compatible Linux distribution (Debian family) has NOT been detected!${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
exit 1;
fi;
#
# Verify that a compatible architecture is installed ...
#
COMPATIBLE_ARCH=false
ARCH_DETECTION_COMMAND="arch";
ARCH_DETECTION=$($ARCH_DETECTION_COMMAND);
echo "Architecture Detection Command: $ARCH_DETECTION_COMMAND";
echo "Architecture Detection Output (Mixed-Case): $ARCH_DETECTION";
ARCH_DETECTION=$(echo "$ARCH_DETECTION" | tr '[:upper:]' '[:lower:]');
echo "Architecture Detection Output (Lower-Case): $ARCH_DETECTION";
if [[ $ARCH_DETECTION == x86_64* ]]; then
echo -e "Architecture Detected: ${ANSI_GREENLT}Intel: 64-bit (x86_64)${ANSI_OFF}";
COMPATIBLE_ARCH=true
fi;
if [[ $ARCH_DETECTION == i*86 ]]; then
echo -e "Architecture Detected: ${ANSI_GREENLT}Intel: 32-bit (x86/iX86)${ANSI_OFF}";
COMPATIBLE_ARCH=true
fi;
if [[ $ARCH_DETECTION == x32 ]]; then
echo -e "Architecture Detected: ${ANSI_GREENLT}Intel: 32-bit (x32)${ANSI_OFF}";
COMPATIBLE_ARCH=true
fi;
if [[ $ARCH_DETECTION == amd64 ]]; then
echo -e "Architecture Detected: ${ANSI_GREENLT}AMD: 64-bit (amd64)${ANSI_OFF}";
COMPATIBLE_ARCH=true
fi;
if [[ $ARCH_DETECTION == arm ]]; then
echo -e "Architecture Detected: ${ANSI_GREENLT}Arm${ANSI_OFF}";
COMPATIBLE_ARCH=false
fi;
if [[ $ARCH_DETECTION == arm64 ]]; then
echo -e "Architecture Detected: ${ANSI_GREENLT}Arm: 64-bit (arm64)${ANSI_OFF}";
COMPATIBLE_ARCH=false
fi;
if ! [[ $COMPATIBLE_ARCH == true ]]; then
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}A compatible Linux architecture (Intel comptabile) has NOT been detected!${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
exit 1;
fi;
#
# Enable 32-bit Intel architecture support:
#
echo -e "\n${ANSI_BLUELT}INSTALLING:${ANSI_WHITE} 32-bit Intel architecture support (Possibly already installed)${ANSI_OFF} ...";
sudo dpkg --add-architecture i386;
#
# Latest updates for existing packages:
#
echo -e "\n${ANSI_BLUELT}INSTALLING:${ANSI_WHITE} Latest updates for existing packages${ANSI_OFF} ...";
sudo apt-get update;
sudo apt-get upgrade -y;
sudo apt-get autoremove -y --purge;
#
# General OS requirements:
#
echo -e "\n${ANSI_BLUELT}INSTALLING:${ANSI_WHITE} General OS requirements (Hopefully already installed)${ANSI_OFF} ...";
sudo apt-get install -y openssh-server coreutils sudo nano;
#
# Required for virtual machine:
# (Enable if running under VirtualBox, VMware, etc.)
#
#echo -e "\nINSTALLING: Recommended for virtual machine ...";
#echo -e "(No harm-done if it is not a virtual machine)";
#sudo apt-get install -y open-vm-tools exfat-fuse;
#
# Required if using Webmin:
#
echo -e "\n${ANSI_BLUELT}INSTALLING:${ANSI_WHITE} Required or recommended if using Webmin${ANSI_OFF} ..";
sudo apt-get install -y ntp sntp ntpdate apt-transport-https dialog xmlstarlet iptables;
#
# Required for SteamCMD and/or game-servers:
#
echo -e "\n${ANSI_BLUELT}INSTALLING:${ANSI_WHITE} Required by SteamCMD - or HLDS / SrcDS, etc.${ANSI_OFF} ...";
sudo apt-get install -y libstdc++6 libstdc++6:i386 lib32gcc-s1 ncompress bzip2;
#
# Required by scripts:
#
echo -e "\n${ANSI_BLUELT}INSTALLING:${ANSI_WHITE} Required by scripts (Many probably already installed)${ANSI_OFF} ...";
sudo apt-get install -y gawk git grep tree wget curl git htop screen net-tools bind9-dnsutils p7zip-full zip unzip tar dialog figlet colorized-logs dos2unix bsdmainutils;
#
# Required for ANSI-color processsing (and removal):
#
sudo apt-get install -y olorized-logs;
#
# Testing that various required commands/utilities work now ...
#
# Define some stuff ..
#
TEST_ERROR_CHECK=false;
#
# Actually test each command (tesing parameters vary by command) ...
#
echo -e "\n${ANSI_BLUELT}TESTING:${ANSI_WHITE} Testing that various required commands/utilities work now (Many probably worked before)${ANSI_OFF} ...";
echo -e -n "Testing 'cat': ";cat --version &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'wc': ";wc --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'more': ";echo "test" | more &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing '(g)awk': ";gawk -V &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'sed': ";sed --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'tr': ";tr --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'column': ";column --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'tail': ";tail --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'printf': ";printf "test" &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'grep': ";grep --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'tar': ";tar --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'gzip': ";gzip --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'wget': ";wget --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'curl': ";curl --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'tree': ";tree --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'git': ";git --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'screen': ";screen -v &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing '7za': ";7za --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'zip': ";zip --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'unzip': ";unzip --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'uncompress': ";uncompress -h &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'bzip2': ";bzip2 --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'dialog': ";dialog --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'dos2unix': ";echo -e "test" | dos2unix &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'figlet': ";figlet "test" &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'netstat': ";netstat --help &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'dig': ";dig -h &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
echo -e -n "Testing 'ansi2txt': ";echo -e "test" | ansi2txt &> /dev/null && echo -e "${ANSI_GREENLT}Pass.${ANSI_OFF}" || { echo -e "${ANSI_REDLT}FAIL!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
#
# If any of thsoe checks failed, display an error messsage ...
#
if [[ $TEST_ERROR_CHECK == true ]]; then
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}One or more prerequisite commands or utilities are missing!\n${ANSI_OFF}";
MESSAGE+="${ANSI_WHITE}You MUST resolve these errors by intalling the appropiate\n${ANSI_OFF}";
MESSAGE+="${ANSI_WHITE}packages for failed tests before proceeding!${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
exit 1;
else
MESSAGE="${ANSI_GREENLT}PASSED:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}So far, everything looks good!${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
fi;
#
# Attempt to determine the computer's (local) IP address ...
#
SERVER_LOCAL_IP_ADDRESS=$(hostname --all-ip-addresses | cut -d' ' -f1);
#
# Attempt to determine the computer's (public) IP address ...
#
SERVER_PUBLIC_IP_ADDRESS=$(dig +short txt o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{print $2}');
#
# Test if Webmin is already installed ...
#
sudo dpkg -l | grep webmin 2> /dev/null > /dev/null;
if [[ "$?" -gt 0 ]]; then
WEBMIN_CHECK=false;
else
WEBMIN_CHECK=true
fi;
if [[ $WEBMIN_CHECK == false ]]; then
#
# If Webmin is not installed, offer to install it ...
#
if [[ $NIKE_MODE == true ]]; then
PROMPT_INPUT="nike";
else
read -p "Would you like to install \"Webmin\" now? (y/n)" PROMPT_INPUT;
fi;
case $PROMPT_INPUT in
y|Y|yes|Yes|YES|nike)
#
# Setup repos for Webmin installation ...
#
WEBMIN_FOLDER="/etc/webmin";
cd $WEBMIN_FOLDER;
echo "Downloading the \"Webmin\" repository-setup script (setup-repos.sh ) ...";
wget -O setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
chmod +x ./setup-repos.sh -f && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
sudo ./setup-repos.sh -f && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
if [[ $TEST_ERROR_CHECK == true ]]; then
TEST_USER_EXISTS=false;
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}There was a problem downloading (or running) the \"Webmin\" repository-setup script (setup-repos.sh)!${ANSI_OFF}\n";
echo -e "\n$MESSAGE\n";
exit 1;
fi;
rm -f setup-repos.sh 2> /dev/null > /dev/null;
#
# Install Webmin ...
#
echo "Attempting to install \"Webmin\" ...";
sudo apt-get install -y --install-recommends ntpdate iptables webmin && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
sudo service webmin stop && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
echo "Changing Webmin default port to \"8443\" ...";
sudo sed -i 's/port=10000/port=8443/g' /etc/webmin/miniserv.conf 2> /dev/null > /dev/null && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
sudo sed -i 's/listen=10000/listen=8443/g' /etc/webmin/miniserv.conf 2> /dev/null > /dev/null && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
echo "Enabling Webmin \"referrers\" ...";
sudo sed -i 's/referers_none=1/referers_none=0/g' /etc/webmin/config 2> /dev/null > /dev/null && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
sudo service webmin restart && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
if [[ $TEST_ERROR_CHECK == true ]]; then
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}There was a problem installing (or configuring) the \"Webmin\"!${ANSI_OFF}\n";
echo -e "\n$MESSAGE\n";
exit 1;
else
MESSAGE="${ANSI_GREENLT}PASSED:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}The \"Webmin\" should now be installed and reachable in a web browser at:${ANSI_OFF}\n";
MESSAGE+="${ANSI_YELLOW}https://$SERVER_LOCAL_IP_ADDRESS:8443${ANSI_OFF}\n";
echo -e "\n$MESSAGE\n";
fi;
#
# Create /root/.filemin/.bookmarks file ...
#
echo "Setting-up default File Manager \"bookmarks\" ...";
FILEMIN_BOOKMARKS_FOLDER="/root/.filemin/";
mkdir $FILEMIN_BOOKMARKS_FOLDER 2> /dev/null > /dev/null;
FILEMIN_BOOKMARKS_FILE="$FILEMIN_BOOKMARKS_FOLDER/.bookmarks";
echo -e "/" > $FILEMIN_BOOKMARKS_FILE;
echo -e "/root" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/etc" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/etc/webmin" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/home" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/home/game-servers" >> $FILEMIN_BOOKMARKS_FILE;
chown game-servers:game-serves $FILEMIN_BOOKMARKS_FILE 2> /dev/null > /dev/null;
;;
n|N|no|No|NO)
#
# Do not install Webmin, but warn about creating it ...
#
MESSAGE="${ANSI_YELLOW}WARNING:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}Okay, whatever - if you want to make your life harder than it needs to be!${ANSI_OFF}\n";
echo -e "\n$MESSAGE\n";
;;
*)
#
# Something else happended, abort ...
#
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="DUDE! I do not know what you mean? You were supposed to press \"Y\" or \"N\"!";
echo -e "\n$MESSAGE\n";
exit 1;
;;
esac;
else
MESSAGE="${ANSI_GREENLT}Update:${ANSI_OFF}\n";
MESSAGE+="Looks like \"Webmin\" is already installed.";
echo -e "\n$MESSAGE\n";
fi;
#
# Test if Webmin is already installed ...
#
sudo dpkg -l | grep webmin 2> /dev/null > /dev/null;
if [[ "$?" -gt 0 ]]; then
WEBMIN_CHECK=false;
else
WEBMIN_CHECK=true
fi;
if [[ $WEBMIN_CHECK == true ]]; then
#
# If Webmin IS installed, offer to install "custom commands" for Webmin ...
#
if [[ $NIKE_MODE == true ]]; then
PROMPT_INPUT="nike";
else
read -p "Would you like to install Weasels \"Custom Commands\" into Webmin now? (y/n)" PROMPT_INPUT;
fi;
case $PROMPT_INPUT in
y|Y|yes|Yes|YES|nike)
#
# Download the gzipped-tarball archive of Webmin "Custom Commands" ...
#
WEBMIN_FOLDER="/etc/webmin";
cd $WEBMIN_FOLDER;
CUSTOM_COMMANDS_FILE="webmin-custom.tar.gz";
echo "Downloading the Webmin \"Custom Commands\" archive (webmin-custom.tar.gz) ...";
wget -O $CUSTOM_COMMANDS_FILE https://github.com/Mecha-Weasel/wgasm/raw/main/webmin-custom.tar.gz && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
#
# Extract the gzipped-tarball archive of Webmin "Custom Commands" ...
#
tar -xzf $CUSTOM_COMMANDS_FILE && TEST_ERROR_CHECK=false || TEST_ERROR_CHECK=true;
#
# Check if any errors were thrown ...
#
if [[ $TEST_ERROR_CHECK == true ]]; then
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}There was a problem downloading (or extracting) the Webmin \"Custom Commands\"!${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
exit 1;
fi;
#rm -f $CUSTOM_COMMANDS_FILE 2> /dev/null > /dev/null;
;;
n|N|no|No|NO)
#
# Do not install the "wgasm" system, but warn about creating it ...
#
MESSAGE="${ANSI_YELLOW}WARNING:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}Okay, whatever - if you want to make your life harder than it needs to be!${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
;;
*)
#
# Something else happended, abort ...
#
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="DUDE! I do not know what you mean? You were supposed to press \"Y\" or \"N\"!";
echo -e "\n$MESSAGE\n";
exit 1;
;;
esac;
else
MESSAGE="${ANSI_YELLOW}WARNING:${ANSI_OFF}\n";
MESSAGE+="Looks like \"Webmin\" is NOT already installed, so NOT offering to install Webmin \"Custom Commands\".";
echo -e "\n$MESSAGE\n";
fi;
#
# Test ti see if the game-servers user already exists ..
#
echo "Checking to see if the \"game-servers\" user already exists ...";
sudo id game-servers &> /dev/null && TEST_USER_EXISTS=true || TEST_USER_EXISTS=false;
if [[ $TEST_USER_EXISTS == false ]]; then
#
# Prompt if the game-servers user should be created now ...
#
if [[ $NIKE_MODE == true ]]; then
PROMPT_INPUT="nike";
else
read -p "Would you like create the \"game-servers\" user now? (y/n)" PROMPT_INPUT;
fi;
case $PROMPT_INPUT in
y|Y|yes|Yes|YES|nike)
#
# Create the game-servers user ...
#
echo "Creating user \"game-servers\" ...";
{ sudo useradd -m -s /bin/bash game-servers; echo -e "n0t.Password!\nn0t.Password!\n" | sudo passwd game-servers; } && { echo -e "${ANSI_GREENLT}User created.${ANSI_OFF}"; TEST_ERROR_CHECK=false; } || { echo -e "${ANSI_REDLT}User failed to create!${ANSI_OFF}"; TEST_ERROR_CHECK=true; };
if [[ $TEST_ERROR_CHECK == true ]]; then
TEST_USER_EXISTS=false;
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}There was a problem creating the \"game-servers\" user!\n${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
exit 1;
else
TEST_USER_EXISTS=true;
MESSAGE="${ANSI_GREENLT}PASSED:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}The user \"game-servers\" should now be created, and have the default password of \"${ANSI_YELLOW}n0t.Password${ANSI_OFF}\" - which of course you should ${ANSI_REDLT}immediately to change to something else${ANSI_OFF}.${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
fi;
;;
n|N|no|No|NO)
#
# Do not create the game-servers user, but warn about creating it ...
#
MESSAGE="${ANSI_YELLOW}WARNING:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}Okay, whatever - just remember to create it later yourself! Remember that:\n${ANSI_OFF}";
MESSAGE+="${ANSI_WHITE}1) The users shell must be set to use \"${ANSI_YELLOW}/bin/bash${ANSI_OFF}\" for the scripts to run correctly!${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}2) The user must be named (exactly) \"${ANSI_YELLOW}game-servers${ANSI_OFF}\" if you want the related Webmin \"Custom Commands\" to work!${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
;;
*)
#
# Something else happended, abort ...
#
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="DUDE! I do not know what you mean? You were supposed to press \"Y\" or \"N\"!";
echo -e "\n$MESSAGE\n";
exit 1;
;;
esac;
else
#
# Skip creating the game-servers user since it already exists ...
#
MESSAGE="${ANSI_GREENLT}Update:${ANSI_OFF}\n";
MESSAGE+="Looks like the \"game-servers\" user already exists, skipping creation of it ...";
echo -e "\n$MESSAGE\n";
fi;
#
# If game-servers user (now) exists, offer to download the installation script as that user ...
#
sudo id game-servers &> /dev/null && TEST_USER_EXISTS=true || TEST_USER_EXISTS=false;
if [[ $TEST_USER_EXISTS == true ]]; then
#
# Offer to download the installer for the "wgasm" system, as the game-servers user ...
#
if [[ $NIKE_MODE == true ]]; then
PROMPT_INPUT="nike";
else
read -p "Would you like to pre-download the latest \"wgasm\" installation script (install-wgasm.sh) under the \"game-servers\" user now? (y/n)" PROMPT_INPUT;
fi;
case $PROMPT_INPUT in
y|Y|yes|Yes|YES|nike)
#
# Create the game-servers user ...
#
echo "Downloading the \"wgasm\" installation script (install-wgasm.sh) under the \"game-servers\" user ...";
DOWNLOAD_COMMAND="wget -O install-wgasm.sh https://github.com/Mecha-Weasel/wgasm/raw/main/install-wgasm.sh";
SUDO_DOWNLOAD_COMMAND="sudo -i -u game-servers $DOWNLOAD_COMMAND";
{ $SUDO_DOWNLOAD_COMMAND; } && { TEST_ERROR_CHECK=false; } || { TEST_ERROR_CHECK=true; };
if [[ $TEST_ERROR_CHECK == true ]]; then
TEST_USER_EXISTS=false;
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}There was a problem downloading the \"wgasm\" installation script under the \"${ANSI_YELLOW}game-servers${ANSI_WHITE}\" user!${ANSI_OFF}\n";
echo -e "\n$MESSAGE\n";
exit 1;
else
TEST_USER_EXISTS=true;
MESSAGE="${ANSI_GREENLT}PASSED:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}The \"wgasm\" installation script (install-wgasm.sh) should now be pre-downloaded under the \"${ANSI_YELLOW}game-servers${ANSI_WHITE}\" user.${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}To install the \"wgasm\" system:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}1) Login as \"${ANSI_YELLOW}game-servers${ANSI_WHITE}\" user.${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}2) Mark the ${ANSI_YELLOW}install-wgasm.sh${ANSI_WHITE} file as executable (using the command: \"chmod +x ~/install-wgasm.sh\").${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}3) Run the ${ANSI_YELLOW}install-wgasm.sh${ANSI_WHITE} script (using the command: \"~/install-wgasm.sh\").${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
sudo -i -u game-servers ls -lah;
fi;
;;
n|N|no|No|NO)
#
# Do not download the "wgasm" installer, but warn about creating it ...
#
MESSAGE="${ANSI_YELLOW}WARNING:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}Okay, whatever - just remember to install it later yourself!${ANSI_OFF}\n";
MESSAGE+="Remember when installing the \"wgasm\" system, be sure to be logged-in as the \"${ANSI_YELLOW}game-servers${ANSI_WHITE}\" user!${ANSI_OFF}";
echo -e "\n$MESSAGE\n";
;;
*)
#
# Something else happended, abort ...
#
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="DUDE! I do not know what you mean? You were supposed to press \"Y\" or \"N\"!";
echo -e "\n$MESSAGE\n";
exit 1;
;;
esac;
else
#
# Skip downloading "wgasm" installer if the game-servers user does not exist ...
#
MESSAGE="${ANSI_GREENLT}Update:${ANSI_OFF}\n";
MESSAGE+="Since \"game-servers\" does not exist, skipping offering to install the \"wgasm\" system.";
echo -e "\n$MESSAGE\n";
fi;
#
# Test if Webmin is installed AND game-servers user exists ...
#
sudo dpkg -l | grep webmin 2> /dev/null > /dev/null;
if [[ "$?" -gt 0 ]]; then
WEBMIN_CHECK=false;
else
WEBMIN_CHECK=true
fi;
sudo id game-servers &> /dev/null && TEST_USER_EXISTS=true || TEST_USER_EXISTS=false;
if [ $WEBMIN_CHECK == true -a $TEST_USER_EXISTS == true ]; then
#
# Offer to setup game-servers as a Webmin user ...
#
if [[ $NIKE_MODE == true ]]; then
PROMPT_INPUT="nike";
else
read -p "Would you like setup \"game-servers\" as a Webmin user now? (y/n)" PROMPT_INPUT;
fi;
WEBMIN_FOLDER="/etc/webmin";
case $PROMPT_INPUT in
y|Y|yes|Yes|YES|nike)
#
# Setup "game-servers" as a Webmin user ...
#
echo "Setting-up \"game-servers\" as a Webmin user ...";
#
# Add "game-servers" to webmin/miniserv.users ...
#
# root:x:0
# game-servers:x::::::::0::::
#
WEBMIN_MINISERV_FILE="$WEBMIN_FOLDER/miniserv.users";
sed -i '/^game-servers/d' $WEBMIN_MINISERV_FILE;
WEBMIN_MINISERV_ENTRY="game-servers:x::::::::0::::";
echo "$WEBMIN_MINISERV_ENTRY" >> $WEBMIN_MINISERV_FILE;
#
# Add "game-servers" to webmin/config ...
#
# realname_game-servers=Game-Servers
# notabs_game-servers=2
#
WEBMIN_CONFIG_FILE="$WEBMIN_FOLDER/config";
#
sed -i '/^realname_game-servers/d' $WEBMIN_CONFIG_FILE;
WEBMIN_CONFIG_ENTRY="realname_game-servers=Game-Servers";
echo "$WEBMIN_CONFIG_ENTRY" >> $WEBMIN_CONFIG_FILE;
#
sed -i '/^notabs_game-servers/d' $WEBMIN_CONFIG_FILE;
WEBMIN_CONFIG_ENTRY="notabs_game-servers=2";
echo "$WEBMIN_CONFIG_ENTRY" >> $WEBMIN_CONFIG_FILE;
#
# Add "game-servers" to webmin/webmin.acl ...
#
# root: acl adsl-client apache at backup-config bacula-backup bandwidth bind8 change-user cluster-copy cluster-cron cluster-passwd cluster-shell cluster-software cluster-useradmin cluster-usermin cluster-webmin cpan cron custom dfsadmin dhcpd dovecot exim exports fail2ban fdisk fetchmail filemin filter firewall firewall6 firewalld fsdump heartbeat htaccess-htpasswd idmapd inetd init inittab ipfilter ipfw ipsec iscsi-client iscsi-server iscsi-target iscsi-tgtd krb5 ldap-client ldap-server ldap-useradmin logrotate logviewer lpadmin lvm mailboxes mailcap man mount mysql net nis openslp package-updates pam pap passwd phpini postfix postgresql ppp-client pptp-client pptp-server proc procmail proftpd qmailadmin quota raid samba sarg sendmail servers shell shorewall shorewall6 smart-status smf software spam squid sshd status stunnel syslog-ng syslog system-status tcpwrappers time tunnel updown useradmin usermin webalizer webmin webmincron webminlog xinetd xterm
# game-servers: custom filemin updown uthentic-theme
#
WEBMIN_ACL_FILE="$WEBMIN_FOLDER/webmin.acl";
sed -i '/^game-servers/d' $WEBMIN_ACL_FILE;
WEBMIN_ACL_ENTRY+="game-servers:";
WEBMIN_ACL_ENTRY+=" custom";
WEBMIN_ACL_ENTRY+=" filemin";
WEBMIN_ACL_ENTRY+=" updown";
WEBMIN_ACL_ENTRY+=" uthentic-theme";
echo -e "$WEBMIN_ACL_ENTRY" >> $WEBMIN_ACL_FILE;
#
# Create webmin/game-servers.acl file ...
#
# gedit2=
# readonly=0
# feedback=0
# gedit_mode=0
# nodot=0
# uedit=
# webminsearch=0
# uedit2=
# otherdirs=
# rpc=0
# negative=1
# fileunix=game-servers
# root=
# uedit_mode=0
# gedit=
#
GAMESEVERS_ACL_FILE="$WEBMIN_FOLDER/game-servers.acl";
echo -e "gedit2=" > $GAMESEVERS_ACL_FILE;
echo -e "readonly=0" >> $GAMESEVERS_ACL_FILE;
echo -e "feedback=0" >> $GAMESEVERS_ACL_FILE;
echo -e "gedit_mode=0" >> $GAMESEVERS_ACL_FILE;
echo -e "nodot=0" >> $GAMESEVERS_ACL_FILE;
echo -e "uedit=" >> $GAMESEVERS_ACL_FILE;
echo -e "webminsearch=0" >> $GAMESEVERS_ACL_FILE;
echo -e "uedit2=" >> $GAMESEVERS_ACL_FILE;
echo -e "otherdirs=" >> $GAMESEVERS_ACL_FILE;
echo -e "rpc=0" >> $GAMESEVERS_ACL_FILE;
echo -e "negative=1" >> $GAMESEVERS_ACL_FILE;
echo -e "fileunix=game-servers" >> $GAMESEVERS_ACL_FILE;
echo -e "root=" >> $GAMESEVERS_ACL_FILE;
echo -e "uedit_mode=0" >> $GAMESEVERS_ACL_FILE;
echo -e "gedit=" >> $GAMESEVERS_ACL_FILE;
#
# Create webmin/updown/game-servers.acl file ...
#
# upload=1
# home=1
# dirs=/home/game-servers
# fetch=1
# max=
# mode=1
# download=1
# users=game-servers
#
WEBMIN_UPDOWN_FILE="$WEBMIN_FOLDER/updown/game-servers.acl";
echo -e "upload=1" > $WEBMIN_UPDOWN_FILE;
echo -e "home=1" >> $WEBMIN_UPDOWN_FILE;
echo -e "dirs=/home/game-servers" >> $WEBMIN_UPDOWN_FILE;
echo -e "fetch=1" >> $WEBMIN_UPDOWN_FILE;
echo -e "max=" >> $WEBMIN_UPDOWN_FILE;
echo -e "mode=1" >> $WEBMIN_UPDOWN_FILE;
echo -e "download=1" >> $WEBMIN_UPDOWN_FILE;
echo -e "users=game-servers" >> $WEBMIN_UPDOWN_FILE;
#
# Create webmin/filemin/game-servers.acl file ...
#
# work_as_user=game-servers
# work_as_root=0
# max=
# allowed_paths=/home/game-servers
# allowed_for_edit=application-x-php application-x-ruby application-xml application-xslt+xml application-javascript application-x-shellscript application-x-perl application-x-yaml application-json application-x-x509-ca-cert application-pkix-cert application-sql application-x-sql application-x-asp application-x-aspx application-xhtml+xml
#
WEBMIN_FILEMIN_FILE="$WEBMIN_FOLDER/filemin/game-servers.acl";
echo -e "work_as_user=game-servers" > $WEBMIN_FILEMIN_FILE;
echo -e "work_as_root=0" >> $WEBMIN_FILEMIN_FILE;
echo -e "max=" >> $WEBMIN_FILEMIN_FILE;
echo -e "allowed_paths=/home/game-servers" >> $WEBMIN_FILEMIN_FILE;
echo -e "allowed_for_edit=application-x-php application-x-ruby application-xml application-xslt+xml application-javascript application-x-shellscript application-x-perl application-x-yaml application-json application-x-x509-ca-cert application-pkix-cert application-sql application-x-sql application-x-asp application-x-aspx application-xhtml+xml" >> $WEBMIN_FILEMIN_FILE;
#
# Create webmin/filemin/prefs.game-servers file ...
#
# config_portable_module_filemanager_tree_view_depth=3
# config_portable_module_filemanager_calculate_size=true
# config_portable_module_filemanager_view_limit=512000
# config_portable_module_filemanager_checksum_limit=1024000
# config_portable_module_filemanager_tree_expand_search=true
# config_portable_module_filemanager_editor_detect_encoding=true
# config_portable_module_filemanager_files_safe_mode=true
# config_portable_module_filemanager_hovered_toolbar=false
# config_portable_module_filemanager_switch_users=true
# config_portable_module_filemanager_tree_exclude_on_first_load=true
# per_page=500
# columns=type,size,owner_user,permissions,last_mod_time
# config_portable_module_filemanager_records_for_server_pagination=1000
# config_portable_module_filemanager_editor_tabs_to_spaces=false
# config_portable_module_filemanager_editor_maximized=false
# config_portable_module_filemanager_hide_tree_view=true
# config_portable_module_filemanager_remember_tabs=false
# config_portable_module_filemanager_force_tar=true
# config_portable_module_filemanager_hide_actions=true
# config_portable_module_filemanager_move_to_trash=false
# config_portable_module_filemanager_default_sort=0
# config_portable_module_filemanager_hide_toolbar=false
# config_portable_module_filemanager_show_dot_files=true
#
WEBMIN_FILEMIN_FILE="$WEBMIN_FOLDER/filemin/prefs.game-servers";
echo -e "config_portable_module_filemanager_tree_view_depth=3" > $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_calculate_size=true" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_view_limit=512000" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_checksum_limit=1024000" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_tree_expand_search=true" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_editor_detect_encoding=true" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_files_safe_mode=true" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_hovered_toolbar=false" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_switch_users=true" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_tree_exclude_on_first_load=true" >> $WEBMIN_FILEMIN_FILE;
echo -e "per_page=500" >> $WEBMIN_FILEMIN_FILE;
echo -e "columns=type,size,owner_user,permissions,last_mod_time" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_records_for_server_pagination=1000" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_editor_tabs_to_spaces=false" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_editor_maximized=false" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_hide_tree_view=true" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_remember_tabs=false" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_force_tar=true" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_hide_actions=true" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_move_to_trash=false" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_default_sort=0" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_hide_toolbar=false" >> $WEBMIN_FILEMIN_FILE;
echo -e "config_portable_module_filemanager_show_dot_files=true" >> $WEBMIN_FILEMIN_FILE;
#
# Create /home/game-servers/.filemin/.bookmarks file ...
#
# /
# /backups
# /logs
# /wgasm
# /wgasm/backup-configs
# /wgasm/cron
# /wgasm/data
# /wgasm/include
# /wgasm/webmin
#
FILEMIN_BOOKMARKS_FOLDER="/home/game-servers/.filemin/";
mkdir $FILEMIN_BOOKMARKS_FOLDER 2> /dev/null > /dev/null;
FILEMIN_BOOKMARKS_FILE="$FILEMIN_BOOKMARKS_FOLDER/.bookmarks";
echo -e "/" > $FILEMIN_BOOKMARKS_FILE;
echo -e "/backups" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/logs" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/stencils" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/wgasm" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/wgasm/backup-configs" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/wgasm/cron" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/wgasm/data" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/wgasm/include" >> $FILEMIN_BOOKMARKS_FILE;
echo -e "/wgasm/webmin" >> $FILEMIN_BOOKMARKS_FILE;
chown -R game-servers:game-servers $FILEMIN_BOOKMARKS_FOLDER 2> /dev/null > /dev/null;
chown game-servers:game-servers $FILEMIN_BOOKMARKS_FILE 2> /dev/null > /dev/null;
#
# Check for any errors thrown ...
#
if [[ $TEST_ERROR_CHECK == true ]]; then
TEST_USER_EXISTS=false;
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}There was a problem setting-up \"game-servers\" as a Webmin user!${ANSI_OFF}\n";
echo -e "\n$MESSAGE\n";
exit 1;
else
#
# Skip creating the game-servers user since it already exists ...
#
MESSAGE="${ANSI_GREENLT}Update:${ANSI_OFF}\n";
MESSAGE+="The Linux user \"game-servers\" should now be setup as a Webmin user also.";
echo -e "\n$MESSAGE\n";
fi;
;;
n|N|no|No|NO)
#
# Do not install the Webmin, but warn about creating it ...
#
MESSAGE="${ANSI_YELLOW}WARNING:${ANSI_OFF}\n";
MESSAGE+="${ANSI_WHITE}Okay, whatever - if you want to make your life harder than it needs to be!${ANSI_OFF}\n";
echo -e "\n$MESSAGE\n";
;;
*)
#
# Something else happended, abort ...
#
MESSAGE="${ANSI_REDLT}ERROR:${ANSI_OFF}\n";
MESSAGE+="DUDE! I do not know what you mean? You were supposed to press \"Y\" or \"N\"!";
echo -e "\n$MESSAGE\n";
exit 1;
;;
esac;
else
MESSAGE="${ANSI_GREENLT}Update:${ANSI_OFF}\n";
MESSAGE+="Skipping offering to setup \"game-servers\" in Webmin, because prerequisites not met.";
echo -e "\n$MESSAGE\n";
fi;
#
# Capture the time the scipt ended in date-serial form ...
#
SCRIPT_DATESERIAL_END=$(date +%s);
#
# Calculate how-long the script was running ...
#
if [[ $SCRIPT_DATESERIAL_START ]]; then
SCRIPT_DATESERIAL_DURATION=$(( $SCRIPT_DATESERIAL_END - $SCRIPT_DATESERIAL_START ));
else
SCRIPT_DATESERIAL_DURATION="";
fi;
#
# Dispaly standard output ending message ...
#
if [[ $SCRIPT_DATESERIAL_DURATION ]]; then
OUPUTCONTENT="End: ${ANSI_CYANLT}${0##*/}${ANSI_OFF}, at ${ANSI_WHITE}$(date) ($SCRIPT_DATESERIAL_DURATION secs)${ANSI_OFF}";
else
OUPUTCONTENT="End: ${ANSI_CYANLT}${0##*/}${ANSI_OFF}, at ${ANSI_WHITE}$(date)${ANSI_OFF}";
fi;
DIVIDERLINE="+-----------------------------------------------------------------------------+";
DIVIDERLINE_LENGTH=${#DIVIDERLINE};
OUPUTCONTENT_NOANSI=$(echo -e "$OUPUTCONTENT" | ansi2txt);
OUPUTCONTENT_LENGTH=${#OUPUTCONTENT_NOANSI};
PAD_LENGTH=$(( $DIVIDERLINE_LENGTH - $(( $OUPUTCONTENT_LENGTH + 4 )) ));
OUTPUTPAD=$(printf '%*s' $PAD_LENGTH);
PADDED_OUTPUT="| $OUPUTCONTENT$OUTPUTPAD |";
PADDED_OUTPUT_NOANSI="| $OUPUTCONTENT_NOANSI$OUTPUTPAD |";
if [ -t 1 ]; then
echo -e "$DIVIDERLINE\n$PADDED_OUTPUT\n$DIVIDERLINE";
else
echo -e "$DIVIDERLINE\n$PADDED_OUTPUT_NOANSI\n$DIVIDERLINE";
fi;
#
# ... thats all folks!
#