-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathget5_auto_installer.sh
More file actions
executable file
·954 lines (851 loc) · 31.3 KB
/
get5_auto_installer.sh
File metadata and controls
executable file
·954 lines (851 loc) · 31.3 KB
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
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
#!/bin/bash
# Project: Get5 Web API Auto Installer for PhlexPlexico Get5-Web
# Author: TandelK
# Credits : Splewis , PhlexPlexico , xe1os
# Purpose: Get5 Web API Panel installation script
# Website :
version="1.00"
## Color Support Functions
greenMessage() {
echo -e "\\033[32;1m${@}\033[0m"
}
cyanMessage() {
echo -e "\\033[36;1m${@}\033[0m"
}
redMessage() {
echo -e "\\033[31;1m${@}\033[0m"
}
yellowMessage() {
echo -e "\\033[33;1m${@}\033[0m"
}
greenOneLineMessage() {
echo -en "\\033[32;1m${@}\033[0m"
}
cyanOneLineMessage() {
echo -en "\\033[36;1m${@}\033[0m"
}
yellowOneLineMessage() {
echo -en "\\033[33;1m${@}\033[0m"
}
# Checking for Root
if [[ $EUID -ne 0 ]]; then
redMessage "This script must be run as root as it require packages to be downloaded"
exit 1
fi
##Get5 WSGI Create Function
function wsgi_create()
{
if [ -f "/var/www/get5-web/get5.wsgi" ]
then
redMessage "Get5.wsgi already exist"
break;
else
if [ ! -d "/var/www/get5-web" ]
then
redMessage "Get5 Web Installation not detected , Please install Get5-Web first"
break;
else
cd /var/www/get5-web
wsgifile="get5.wsgi"
echo "Creating WSGI Config File"
echo "#!/usr/bin/python">> $wsgifile
echo "">> $wsgifile
echo "activate_this = '/var/www/get5-web/venv/bin/activate_this.py'">> $wsgifile
echo "execfile(activate_this, dict(__file__=activate_this))">> $wsgifile
echo "">> $wsgifile
echo "import sys">> $wsgifile
echo "import logging">> $wsgifile
echo "logging.basicConfig(stream=sys.stderr)">> $wsgifile
echo "">> $wsgifile
echo 'folder = "/var/www/get5-web"'>> $wsgifile
echo "if not folder in sys.path:">> $wsgifile
echo " sys.path.insert(0, folder)">> $wsgifile
echo 'sys.path.insert(0,"")'>> $wsgifile
echo "">> $wsgifile
echo "from get5 import app as application">> $wsgifile
echo "import get5">> $wsgifile
echo "get5.register_blueprints()">> $wsgifile
chmod +x get5.wsgi
greenMessage "File created sucessfully in /var/www/get5-web/get5.wsgi"
fi
fi
}
#Apache Config
function apacheconfig()
{
cd /etc/apache2/sites-enabled/
cyanMessage "Please Enter Panel Address without http or https protocol [eg. g5panel.website.com]"
read sitename
greenMessage "You have entered $sitename"
while [[ $sitename == http* || $sitename == https* ]];
do
redMessage "Please re-enter Website Address without http or https protocol [eg. g5panel.website.com]"
read -r sitename
greenMessage "You have entered $sitename"
done
cyanMessage "Enter Admin Email address: ";
read adminemail
cyanMessage "Do you want to enable Demo Rewrite allowing Demos upload to different website/ftp for clients to download ?"
read -p "True or False(Case Sensitive)" demorewriteoverride
while [[ "$demorewriteoverride" != @("True"|"False") ]]
do
redMessage "You did not enter True or False. Please write it again"
read -p "True or False (Case Sensitive)" demorewriteoverride
done
if [ -f "/etc/apache2/sites-enabled/$sitename.conf" ]
then
redMessage "Sitename Apache Config already exist in sites-enabled"
redMessage "Do you want to delete existing $sitename.conf file"
read -p "Enter True or False:" sitefile
while [[ "$sitefile" != @("True"|"False") ]]
do
redMessage "You did not select True or False."
read -p "Enter True or False:" sitefile
done
if [ $sitefile == "True" ]
then
rm -r /etc/apache2/sites-enabled/$sitename.conf
else
redMessage "Please delete the old file or update the file as per your requirement from Official Guides"
redMessage "File Location is /etc/apache2/sites-enabled/$sitename.conf"
exit 1
fi
else
greenMessage "Creating Apache Site Configuration File"
fi
## HTTP Site Configuration
greenMessage "Creating Apache Site config file under /etc/apache2/sites-enabled/$sitename.conf"
echo "<VirtualHost *:80>" >>$sitename.conf
echo " ServerName $sitename" >>$sitename.conf
echo " ServerAdmin $adminemail" >>$sitename.conf
echo " WSGIScriptAlias / /var/www/get5-web/get5.wsgi" >>$sitename.conf
echo "" >>$sitename.conf
echo " <Directory /var/www/get5>" >>$sitename.conf
echo " Order deny,allow" >>$sitename.conf
echo " Allow from all" >>$sitename.conf
if [ $demorewriteoverride == "True" ]
then
echo " AllowOverride All">>$sitename.conf
fi
echo " </Directory>" >>$sitename.conf
echo "">>$sitename.conf
echo " Alias /static /var/www/get5-web/get5/static" >>$sitename.conf
echo " <Directory /var/www/get5-web/get5/static>" >>$sitename.conf
echo " Order allow,deny" >>$sitename.conf
echo " Allow from all" >>$sitename.conf
if [ $demorewriteoverride == "True" ]
then
echo " AllowOverride All">>$sitename.conf
fi
echo " </Directory>" >>$sitename.conf
echo "" >>$sitename.conf
echo " ErrorLog \${APACHE_LOG_DIR}/error.log" >>$sitename.conf
echo " LogLevel warn" >>$sitename.conf
echo " CustomLog \${APACHE_LOG_DIR}/access.log combined" >>$sitename.conf
echo "</VirtualHost>" >>$sitename.conf
##SSL Support
redMessage "Note: Before using SSL function make sure SSL Certificate and private Key are already inside the server"
echo ""
echo ""
cyanMessage "Do you want to use SSL (True or False)"
read -p "True or False:" ssloption
while [[ "$ssloption" != @("True"|"False") ]]
do
redMessage "You did not select True or False."
read -p "True or False:" ssloption
done
if [ $ssloption == "True" ]
then
if [ -f "/etc/apache2/sites-enabled/$sitename-ssl.conf" ]
then
redMessage "Sitename Apache Config already exist in sites-enabled"
redMessage "Do you want to delete existing $sitename-ssl.conf file"
read -p "Enter True or False:" sslfileconf
while [[ "$sslfileconf" != @("True"|"False") ]]
do
redMessage "You did not select True or False."
read sslfileconf
done
if [ $sslfileconf == "True" ]
then
rm -r /etc/apache2/sites-enabled/$sitename-ssl.conf
else
redMessage "Please delete the old file or update the file as per your requirement from Official Guides"
redMessage "File Location is /etc/apache2/sites-enabled/$sitename-ssl.conf"
exit 1
fi
fi
greenMessage "Enabling SSL Support"
a2enmod ssl
##SSL Certificate
cyanMessage "Please provide your SSL Certificate Path"
read crtpath
greenMessage "You have entered $crtpath"
while [[ ! -f "$crtpath" || ${crtpath##*.} != 'crt' ]];
do
redMessage "Please check if the file exists and it also contains .crt extension"
read crtpath
yellowMessage "You have entered $crtpath"
done
cyanMessage "Please provide your SSL Private Key Path"
##SSL Key
read crtkey
while [[ ! -f "$crtkey" || ${crtkey##*.} != 'key' ]];
do
redMessage "Please check the file exists and it also contains .key extension"
read crtkey
yellowMessage "You have entered $crtkey"
done
##Apache Site Config for Port 443
echo "<IfModule mod_ssl.c>">>$sitename-ssl.conf
echo "<VirtualHost *:443>" >>$sitename-ssl.conf
echo " ServerName $sitename" >>$sitename-ssl.conf
echo " ServerAdmin $adminemail" >>$sitename-ssl.conf
echo " WSGIScriptAlias / /var/www/get5-web/get5.wsgi" >>$sitename-ssl.conf
echo "" >>$sitename-ssl.conf
echo " <Directory /var/www/get5>" >>$sitename-ssl.conf
echo " Order deny,allow" >>$sitename-ssl.conf
echo " Allow from all" >>$sitename-ssl.conf
if [ $demorewriteoverride == "True" ]
then
echo " AllowOverride All">>$sitename-ssl.conf
fi
echo " </Directory>" >>$sitename-ssl.conf
echo "">>$sitename-ssl.conf
echo " Alias /static /var/www/get5-web/get5/static" >>$sitename-ssl.conf
echo " <Directory /var/www/get5-web/get5/static>" >>$sitename-ssl.conf
echo " Order allow,deny" >>$sitename-ssl.conf
echo " Allow from all" >>$sitename-ssl.conf
if [ $demorewriteoverride == "True" ]
then
echo " AllowOverride All">>$sitename-ssl.conf
fi
echo " </Directory>" >>$sitename-ssl.conf
echo "" >>$sitename-ssl.conf
echo " ErrorLog \${APACHE_LOG_DIR}/error.log" >>$sitename-ssl.conf
echo " LogLevel warn" >>$sitename-ssl.conf
echo " CustomLog \${APACHE_LOG_DIR}/access.log combined" >>$sitename-ssl.conf
echo "">>$sitename-ssl.conf
echo " SSLEngine on">>$sitename-ssl.conf
echo " SSLCertificateFile $crtpath">>$sitename-ssl.conf
echo " SSLCertificateKeyFile $crtkey">>$sitename-ssl.conf
echo "">>$sitename-ssl.conf
echo ' <FilesMatch "\.(cgi|shtml|phtml|php)$">'>>$sitename-ssl.conf
echo " SSLOptions +StdEnvVars">>$sitename-ssl.conf
echo " </FilesMatch>">>$sitename-ssl.conf
echo " <Directory /usr/lib/cgi-bin>">>$sitename-ssl.conf
echo " SSLOptions +StdEnvVars">>$sitename-ssl.conf
echo " </Directory>">>$sitename-ssl.conf
echo " </VirtualHost>" >>$sitename-ssl.conf
echo " </IfModule>">>$sitename-ssl.conf
else
yellowMessage "SSL Support not activated"
fi
greenMessage "Restarting Apache2 Service"
service apache2 restart
if [ $demorewriteoverride == "True" ]
then
cd /var/www/get5-web/
cyanMessage "Enter your new Demo URL give full path till demos folder"
cyanMessage "eg. https://example.com/demos/ or https://demos.example.com/"
redMessage "Make sure it ends with / in the end"
read demourlpath
greenMessage "Creating .htaccess file for Rewrite Rules in /var/www/get5-web/"
echo "Options +FollowSymLinks">>.htaccess
echo "RewriteEngine On">>.htaccess
echo "RedirectMatch ^/static/demos/(.*)$ $demourlpath/$1">>.htaccess
greenMessage "Enabling Apache2 Rewrite Module"
a2enmod rewrite
service apache2 restart
break;
fi
}
##Web Installation
greenMessage "Welcome to Get5 Web Panel Auto Installation script"
echo ""
PS3="Select the option >"
select option in Install Update 'Create WSGI' 'Create Apache Config' 'Create FTP' 'Remove Get5' exit
do
case $option in
Install)
#Setting locales
greenMessage "Setting system locales"
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
locale-gen en_US.UTF-8
if [ -d "/var/www/get5-web" ]
then
redMessage "Installation already done and exist inside /var/www/get5-web ."
else
greenMessage "Downloading Dependencies"
cyanMessage "Do you want to use Apt update and Upgrade Commands ?"
redMessage "If you are using specific branch / versions for other projects on the panel i would not recommend below option"
read -p "Apt-get Update and Upgrade. ( True or False) :" aptupdateissue
while [[ $aptupdateissue != @("True"|"False") ]]
do
redMessage "Please enter only True or False"
read -p "True or False:" aptupdateissue
done
if [ $aptupdateissue == "True" ]
then
sudo apt-get update && apt-get upgrade -y
fi
sudo apt-get install build-essential software-properties-common -y
sudo apt-get install python-dev python-pip apache2 libapache2-mod-wsgi -y
sudo apt-get install virtualenv libmysqlclient-dev -y
#Checking Git Package available or not
cyanMessage "Checking Git Command Status"
gitavailable='git'
if ! dpkg -s $gitavailable >/dev/null 2>&1; then
greenMessage "Installing Git"
sudo apt-get install $gitavailable
else cyanMessage "Git Already Installed"
fi
echo ""
#Checking MySQL Server installed or not
cyanMessage "Checking MySQL Server Status"
echo ""
sqlavailable='mysql-server'
if ! dpkg -s $sqlavailable >/dev/null 2>&1; then
greenMessage "Installing MySQL Server"
sudo apt-get install $sqlavailable
service mysql start
echo ""
else
cyanMessage "MySQL Server already Installed"
echo ""
fi
greenMessage "Restarting MySQL Service"
#This is due to any systems have any kind of MySQL Errors can be restarted with this.
service mysql restart
#MYSQL Information
cyanMessage "MySQL Server User and Database Creation"
get5dbpass="$(openssl rand -base64 12)"
redMessage "Just for safety if you want to save it Get5 User Password is $get5dbpass"
yellowMessage "Please enter root user MySQL password!"
read -p "YOUR SQL ROOT PASSWORD: " -s rootpasswd
until mysql -u root -p$rootpasswd -e ";" ; do
read -p "Can't connect, please retry Root Password: " -s rootpasswd
done
yellowMessage "Creating Database Get5 with Collate utf8mb4_general_ci"
mysql -u root -p$rootpasswd -e "CREATE DATABASE get5 CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
yellowMessage "Creating Get5 User with Random Password"
mysql -u root -p$rootpasswd -e "CREATE USER 'get5'@'localhost' IDENTIFIED BY '$get5dbpass';"
yellowMessage "Grant Privileges to Get5 User to Get5 Database"
mysql -u root -p$rootpasswd -e "GRANT ALL PRIVILEGES ON get5.* TO 'get5'@'localhost' WITH GRANT OPTION;"
yellowMessage "Flushing Privilges"
mysql -u root -p$rootpasswd -e "FLUSH PRIVILEGES;"
echo ""
echo ""
echo ""
greenMessage "Downloading Get5 Web Panel"
cd /var/www/
# Branch Selection
greenMessage "Github Branch Selection"
PS3="Select the branch to clone >"
select branch in master development
do
case $branch in
master)
yellowMessage "Downloading Master branch"
git clone https://github.com/PhlexPlexico/get5-web
cyanMessage "Finish Downloading Master Branch"
break;
;;
development)
yellowMessage "Downloading Development branch"
git clone -b development --single-branch https://github.com/PhlexPlexico/get5-web
cyanMessage "Finish Downloading Development Branch"
break;
;;
*)
redMessage "You didnt select correct Option, Please use selection from above"
;;
esac
done
greenMessage "Downloaded in /var/www/get5-web"
cd /var/www/get5-web
greenMessage "Start Creating Virtual Environment and Download Requirements"
virtualenv venv
source venv/bin/activate
#Change Setup Tools to lower version for Supporting enum
pip install --upgrade 'setuptools==44.1.0'
#Install Requirements
pip install -r requirements.txt
#Prod Config File Creation and settings
#Copy & Modify Prod Config file
cyanMessage "Creating Prod Config File"
cd /var/www/get5-web/instance
cp prod_config.py.default prod_config.py
file="prod_config.py"
#Steam API Key
greenMessage "Enter your Steam API Key (https://steamcommunity.com/dev/apikey)"
read -p "Steam API Key :" steamapi
while [[ $steamapi == "" ]];
do
redMessage "You did not enter anything. Please re-enter Steam API Key"
read -p "Steam API Key :" steamapi
done
echo "Your Steam API Key is $steamapi"
echo ""
echo ""
echo ""
#Random Secret Key for Flask Cookies
greenMessage "Enter Random Secret Key for Flask Cookies"
read -p "Random Secret Key :" secretkey
while [[ $secretkey == "" ]];
do
redMessage "You did not enter anything. Please re-enter Secret Key"
read -p "Random Secret Key :" secretkey
done
echo ""
echo ""
echo ""
#Super Admin Steam ID 64
redMessage "Warning !! Only added Trusted Steam Admins ID as they have access to everything on the Panel \e[39m"
echo ""
greenMessage "Super Admin's Steam ID 64 (Please ensure values are separated by a comma. eg.id1,id2)"
redMessage "Make sure the Steam ID dont end with [,] in the end"
read -p "Steam ID 64 of Super Admins :" superadminsteamid
while [[ $superadminsteamid == "" ]];
do
redMessage "You did not enter anything. Please re-enter Super Admin Steam ID 64 Key"
read -p "Steam ID 64 of Super Admins :" superadminsteamid
done
echo ""
echo ""
echo ""
#Normal Admin's Steam ID 64
greenMessage "Want to add Normal Admin's Steam ID"
read -p "True or False: " normaladmin
while [[ $normaladmin != @("True"|"False") ]]
do
redMessage "Please enter only True or False"
read -p "True or False :" normaladmin
done
if [ $normaladmin == "True" ]
then
cyanMessage "Admin's Steam ID 64 (Please ensure values are separated by a comma. eg.id1,id2)"
read -p "Steam ID 64 of Admins :" adminsteamid
while [[ $adminsteamid == "" ]];
do
redMessage "You did not enter anything. Please re-enter Admin Steam ID 64 Key"
read -p "Steam ID 64 of Admins :" adminsteamid
done
fi
echo ""
echo ""
echo ""
#Super Admin and Admin only Panel access
cyanMessage "By Default anyone can login into panel and create matches,server and teams. Do you want panel to be exclusive for your Admins?"
greenMessage "Only Admins can access webpanel ? (True or False) . No other Steam IDs will be allowed to login inside the Panel"
redMessage "Alert!! If you want to add Whitelisted Steam IDs please use False!!"
read -p "True or False :" adminonlypanel
while [[ "$adminonlypanel" != @("True"|"False") ]]
do
redMessage "Please enter only True or False"
read adminonlypanel
done
echo ""
echo ""
echo ""
#Whitelisted Steam ID 64
if [ $adminonlypanel == "False" ]
then
cyanMessage "By Default the panel is open to public to create their own Servers/Teams and Matches. If you want panel should have exclusive access please configure it here properly."
greenMessage "Want to add Whitelisted Steam ID ?"
read -p "True or False :" whitelistoption
while [[ $whitelistoption != @("True"|"False") ]]
do
redMessage "Please enter only True or False"
read -p "True or False :" whitelistoption
done
if [ $whitelistoption == "True" ]
then
greenMessage "Whitelist's Steam ID 64 (Please ensure values are separated by a comma. eg.id1,id2)"
read -p "Steam ID 64 of Whitelist :" whitelistids
while [[ $whitelistids == "" ]];
do
redMessage "You did not enter anything. Please re-enter Whitelist Steam ID 64 Key"
read -p "Steam ID 64 of Whitelist :" whitelistids
done
else
cyanMessage "The Panel will be open to the Public for Creating Servers/Matches/Teams. Also they can use any Public Servers and Teams created by Super Admins and Admins"
fi
fi
echo ""
echo ""
echo ""
#Spectators Steam IDs
cyanMessage "By Default anyone on the Game Server will not be allowed in the matches, Everytime Admins have to add Spectators which are like in Game Admins as well as Casters . This function will auto add them to all Servers"
greenMessage "Want to add Spectators Spectators Steam ID ?"
read -p "True or False: " spectatoroption
while [[ $spectatoroption != @("True"|"False") ]]
do
redMessage "Please enter only True or False"
read -p "True or False :" spectatoroption
done
if [ $spectatoroption == "True" ]
then
greenMessage "Spectator's Steam ID 64 (Please ensure values are separated by a comma. eg.id1,id2)"
read -p "Steam ID 64 of Spectators :" spectatorids
while [[ $spectatorids == "" ]];
do
redMessage "You did not enter anything. Please re-enter Spectators Steam ID 64 Key"
read -p "Steam ID 64 of Spectators :" spectatorids
done
fi
echo ""
echo ""
echo ""
#Web Panel Name
greenMessage "Enter Title Name for Web Panel"
read -p "Webpanel Title :" wpanelname
while [[ $wpanelname == "" ]];
do
redMessage "You did not enter anything. Please enter the name for Web Panel Title"
read -p "Webpanel Title :" wpanelname
done
echo ""
echo ""
echo ""
#Custom Player Names
greenMessage "Do you want to enable Custom Player Names in Match Use True or False (Case Sensitive)"
read -p "True or False :" customname
while [[ $customname != @("True"|"False") ]]
do
redMessage "Please enter only True or False"
read -p "True or False :" customname
done
echo ""
echo ""
echo ""
#Admin Access all Matches
greenMessage "Can Super Admin Access all the Matches ? Use True or False (Case Sensitive)"
read -p "True or False :" superadminaccess
while [[ $superadminaccess != @("True"|"False") ]]
do
redMessage "Please enter only True or False"
read -p "True or False :" superadminaccess
done
cyanMessage "You have entered $superadminaccess for Admin Can Access all the Matches"
echo ""
echo ""
echo ""
#Create Match Title Text
greenMessage "Do you want to create Match Title Text Use True or False (Case Sensitive)"
read -p "True or False :" matchttext
while [[ $matchttext != @("True"|"False") ]]
do
redMessage "Please enter only True or False"
read -p "True or False :" matchttext
done
echo ""
echo ""
echo ""
#Database Key for Encryption of User Password as well as RCON Passwords of servers.
dbkey="$(openssl rand -base64 12)"
yellowMessage "Your DB Key is $dbkey. This will encrypt user passwords in database."
sed -i "s|mysql://user:password@host/db|mysql://get5:$get5dbpass@localhost/get5|g" $file
sed -i "s|STEAM_API_KEY = '???'|STEAM_API_KEY = '$steamapi'|g" $file
sed -i "s|SECRET_KEY = '???'|SECRET_KEY = '$secretkey'|g" $file
sed -i "s|WEBPANEL_NAME = 'Get5'|WEBPANEL_NAME = '$wpanelname'|g" $file
sed -i "s|CUSTOM_PLAYER_NAMES = True|CUSTOM_PLAYER_NAMES = $customname|g" $file
sed -i "s|DATABASE_KEY = '???'|DATABASE_KEY = '$dbkey'|g" $file
sed -i "s|ADMINS_ACCESS_ALL_MATCHES = False|ADMINS_ACCESS_ALL_MATCHES = $superadminaccess|g" $file
sed -i "s|CREATE_MATCH_TITLE_TEXT = False|CREATE_MATCH_TITLE_TEXT = $matchttext|g" $file
sed -i "71 s|SUPER_ADMIN_IDS = \[.*\]|SUPER_ADMIN_IDS = ['$superadminsteamid']|g" $file
echo "['$superadminsteamid']" | sed -i "71 s:,:\',\':g" $file
if [ $normaladmin == "True" ]
then
sed -i "66 s|ADMIN_IDS = \[.*\]|ADMIN_IDS = ['$adminsteamid']|g" $file
echo "['$adminsteamid']" | sed -i "66 s:,:\',\':g" $file
fi
if [ $adminonlypanel == "True" ]
then
if [ $normaladmin == "True" ]
then
sed -i "61 s|WHITELISTED_IDS = \[.*\]|WHITELISTED_IDS = ['$superadminsteamid,$adminsteamid']|g" $file
echo "['$superadminsteamid','$adminsteamid']" | sed -i "61 s:,:\',\':g" $file
else
sed -i "61 s|WHITELISTED_IDS = \[.*\]|WHITELISTED_IDS = ['$superadminsteamid']|g" $file
echo "['$superadminsteamid']" | sed -i "61 s:,:\',\':g" $file
fi
else
if [ $whitelistoption == "True" ]
then
if [ $normaladmin == "True" ]
then
sed -i "61 s|WHITELISTED_IDS = \[.*\]|WHITELISTED_IDS = ['$superadminsteamid,$adminsteamid,$whitelistids']|g" $file
echo "['$superadminsteamid','$adminsteamid','$whitelistids']" | sed -i "61 s:,:\',\':g" $file
else
sed -i "61 s|WHITELISTED_IDS = \[.*\]|WHITELISTED_IDS = ['$superadminsteamid,$whitelistids']|g" $file
echo "['$superadminsteamid','$whitelistids']" | sed -i "61 s:,:\',\':g" $file
fi
fi
fi
if [ $spectatoroption == "True" ]
then
sed -i "56 s|SPECTATOR_IDS = \[.*\]|SPECTATOR_IDS = ['$spectatorids']|g" $file
echo "['$spectatorids']" | sed -i "56 s:,:\',\':g" $file
fi
echo ""
echo ""
echo ""
cyanMessage "File is created under /var/www/get5-web/instance/prod_config.py Please open the file after installation and edit Map Pools and Add User IDs"
echo ""
echo ""
echo ""
#Database Creation
greenMessage "Creating Database Structure."
cd /var/www/get5-web/
./manager.py db upgrade
#Changing File Permisions
greenMessage "Changing File permissions for required folder"
cd /var/www/get5-web/
chown -R www-data:www-data logs
chown -R www-data:www-data get5/static/resource/csgo
echo ""
echo ""
echo ""
#WSGI File
cyanMessage "Creating Get5.wsgi"
wsgi_create
echo ""
echo ""
echo ""
#Apache Config Creation
cyanMessage "Creating Apache Config"
apacheconfig
echo ""
echo ""
echo ""
yellowMessage "Changing Directory back to /var/www/get5-web"
cd /var/www/get5-web
echo ""
echo ""
echo ""
yellowMessage "Changing Directory to /var/www/get5-web/instance. Here you can modify the Map List under prod_config.py file. Please look at the formatting properly."
cd /var/www/get5-web/instance
echo ""
echo ""
echo ""
greenMessage "If you want to Note down some important information if you want to modify anything in future . "
greenMessage "Database User of get5@localhost is $get5dbpass"
greenMessage "Database Encryption Password is $dbkey"
greenMessage "File for modifying for Map Pools is located in /var/www/get5-web/instance/prod_config.py"
break;
fi
;;
Update)
if [ -d "/var/www/get5-web" ]
then
cd /var/www/get5-web
greenMessage "Downloading Update"
git pull
greenMessage "Doing Requirement Update"
source venv/bin/activate
pip install -r requirements.txt
greenMessage "Doing manager upgrade command"
if [ -f "/var/www/get5-web/instance/prod_config.py" ]
then
./manager.py db upgrade
else
redMessage "You seems to not have added prod_config.py file"
fi
cyanMessage "Restarting Apache2 Service"
sudo service apache2 restart
cyanMessage "Update completed. Please do a refresh on webpanel for changes"
exit 1
else
redMessage "Installation Not Found.Please use install option"
fi
;;
'Create WSGI')
if [ -f "/var/www/get5-web/get5.wsgi" ]
then
redMessage "Get5.wsgi already exist"
else
if [ -d "/var/www/get5-web" ]
then
greenMessage "Creating new WSGI File in /var/www/get5-web/get5.wsgi"
wsgi_create
else
redMessage "Please install the get5-web first"
fi
fi
;;
'Create Apache Config')
if [ -d "/var/www/get5-web" ]
then
apacheconfig
greenMessage "Please check the apache Config file located in /etc/apache2/sites-enabled/$sitename.conf"
else
redMessage "You dont seem to have Get5-Web Installed"
fi
;;
'Create FTP')
if [ -d "/var/www/get5-web" ]
then
#FTP User Creation
if [ $(id -u) -eq 0 ]; then
read -p "Enter FTP username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
redMessage "$username already exists!"
exit 1
else
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
greenMessage $pass
useradd -m -p $pass -s /bin/bash $username
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
fi
else
echo "Only root may add a user to the system"
exit 2
fi
#VSFTPD Installation
if [ -f "/etc/vsftpd.conf" ]
then
yellowMessage "VSFTPD Config already available"
redMessage "Copying original file to original extension"
mv /etc/vsftpd.conf /etc/vsftpd.conf.original
else
cyanMessage "Checking for vsftpd Installation"
vsftpdavailable='vsftpd'
if ! dpkg -s $vsftpdavailable >/dev/null 2>&1; then
greenMessage "Installing VSFTPD Server"
sudo apt-get install $vsftpdavailable
echo ""
greenMessage "Copying original Config file to .orginal extension"
mv /etc/vsftpd.conf /etc/vsftpd.conf.original
fi
fi
redMessage "What kind of FTP IP you want to use ?"
cyanMessage "Localhost - When same PCs are used for CSGO and get5-Web"
echo ""
cyanMessage "Internal IP - When Get5-Web is hosted on same Network of CSGO Server in LAN Environment"
echo ""
cyanMessage "Recommended - When Get5-Web wants to connect from External IP to different CSGO Host - This option is also recommend for Amazon AWS and other Cloud Services"
cyanMessage "External IP needs working Internet Connection"
yellowMessage "What kind of IP you want to use ?"
echo "Select the IP for FTP Connection>"
select iptype in 'Localhost' 'Internal IP' 'External IP'
do
case $iptype in
'Localhost')
yellowMessage "You have selected Localhost for the FTP IP"
ip=$"127.0.0.1"
break;
;;
'Internal IP')
yellowMessage "You have selected Internal IP (Recommend for LAN Servers"
ip="$(ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)"
break;
;;
'External IP')
greenMessage "Using External IP as the Passive IP Address"
ip="$(dig TXT +short o-o.myaddr.l.google.com @ns1.google.com)"
break;
;;
*)
redMessage "You did not select Correct Option, Please do it again"
;;
esac
done
vsftpd="/etc/vsftpd.conf"
echo "allow_writeable_chroot=YES" >> $vsftpd
echo "anon_umask=022" >> $vsftpd
echo "anon_upload_enable=NO" >> $vsftpd
echo "anonymous_enable=NO" >> $vsftpd
echo "ascii_download_enable=YES" >> $vsftpd
echo "ascii_upload_enable=YES" >> $vsftpd
echo "chroot_local_user=YES" >> $vsftpd
echo "connect_from_port_20=YES" >> $vsftpd
echo "dirmessage_enable=YES" >> $vsftpd
echo "dual_log_enable=YES" >> $vsftpd
echo "force_dot_files=YES" >> $vsftpd
echo "listen=YES" >> $vsftpd
echo "local_enable=YES" >> $vsftpd
echo "local_umask=002" >> $vsftpd
echo "max_clients=100" >> $vsftpd
echo "max_per_ip=10" >> $vsftpd
echo "pam_service_name=vsftpd" >> $vsftpd
echo "pasv_enable=YES" >> $vsftpd
echo "pasv_address=$ip" >> $vsftpd
if [[ $iptype == "External IP" ]]
then
echo "${ip}" | sed -i 's/"//g' $vsftpd
fi
echo "pasv_max_port=12100" >> $vsftpd
echo "pasv_min_port=12000" >> $vsftpd
echo "seccomp_sandbox=NO" >> $vsftpd
echo "tcp_wrappers=YES" >> $vsftpd
echo "use_localtime=YES" >> $vsftpd
echo "userlist_deny=NO" >> $vsftpd
echo "userlist_enable=YES" >> $vsftpd
echo "userlist_file=/etc/vsftpd.userlist" >> $vsftpd
echo "write_enable=YES" >> $vsftpd
echo "xferlog_enable=YES" >> $vsftpd
echo "xferlog_std_format=YES" >> $vsftpd
# Setting Permissions
greenMessage "Adding FTP User to VSFTPD Userlist File"
echo "$username" >> /etc/vsftpd.userlist
greenMessage "Setting folder permissions for $username"
sudo usermod -a -G www-data $username
sudo usermod -d /var/www/get5-web/get5/static/demos $username
sudo chown -R $username:www-data /var/www/get5-web/get5/static/demos
greenMessage "Restarting vsftpd service"
service vsftpd restart
cyanMessage "Please forward the ports range 20-21(tcp) & 12000-12100(tcp)"
greenMessage "Done."
else
redMessage "You dont seem to have Get5-Web Installed"
fi
;;
'Remove Get5')
if [ ! -d "/var/www/get5-web" ]
then
redMessage "Get5-Web Installation not exist in /var/www/get5-web"
break;
else
redMessage "Do you really want to remove Get5-Web Installation"
read -p "True or False" get5remove
while [[ $get5remove != @("True"|"False") ]]
do
redMessage "Please enter only True or False"
read -p "True or False :" get5remove
done
if [ $get5remove == "True" ]
then
redMessage "Removing Get5-Web Directory"
rm -r /var/www/get5-web/
redMessage "Removing MySQL Database and User"
yellowMessage "Enter MySQL Root Password"
read -p "YOUR SQL ROOT PASSWORD: " -s rootpasswd
until mysql -u root -p$rootpasswd -e ";" ; do
read -p "Can't connect, please retry Root Password: " -s rootpasswd
done
redMessage "Removing MySQL Database"
mysql -u root -p$rootpasswd -e "DROP DATABASE get5;"
redMessage "Removing MySQL User"
mysql -u root -p$rootpasswd -e "DROP USER get5@localhost;"
redMessage "Flushing MySQL Privileges"
mysql -u root -p$rootpasswd -e "FLUSH PRIVILEGES;"
else
redMessage "You selected False , Nothing will be deleted"
exit 1;
fi
fi
;;
exit)
redMessage "Exiting Script"
exit 1
;;
*)
redMessage "You didnt select correct Option, Please use selection from above"
;;
esac
done