/
functions.sh
executable file
·2699 lines (2689 loc) · 130 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
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
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# FOG - Free, Open-Source Ghost is a computer imaging solution.
# Copyright (C) 2007 Chuck Syperski & Jian Zhang
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
dots() {
local pad=$(printf "%0.1s" "."{1..60})
printf " * %s%*.*s" "$1" 0 $((60-${#1})) "$pad"
return 0
}
backupReports() {
dots "Backing up user reports"
[[ ! -d ../rpttmp/ ]] && mkdir ../rpttmp/ >>$error_log
[[ -d $webdirdest/management/reports/ ]] && cp -a $webdirdest/management/reports/* ../rpttmp/ >>$error_log
echo "Done"
return 0
}
checkDatabaseConnection() {
dots "Checking connection to master database"
[[ -n $snmysqlhost ]] && host="--host=$snmysqlhost"
sqloptionsuser="${host} -s --user=${snmysqluser}"
mysql $sqloptionsuser --password="${snmysqlpass}" --execute="quit" >/dev/null 2>&1
errorStat $?
}
registerStorageNode() {
[[ -z $webroot ]] && webroot="/"
dots "Checking if this node is registered"
storageNodeExists=$(wget --no-check-certificate -qO - ${httpproto}://${ipaddress}${webroot}/maintenance/check_node_exists.php --post-data="ip=${ipaddress}")
echo "Done"
if [[ $storageNodeExists != exists ]]; then
[[ -z $maxClients ]] && maxClients=10
dots "Node being registered"
curl -s -k -X POST -d "newNode" -d "name=$(echo -n $ipaddress|base64)" -d "path=$(echo -n $storageLocation|base64)" -d "ftppath=$(echo -n $storageLocation|base64)" -d "snapinpath=$(echo -n $snapindir|base64)" -d "sslpath=$(echo -n $sslpath|base64)" -d "ip=$(echo -n $ipaddress|base64)" -d "maxClients=$(echo -n $maxClients|base64)" -d "user=$(echo -n $username|base64)" --data-urlencode "pass=$(echo -n $password|base64)" -d "interface=$(echo -n $interface|base64)" -d "bandwidth=1" -d "webroot=$(echo -n $webroot|base64)" -d "fogverified" ${httpproto}://${ipaddress}${webroot}/maintenance/create_update_node.php
echo "Done"
else
echo " * Node is registered"
fi
}
updateStorageNodeCredentials() {
[[ -z $webroot ]] && webroot="/"
dots "Ensuring node username and passwords match"
curl -s -k -X POST -d "nodePass" -d "ip=$(echo -n $ipaddress|base64)" -d "user=$(echo -n $username|base64)" --data-urlencode "pass=$(echo -n $password|base64)" -d "fogverified" $httpproto://$ipaddress${webroot}maintenance/create_update_node.php
echo "Done"
}
backupDB() {
dots "Backing up database"
if [[ -d $backupPath/fog_web_${version}.BACKUP ]]; then
[[ ! -d $backupPath/fogDBbackups ]] && mkdir -p $backupPath/fogDBbackups >>$error_log 2>&1
wget --no-check-certificate -O $backupPath/fogDBbackups/fog_sql_${version}_$(date +"%Y%m%d_%I%M%S").sql "${httpproto}://${ipaddress}${webroot}/maintenance/backup_db.php" --post-data="type=sql&fogajaxonly=1" >>$error_log 2>&1
fi
if [[ $? -ne 0 ]]; then
echo "Failed"
if [[ -z $autoaccept ]]; then
echo
echo " We were not able to backup the current database! Just press"
echo " [Enter] to proceed anyway or Ctrl+C to stop the installer."
read
fi
else
echo "Done"
fi
}
updateDB() {
case $dbupdate in
[Yy]|[Yy][Ee][Ss])
dots "Updating Database"
local replace='s/[]"\/$&*.^|[]/\\&/g'
local escstorageLocation=$(echo $storageLocation | sed -e $replace)
sed -i -e "s/'\/images\/'/'$escstorageLocation'/g" $webdirdest/commons/schema.php
wget --no-check-certificate -qO - --post-data="confirm&fogverified" --no-proxy ${httpproto}://${ipaddress}${webroot}management/index.php?node=schema >>$error_log 2>&1
errorStat $?
;;
*)
echo
echo " * You still need to install/update your database schema."
echo " * This can be done by opening a web browser and going to:"
echo
echo " $httpproto://${ipaddress}/fog/management"
echo
read -p " * Press [Enter] key when database is updated/installed."
echo
;;
esac
dots "Update fogstorage database password"
mysql $sqloptionsuser --password="${snmysqlpass}" --execute="INSERT INTO globalSettings (settingKey, settingDesc, settingValue, settingCategory) VALUES ('FOG_STORAGENODE_MYSQLPASS', 'This setting defines the password the storage nodes should use to connect to the fog server.', \"$snmysqlstoragepass\", 'FOG Storage Nodes') ON DUPLICATE KEY UPDATE settingValue=\"$snmysqlstoragepass\"" $mysqldbname >>$error_log 2>&1
errorStat $?
dots "Granting access to fogstorage database user"
mysql ${host} -s --user=fogstorage --password="${snmysqlstoragepass}" --execute="INSERT INTO $mysqldbname.taskLog VALUES ( 0, '999test', 3, '127.0.0.1', NOW(), 'fog');" >/dev/null 2>&1
connect_as_fogstorage=$?
if [[ $connect_as_fogstorage -eq 0 ]]; then
mysql $sqloptionsuser --password="${snmysqlpass}" --execute="DELETE FROM $mysqldbname.taskLog WHERE taskID='999test' AND ip='127.0.0.1';" >/dev/null 2>&1
echo "Skipped"
return
fi
# we still need to grant access for the fogstorage DB user
# and therefore need root DB access
mysql $sqloptionsroot --password="${snmysqlrootpass}" --execute="quit" >>$error_log 2>&1
if [[ $? -ne 0 ]]; then
echo
echo " To improve the overall security the installer will restrict"
echo " permissions for the *fogstorage* database user."
echo " Please provide the database *root* user password. Be asured"
echo " that this password will only be used while the FOG installer"
echo -n " is running and won't be stored anywhere: "
read -rs snmysqlrootpass
echo
echo
mysql $sqloptionsroot --password="${snmysqlrootpass}" --execute="quit" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo " Unable to connect to the database using the given password!"
echo -n " Try again: "
read -rs snmysqlrootpass
mysql $sqloptionsroot --password="${snmysqlrootpass}" --execute="quit" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo
echo " Failed! Terminating installer now."
exit 1
fi
fi
fi
[[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1
cat >../tmp/fog-db-grant-fogstorage-access.sql <<EOF
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI' ;
GRANT SELECT ON $mysqldbname.* TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.hosts TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.inventory TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.multicastSessions TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.multicastSessionsAssoc TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.nfsGroupMembers TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.tasks TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.taskStates TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.taskLog TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.snapinTasks TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.snapinJobs TO 'fogstorage'@'%' ;
GRANT INSERT,UPDATE ON $mysqldbname.imagingLog TO 'fogstorage'@'%' ;
FLUSH PRIVILEGES ;
SET SQL_MODE=@OLD_SQL_MODE ;
EOF
mysql $sqloptionsroot --password="${snmysqlrootpass}" <../tmp/fog-db-grant-fogstorage-access.sql >>$error_log 2>&1
errorStat $?
}
validip() {
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
ip=($ip)
IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
echo $stat
}
getCidr() {
local cidr
cidr=$(ip -f inet -o addr | grep $1 | awk -F'[ /]+' '/global/ {print $5}' | head -n2 | tail -n1)
echo $cidr
}
mask2cidr() {
local submask=$1
nbits=0
OIFS=$IFS
IFS='.'
for dec in $submask; do
case $dec in
255)
let nbits+=8
;;
254)
let nbits+=7
break
;;
252)
let nbits+=6
break
;;
248)
let nbits+=5
break
;;
240)
let nbits+=4
break
;;
224)
let
nbits+=3
break
;;
192)
let nbits+=2
break
;;
128)
let nbits+=1
break
;;
0)
;;
*)
echo "Error: $dec is not recognized"
exit 1
;;
esac
done
IFS=$OIFS
echo "$nbits"
}
cidr2mask() {
local i=""
local mask=""
local full_octets=$(($1/8))
local partial_octet=$(($1%8))
for ((i=0;i<4;i+=1)); do
if [[ $i -lt $full_octets ]]; then
mask+=255
elif [[ $i -eq $full_octets ]]; then
mask+=$((256 - 2**(8-$partial_octet)))
else
mask+=0
fi
test $i -lt 3 && mask+=.
done
echo $mask
}
mask2network() {
OIFS=$IFS
IFS='.'
read -r i1 i2 i3 i4 <<< "$1"
read -r m1 m2 m3 m4 <<< "$2"
IFS=$OIFS
printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
}
interface2broadcast() {
local interface=$1
if [[ -z $interface ]]; then
echo "No interface passed"
return 1
fi
echo $(ip -4 addr show | grep -w inet | grep $interface | awk '{print $4}')
}
subtract1fromAddress() {
local ip=$1
if [[ -z $ip ]]; then
echo "No IP Passed"
return 1
fi
if [[ ! $(validip $ip) -eq 0 ]]; then
echo "Invalid IP Passed"
return 1
fi
oIFS=$IFS
IFS='.'
read ip1 ip2 ip3 ip4 <<< "$ip"
IFS=$oIFS
if [[ $ip4 -gt 0 ]]; then
let ip4-=1
elif [[ $ip3 -gt 0 ]]; then
let ip3-=1
ip4=255
elif [[ $ip2 -gt 0 ]]; then
let ip2-=1
ip3=255
ip4=255
elif [[ $ip1 -gt 0 ]]; then
let ip1-=1
ip2=255
ip3=255
ip4=255
else
echo "Invalid IP ranges were passed"
echo ${ip1}.${ip2}.${ip3}.${ip4}
return 2
fi
echo ${ip1}.${ip2}.${ip3}.${ip4}
}
subtractFromAddress() {
local ipaddress="$1"
local decreaseby=$2
local maxOctetValue=256
local octet1=""
local octet2=""
local octet3=""
local octet4=""
oIFS=$IFS
IFS='.' read octet1 octet2 octet3 octet4 <<< "$ipaddress"
IFS=$oIFS
let octet4-=$decreaseby
if [[ $octet4 -lt $maxOctetValue && $octet4 -ge 0 ]]; then
printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4 | sed 's/-//g'
return 0
fi
echo $octet4
echo $maxOctetValue
octet4=$(echo $octet4 | sed 's/-//g')
numRollOver=$((octet4 / maxOctetValue))
echo $numRollOver
let octet4-=$((numRollOver * maxOctetValue))
echo $((numRollOver - octet3))
let octet3-=$numRollOver
echo $octet3
if [[ $octet3 -lt $maxOctetValue && $octet3 -ge 0 ]]; then
echo 'here'
printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4 | sed 's/-//g'
return 0
fi
numRollOver=$((octet3 / maxOctetValue))
let octet3-=$((numRollOver * maxOctetValue))
let octet2-=$numRollOver
if [[ $octet2 -lt $maxOctetValue && $octet2 -ge 0 ]]; then
printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4 | sed 's/-//g'
return 0
fi
numRollOver=$((octet2 / maxOctetValue))
let octet2-=$((numRollOver * maxOctetValue))
let octet1-=$numRollOver
if [[ $octet1 -lt $maxOctetValue && $octet1 -ge 0 ]]; then
printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4 | sed 's/-//g'
return 0
fi
return 1
}
addToAddress() {
local ipaddress="$1"
local increaseby=$2
local maxOctetValue=256
local octet1=""
local octet2=""
local octet3=""
local octet4=""
oIFS=$IFS
IFS='.' read octet1 octet2 octet3 octet4 <<< "$ipaddress"
IFS=$oIFS
let octet4+=$increaseby
if [[ $octet4 -lt $maxOctetValue && $octet4 -ge 0 ]]; then
printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4
return 0
fi
numRollOver=$((octet4 / maxOctetValue))
let octet4-=$((numRollOver * maxOctetValue))
let octet3+=$numRollOver
if [[ $octet3 -lt $maxOctetValue && $octet3 -ge 0 ]]; then
printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4
return 0
fi
numRollOver=$((octet3 / maxOctetValue))
let octet3-=$((numRollOver * maxOctetValue))
let octet2+=$numRollOver
if [[ $octet2 -lt $maxOctetValue && $octet2 -ge 0 ]]; then
printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4
return 0
fi
numRollOver=$((octet2 / maxOctetValue))
let octet2-=$((numRollOver * maxOctetValue))
let octet1+=$numRollOver
if [[ $octet1 -lt $maxOctetValue && $octet1 -ge 0 ]]; then
printf "%d.%d.%d.%d\n" $octet1 $octet2 $octet3 $octet4
return 0
fi
return 1
}
getAllNetworkInterfaces() {
gatewayif=$(ip -4 route show | grep "^default via" | awk '{print $5}')
if [[ -z ${gatewayif} ]]; then
interfaces="$(ip -4 link | grep -v LOOPBACK | grep UP | awk -F': |@' '{print $2}' | tr '\n' ' ')"
else
interfaces="$gatewayif $(ip -4 link | grep -v LOOPBACK | grep UP | awk -F': |@' '{print $2}' | tr '\n' ' ' | sed "s/${gatewayif}//g")"
fi
echo -n $interfaces
}
checkInternetConnection() {
dots "Testing internet connection"
DEBIAN_FRONTEND=noninteractive $packageinstaller curl >>$error_log 2>&1
http_sites=("neverssl.com" "httpbin.org")
https_sites=("github.com" "fogproject.org")
dns_ok=0
http_ok=0
https_ok=0
for dnsname in "${http_sites[@]}" "${https_sites[@]}"; do
echo -n "Testing DNS name resolution (${dnsname})... " >> $error_log
getent hosts ${dnsname} >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "Failed" >> $error_log
continue
fi
dns_ok=1
echo "OK" >> $error_log
break
done
if [[ $dns_ok -eq 0 ]]; then
echo "Failed"
echo
echo "There seems to be a DNS problem. Check the contents of /etc/resolv.conf" | tee -a $error_log
echo "If this is CentOS, RHEL, or Fedora or an other RH variant, also check" | tee -a $error_log
echo "the DNS entries in /etc/sysconfig/network-scripts/ifcfg-*" | tee -a $error_log
echo
return
fi
for url in "${http_sites[@]}"; do
echo -n "Testing HTTP connection (http://${url})... " >> $error_log
curl --silent http://${url} >/dev/null 2>>$error_log
if [[ $? -ne 0 ]]; then
echo "Failed" >> $error_log
continue
fi
http_ok=1
echo "OK" >> $error_log
break
done
for url in "${https_sites[@]}"; do
echo -n "Testing HTTPS connection (https://${url})... " >> $error_log
curl --silent -k https://${url} >/dev/null 2>>$error_log
if [[ $? -ne 0 ]]; then
echo "Failed" >> $error_log
continue
fi
https_ok=1
echo "OK" >> $error_log
break
done
if [[ $http_ok -eq 0 && $https_ok -eq 0 ]]; then
echo "Failed"
echo
echo "There was no interface with an active internet connection found." | tee -a $error_log
echo "If you are using a proxy server, please export http_proxy and https_proxy or use .curlrc" | tee -a $error_log
echo
return
fi
echo "Done"
}
join() {
local IFS="$1"
shift
echo "$*"
}
restoreReports() {
dots "Restoring user reports"
if [[ -d $webdirdest/management/reports ]]; then
if [[ -d ../rpttmp/ ]]; then
cp -a ../rpttmp/* $webdirdest/management/reports/
fi
fi
errorStat $?
}
installFOGServices() {
dots "Setting up FOG Services"
mkdir -p $servicedst
cp -Rf $servicesrc/* $servicedst/
chmod +x -R $servicedst/
mkdir -p $servicelogs
errorStat $?
}
configureUDPCast() {
dots "Setting up UDPCast"
cur=$(pwd)
[[ ! -d ../tmp/ ]] && mkdir -p ../tmp/ >/dev/null 2>&1
cd ../tmp
rm -rf $udpcastout
tar xzf $udpcastsrc >>$error_log 2>&1
cd $udpcastout
grep -q 'BCM[0-9][0-9][0-9][0-9]' /proc/cpuinfo >>$error_log 2>&1
if [[ $? -eq 0 ]]; then
wget -qO config.guess "https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess" >>$error_log 2>&1
wget -qO config.sub "https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub" >>$error_log 2>&1
chmod +x config.guess config.sub >>$error_log 2>&1
fi
errorStat $?
dots "Configuring UDPCast"
./configure >>$error_log 2>&1
errorStat $?
dots "Building UDPCast"
make >>$error_log 2>&1
errorStat $?
dots "Installing UDPCast"
make install >>$error_log 2>&1
errorStat $?
cd $cur
}
configureFTP() {
dots "Setting up and starting VSFTP Server"
if [[ -f $ftpxinetd ]]; then
mv $ftpxinetd ${ftpxinetd}.fogbackup
fi
vsftp=$(vsftpd -version 0>&1 | awk -F'version ' '{print $2}')
vsvermaj=$(echo $vsftp | awk -F. '{print $1}')
vsverbug=$(echo $vsftp | awk -F. '{print $3}')
seccompsand=""
allow_writeable_chroot=""
if [[ $vsvermaj -gt 3 ]] || [[ $vsvermaj -eq 3 && $vsverbug -ge 2 ]]; then
seccompsand="seccomp_sandbox=NO"
fi
mv -fv "${ftpconfig}" "${ftpconfig}.${timestamp}" >>$error_log 2>&1
echo -e "max_per_ip=200\nanonymous_enable=NO\nlocal_enable=YES\nwrite_enable=YES\nlocal_umask=022\ndirmessage_enable=YES\nxferlog_enable=YES\nconnect_from_port_20=YES\nxferlog_std_format=YES\nlisten=YES\npam_service_name=vsftpd\nuserlist_enable=NO\nchmod_enable=YES\n$seccompsand" > "$ftpconfig"
diffconfig "${ftpconfig}"
case $systemctl in
yes)
systemctl is-enabled --quiet vsftpd && true || systemctl enable vsftpd >>$error_log 2>&1
systemctl is-active --quiet vsftpd && systemctl stop vsftpd >>$error_log 2>&1 || true
systemctl is-active --quiet vsftpd && true || systemctl start vsftpd >>$error_log 2>&1
systemctl status vsftpd >>$error_log 2>&1
;;
*)
case $osid in
2)
sysv-rc-conf vsftpd on >>$error_log 2>&1
service vsftpd stop >>$error_log 2>&1
service vsftpd start >>$error_log 2>&1
service vsftpd status >>$error_log 2>&1
;;
*)
chkconfig vsftpd on >>$error_log 2>&1
service vsftpd stop >>$error_log 2>&1
service vsftpd start >>$error_log 2>&1
service vsftpd status >>$error_log 2>&1
;;
esac
;;
esac
errorStat $?
}
configureDefaultiPXEfile() {
dots 'Configuring default iPXE file'
[[ -z $webroot ]] && webroot='/'
echo -e "#!ipxe\ncpuid --ext 29 && set arch x86_64 || set arch \${buildarch}\nparams\nparam mac0 \${net0/mac}\nparam arch \${arch}\nparam platform \${platform}\nparam product \${product}\nparam manufacturer \${product}\nparam ipxever \${version}\nparam filename \${filename}\nparam sysuuid \${uuid}\nisset \${net1/mac} && param mac1 \${net1/mac} || goto bootme\nisset \${net2/mac} && param mac2 \${net2/mac} || goto bootme\n:bootme\nchain ${httpproto}://$ipaddress${webroot}service/ipxe/boot.php##params" > "$tftpdirdst/default.ipxe"
errorStat $?
}
configureTFTPandPXE() {
[[ -d ${tftpdirdst}.prev ]] && rm -rf ${tftpdirdst}.prev >>$error_log 2>&1
[[ ! -d ${tftpdirdst} ]] && mkdir -p $tftpdirdst >>$error_log 2>&1
[[ -e ${tftpdirdst}.fogbackup ]] && rm -rf ${tftpdirdst}.fogbackup >>$error_log 2>&1
[[ -d $tftpdirdst && ! -d ${tftpdirdst}.prev ]] && mkdir -p ${tftpdirdst}.prev >>$error_log 2>&1
[[ -d ${tftpdirdst}.prev ]] && cp -Rf $tftpdirdst/* ${tftpdirdst}.prev/ >>$error_log 2>&1
if [[ "x$httpproto" = "xhttps" ]]; then
dots "Compiling iPXE binaries trusting your SSL certificate"
cd $buildipxesrc
./buildipxe.sh ${sslpath}CA/.fogCA.pem >>$workingdir/error_logs/fog_ipxe-build_${version}.log 2>&1
errorStat $?
cd $workingdir
fi
cd $tftpdirsrc
find -type d -exec mkdir -p $tftpdirdst/{} \; >>$error_log 2>&1
find -type f -exec cp -Rfv {} $tftpdirdst/{} \; >>$error_log 2>&1
cd $workingdir
chown -R $username $tftpdirdst >>$error_log 2>&1
chown -R $username $webdirdest/service/ipxe >>$error_log 2>&1
find $tftpdirdst -type d -exec chmod 755 {} \; >>$error_log 2>&1
find $webdirdest -type d -exec chmod 755 {} \; >>$error_log 2>&1
find $tftpdirdst ! -type d -exec chmod 655 {} \; >>$error_log 2>&1
configureDefaultiPXEfile
dots 'Setting up and starting TFTP Server'
case $systemctl in
yes)
# make sure xinetd is off for all systemd distros as we don't use it anymore
systemctl is-enabled --quiet xinetd 2>/dev/null && systemctl disable xinetd >>$error_log 2>&1 || true
systemctl is-active --quiet xinetd && systemctl stop xinetd >>$error_log 2>&1 || true
if [[ -f /etc/xinetd.d/tftp ]]; then
rm -f /etc/xinetd.d/tftp
fi
if [[ $osid -eq 2 && -f $tftpconfigupstartdefaults ]]; then
echo -e "# /etc/default/tftpd-hpa\n# FOG Modified version\nTFTP_USERNAME=\"root\"\nTFTP_DIRECTORY=\"/tftpboot\"\nTFTP_ADDRESS=\":69\"\nTFTP_OPTIONS=\"${tftpAdvOpts:+$tftpAdvOpts }-s\"" > "$tftpconfigupstartdefaults"
systemctl is-enabled --quiet tftpd-hpa && true || systemctl enable tftpd-hpa >>$error_log 2>&1
systemctl is-active --quiet tftpd-hpa && systemctl stop tftpd-hpa >>$error_log 2>&1 || true
systemctl is-active --quiet tftpd-hpa && true || systemctl start tftpd-hpa >>$error_log 2>&1
systemctl status tftpd-hpa >>$error_log 2>&1
else
if [[ -f /etc/systemd/system/fog-tftp.service ]]; then
mv -fv /etc/systemd/system/fog-tftp.service "/etc/systemd/system/fog-tftp.service.${timestamp}" >>$error_log 2>&1
fi
echo -e "[Unit]\nDescription=Tftp Server\nRequires=fog-tftp.socket\nDocumentation=man:in.tftpd\n\n[Service]\nExecStart=/usr/sbin/in.tftpd ${tftpAdvOpts:+$tftpAdvOpts }-s ${tftpdirdst}\nStandardInput=socket\n\n[Install]\nAlso=fog-tftp.socket" > /etc/systemd/system/fog-tftp.service
diffconfig "/etc/systemd/system/fog-tftp.service"
cp -v /usr/lib/systemd/system/tftp.socket /etc/systemd/system/fog-tftp.socket >>$error_log 2>&1
systemctl daemon-reload
systemctl is-enabled --quiet fog-tftp.socket && true || systemctl enable fog-tftp.socket >>$error_log 2>&1
systemctl is-active --quiet fog-tftp.socket && systemctl stop fog-tftp.socket >>$error_log 2>&1 || true
systemctl is-active --quiet fog-tftp.socket && true || systemctl start fog-tftp.socket >>$error_log 2>&1
systemctl status fog-tftp.socket >>$error_log 2>&1
fi
;;
*)
if [[ $osid -eq 2 && -f $tftpconfigupstartdefaults ]]; then
echo -e "# /etc/default/tftpd-hpa\n# FOG Modified version\nTFTP_USERNAME=\"root\"\nTFTP_DIRECTORY=\"/tftpboot\"\nTFTP_ADDRESS=\":69\"\nTFTP_OPTIONS=\"${tftpAdvOpts:+$tftpAdvOpts }-s\"" > "$tftpconfigupstartdefaults"
sysv-rc-conf xinetd off >>$error_log 2>&1
service xinetd stop >>$error_log 2>&1
sysv-rc-conf tftpd-hpa on >>$error_log 2>&1
service tftpd-hpa stop >>$error_log 2>&1
service tftpd-hpa start >>$error_log 2>&1
elif [[ $osid -eq 2 ]]; then
sysv-rc-conf xinetd on >>$error_log 2>&1
$initdpath/xinetd stop >>$error_log 2>&1
$initdpath/xinetd start >>$error_log 2>&1
else
chkconfig xinetd on >>$error_log 2>&1
service xinetd stop >>$error_log 2>&1
service xinetd start >>$error_log 2>&1
service xinetd status >>$error_log 2>&1
fi
;;
esac
errorStat $?
}
configureMinHttpd() {
configureHttpd
echo "<?php" > "$webdirdest/management/index.php"
echo "/**" >> "$webdirdest/management/index.php"
echo " * The main index presenter" >> "$webdirdest/management/index.php"
echo " *" >> "$webdirdest/management/index.php"
echo " * PHP version 5" >> "$webdirdest/management/index.php"
echo " *" >> "$webdirdest/management/index.php"
echo " * @category Index_Page" >> "$webdirdest/management/index.php"
echo " * @package FOGProject" >> "$webdirdest/management/index.php"
echo " * @author Tom Elliott <tommygunsster@gmail.com>" >> "$webdirdest/management/index.php"
echo " * @license http://opensource.org/licenses/gpl-3.0 GPLv3" >> "$webdirdest/management/index.php"
echo " * @link https://fogproject.org" >> "$webdirdest/management/index.php"
echo " */" >> "$webdirdest/management/index.php"
echo "/**" >> "$webdirdest/management/index.php"
echo " * The main index presenter" >> "$webdirdest/management/index.php"
echo " *" >> "$webdirdest/management/index.php"
echo " * @category Index_Page" >> "$webdirdest/management/index.php"
echo " * @package FOGProject" >> "$webdirdest/management/index.php"
echo " * @author Tom Elliott <tommygunsster@gmail.com>" >> "$webdirdest/management/index.php"
echo " * @license http://opensource.org/licenses/gpl-3.0 GPLv3" >> "$webdirdest/management/index.php"
echo " * @link https://fogproject.org" >> "$webdirdest/management/index.php"
echo " */" >> "$webdirdest/management/index.php"
echo "require '../commons/base.inc.php';" >> "$webdirdest/management/index.php"
echo "require '../commons/text.php';" >> "$webdirdest/management/index.php"
echo "ob_start();" >> "$webdirdest/management/index.php"
echo "FOGCore::getClass('FOGPageManager')->render();" >> "$webdirdest/management/index.php"
echo "ob_end_clean();" >> "$webdirdest/management/index.php"
echo "die(_('This is a storage node, please do not access the web ui here!'));" >> "$webdirdest/management/index.php"
}
addOndrejRepo() {
find /etc/apt/sources.list.d/ -name '*ondrej*' -exec rm -rf {} \; >>$error_log 2>&1
DEBIAN_FRONTEND=noninteractive $packageinstaller python-software-properties >>$error_log 2>&1
DEBIAN_FRONTEND=noninteractive $packageinstaller software-properties-common >>$error_log 2>&1
DEBIAN_FRONTEND=noninteractive $packageinstaller ntpdate >>$error_log 2>&1
ntpdate pool.ntp.org >>$error_log 2>&1
locale-gen 'en_US.UTF-8' >>$error_log 2>&1
LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y ppa:ondrej/php >>$error_log 2>&1
LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y ppa:ondrej/apache2 >>$error_log 2>&1
}
installPackages() {
[[ $installlang -eq 1 ]] && packages="$packages gettext"
packages="$packages unzip"
dots "Adjusting repository (can take a long time for cleanup)"
case $osid in
1)
packages="$packages php-bcmath bc"
if [[ $installlang -eq 1 ]]; then
packages="$packages php-intl"
for i in fr de eu es pt zh en; do
packages="$packages glibc-langpack-${i}";
done
fi
packages="${packages// mod_fastcgi/}"
packages="${packages// mod_evasive/}"
packages="${packages// php-mcrypt/}"
case $linuxReleaseName_lower in
*fedora*)
packages="$packages php-json"
packages="${packages// mysql / mariadb }" >>$error_log 2>&1
packages="${packages// mysql-server / mariadb-server }" >>$error_log 2>&1
packages="${packages// dhcp / dhcp-server }" >>$error_log 2>&1
;;
*)
x="epel-release"
eval $packageQuery >>$error_log 2>&1
if [[ ! $? -eq 0 ]]; then
y="https://dl.fedoraproject.org/pub/epel/epel-release-latest-${OSVersion}.noarch.rpm"
$packageinstaller $y >>$error_log 2>&1
errorStat $? "skipOk"
fi
y="https://rpms.remirepo.net/enterprise/remi-release-${OSVersion}.rpm"
x="$(basename $y | awk -F[.] '{print $1}')*"
eval $packageQuery >>$error_log 2>&1
if [[ ! $? -eq 0 ]]; then
rpm -Uvh $y >>$error_log 2>&1
errorStat $? "skipOk"
fi
rpm --import "https://rpms.remirepo.net/RPM-GPG-KEY-remi" >>$error_log 2>&1
errorStat $? "skipOk"
if [[ -n $repoenable ]]; then
if [[ $OSVersion -le 7 ]]; then
$repoenable epel >>$error_log 2>&1 || true
$repoenable remi >>$error_log 2>&1 || true
$repoenable remi-php72 >>$error_log 2>&1 || true
fi
fi
;;
esac
;;
2)
packages="${packages// libapache2-mod-fastcgi/}"
packages="${packages// libapache2-mod-evasive/}"
packages="${packages// xinetd/}"
packages="${packages// php-gettext/}"
packages="${packages// php-php-gettext/}"
packages="${packages} php-bcmath bc"
if [[ $installlang -eq 1 ]]; then
packages="$packages php-intl"
fi
case $linuxReleaseName_lower in
*ubuntu*|*mint*)
if [[ $installlang -eq 1 ]]; then
for i in fr de eu es pt zh-hans en; do
packages="$packages language-pack-${i}";
done
fi
if [[ $OSVersion -gt 17 ]]; then
packages="${packages// libcurl3 / libcurl4 }">>$error_log 2>&1
fi
if [[ $linuxReleaseName_lower == +(*ubuntu*) && $OSVersion -ge 18 ]]; then
# Fix missing universe section for Ubuntu 18.04 LIVE
LANG='en_US.UTF-8' LC_ALL='en_US.UTF-8' add-apt-repository -y universe >>$error_log 2>&1
# check to see if we still have packages from deb.sury.org (a.k.a ondrej) installed and try to clean it up
dpkg -l | grep -q "deb\.sury\.org"
if [[ $? -eq 0 ]]; then
# make sure we have ondrej repos enabled to be able to use ppa-purge
addOndrejRepo
# use ppa-purge to not just remove the repo but also downgrade packages to Ubuntu original versions
DEBIAN_FRONTEND=noninteractive apt-get install -yq ppa-purge >>$error_log 2>&1
ppa-purge -y ppa:ondrej/apache2 >>$error_log 2>&1
# for php we want to purge all packages first as we don't want ppa-purge to try downgrading those
DEBIAN_FRONTEND=noninteractive apt-get purge -yq 'php5*' 'php7*' 'php8*' 'libapache*' >>$error_log 2>&1
ppa-purge -y ppa:ondrej/php >>$error_log 2>&1
DEBIAN_FRONTEND=noninteractive apt-get purge -yq ppa-purge >>$error_log 2>&1
fi
else
addOndrejRepo
fi
;;
*bian*)
if [[ $OSVersion -ge 10 ]]; then
packages="${packages// libcurl3 / libcurl4 }">>$error_log 2>&1
packages="${packages// mysql-client / mariadb-client }">>$error_log 2>&1
packages="${packages// mysql-server / mariadb-server }">>$error_log 2>&1
fi
;;
esac
;;
3)
echo $packages | grep -q -v " git" && packages="${packages} git"
packages="${packages// php-mcrypt/}"
;;
esac
errorStat $?
dots "Preparing Package Manager"
$packmanUpdate >>$error_log 2>&1
if [[ $osid -eq 2 ]]; then
if [[ $? != 0 ]] && [[ $linuxReleaseName_lower == +(*ubuntu*|*mint*) ]]; then
cp /etc/apt/sources.list /etc/apt/sources.list.original_fog_$(date +%s)
sed -i -e 's/\/\/*archive.ubuntu.com\|\/\/*security.ubuntu.com/\/\/old-releases.ubuntu.com/g' /etc/apt/sources.list
$packmanUpdate >>$error_log 2>&1
if [[ $? != 0 ]]; then
cp -f /etc/apt/sources.list.original_fog /etc/apt/sources.list >>$error_log 2>&1
rm -f /etc/apt/sources.list.original_fog >>$error_log 2>&1
false
fi
fi
fi
errorStat $?
packages=$(echo ${packages[@]} | tr ' ' '\n' | sort -u | tr '\n' ' ')
echo -e " * Packages to be installed:\n\n\t$packages\n\n"
newPackList=""
local toInstall=""
for x in $packages; do
case $x in
mysql|mariadb|mariadb-client|MariaDB-client)
for sqlclient in $sqlclientlist; do
eval $packagelist "$sqlclient" >>$error_log 2>&1
if [[ $? -eq 0 ]]; then
available_sqlclient=$sqlclient
break
fi
done
for sqlclient in $sqlclientlist; do
x=$sqlclient
eval $packageQuery >>$error_log 2>&1
if [[ $? -eq 0 ]]; then
installed_sqlclient=$sqlclient
break
fi
done
[[ -z $installed_sqlclient ]] && x=$available_sqlclient || x=$installed_sqlclient
;;
mysql-server|mariadb-server|MariaDB-server)
for sqlserver in $sqlserverlist; do
eval $packagelist "$sqlserver" >>$error_log 2>&1
if [[ $? -eq 0 ]]; then
available_sqlserver=$sqlserver
break
fi
done
for sqlserver in $sqlserverlist; do
x=$sqlserver
eval $packageQuery >>$error_log 2>&1
if [[ $? -eq 0 ]]; then
installed_sqlserver=$sqlserver
break
fi
done
[[ -z $installed_sqlserver ]] && x=$available_sqlserver || x=$installed_sqlserver
;;
php-json)
for json in php-json php-common; do
eval $packagelist "$json" >>$error_log 2>&1
if [[ $? -eq 0 ]]; then
x=$json
break
fi
done
;;
php-mysql*)
for phpmysql in $(echo php-mysqlnd php-mysql); do
eval $packagelist "$phpmysql" >>$error_log 2>&1
if [[ $? -eq 0 ]]; then
x=$phpmysql
break
fi
done
;;
esac
[[ $osid == 2 && -z $dhcpd && $x == +(*'dhcp'*) ]] && dhcpd=$x
eval $packageQuery >>$error_log 2>&1
if [[ $? -eq 0 ]]; then
dots "Skipping package: $x"
echo "(Already Installed)"
newPackList="$newPackList $x"
continue
fi
eval $packagelist "$x" >>$error_log 2>&1
if [[ ! $? -eq 0 ]]; then
dots "Skipping package: $x"
echo "(Does not exist)"
continue
fi
newPackList="$newPackList $x"
dots "Installing package: $x"
DEBIAN_FRONTEND=noninteractive $packageinstaller $x >>$error_log 2>&1
if [[ ! $? -eq 0 ]]; then
echo "Failed! (Will try later)"
[[ -z $toInstall ]] && toInstall="$x" || toInstall="$toInstall $x"
else
echo "OK"
fi
done
packages=$newPackList
packages=$(echo ${packages[@]} | tr ' ' '\n' | sort -u | tr '\n' ' ')
dots "Updating packages as needed"
DEBIAN_FRONTEND=noninteractive $packageupdater $packages >>$error_log 2>&1
echo "OK"
if [[ -n $toInstall ]]; then
toInstall=$(echo ${toInstall[@]} | tr ' ' '\n' | sort -u | tr '\n' ' ')
dots "Installing now everything is updated"
DEBIAN_FRONTEND=noninteractive $packageinstaller $toInstall >>$error_log 2>&1
errorStat $?
fi
export php_ver=$(php -i | grep "PHP Version" | head -1 | cut -d' ' -f 4 | cut -d'.' -f1-2)
[[ -z ${phpfpm} ]] && export phpfpm="php${php_ver}-fpm"
[[ -z ${phpini} ]] && export phpini="/etc/php/$php_ver/fpm/php.ini"
}
confirmPackageInstallation() {
for x in $packages; do
dots "Checking package: $x"
eval $packageQuery >>$error_log 2>&1
errorStat $?
done
}
checkSELinux() {
command -v sestatus >>$error_log 2>&1
exitcode=$?
[[ $exitcode -ne 0 ]] && return
currentmode=$(LANG=C sestatus | grep "^Current mode" | awk '{print $3}')
configmode=$(LANG=C sestatus | grep "^Mode from config file" | awk '{print $5}')
[[ "x$currentmode" != "xenforcing" && "x$configmode" != "xenforcing" ]] && return
echo " * SELinux is currently enabled on your system. This is often causing"
echo " * issues and we recommend setting to permissive on FOG Servers as of now."
echo -n " * Should the installer set this for you now? (Y/n) "
sedisable=""
while [[ -z $sedisable ]]; do
[[ -n $autoaccept ]] && sedisable="Y" || read -r sedisable
case $sedisable in
[Yy]|[Yy][Ee][Ss]|"")
sedisable="Y"
setenforce 0
sed -i 's/^SELINUX=.*$/SELINUX=permissive/' /etc/selinux/config
echo -e " * SELinux set permissive -- proceeding with installation...\n"
;;
[Nn]|[Nn][Oo])
echo -e " * You sure know what you're doing, just keep in mind we told you! :-)\n"
;;
*)
sedisable=""
echo " * Invalid input, please try again!"
;;
esac
done
}
checkFirewall() {
command -v iptables >>$error_log
iptcmd=$?
if [[ $iptcmd -eq 0 ]]; then
rulesnum=$(iptables -L -n | wc -l)
policy=$(iptables -L -n | grep "^Chain" | grep -v "ACCEPT" -c)
[[ $rulesnum -ne 8 || $policy -ne 0 ]] && fwrunning=1
fi
command -v firewall-cmd >>$error_log 2>&1
fwcmd=$?
if [[ $fwcmd -eq 0 ]]; then
fwstate=$(firewall-cmd --state 2>&1)
[[ "x$fwstate" == "xrunning" ]] && fwrunning=1
fi
[[ $fwrunning -ne 1 ]] && return
echo " * The local firewall, currently, seems to be enabled on your system. This can cause"
echo " * issues on FOG Servers if you are not well experienced and know what you are doing."
echo -n " * Should the installer try to disable the local firewall for you now? (y/N) "
fwdisable=""
while [[ -z $fwdisable ]]; do
[[ -n $autoaccept ]] && fwdisable="N" || read -r fwdisable
case $fwdisable in
[Yy]|[Yy][Ee][Ss])
ufw stop >/dev/null 2>&1
ufw disable >/dev/null 2>&1
systemctl is-active --quiet ufw && systemctl stop ufw >/dev/null 2>&1 || true
systemctl is-enabled --quiet ufw 2>/dev/null && systemctl disable ufw >/dev/null 2>&1 || true
systemctl is-active --quiet firewalld && systemctl stop firewalld >/dev/null 2>&1 || true
systemctl is-enabled --quiet firewalld 2>/dev/null && systemctl disable firewalld >/dev/null 2>&1 || true
systemctl is-active --quiet iptables && systemctl stop iptables >/dev/null 2>&1 || true
systemctl is-enabled --quiet iptables 2>/dev/null && systemctl disable iptables >/dev/null 2>&1 || true
local cannotdisablefw=0
if [[ $iptcmd -eq 0 ]]; then
rulesnum=$(iptables -L -n | wc -l)
policy=$(iptables -L -n | grep "^Chain" | grep -v "ACCEPT" -c)
[[ $rulesnum -ne 8 || $policy -ne 0 ]] && cannotdisablefw=1
fi
if [[ $fwcmd -eq 0 ]]; then
fwstate=$(firewall-cmd --state 2>&1)
[[ "x$fwstate" == "xrunning" ]] && cannotdisablefw=1
fi
if [[ $cannotdisablefw -eq 0 ]]; then
echo -e " * Firewall disabled - proceeding with installation...\n"
else
echo " * We were unable to disable the firewall on your system. Read up on how"
echo " * you can disable it manually. Proceeding with the installation anyway..."
echo " * Hit [Enter] so we know you've read this message."
read
fi
;;
[Nn]|[Nn][Oo]|"")
fwdisable="N"
echo " * You sure know what you are doing, just keep in mind we told you! :-)"
if [[ -z $autoaccept ]]; then
echo " * Hit ENTER so we know you've read this message."
read
fi
;;
*)
fwdisable=""
echo " * Invalid input, please try again!"
;;
esac
done
}
displayOSChoices() {
blFirst=1
while [[ -z $osid ]]; do
if [[ $fogupdateloaded -eq 1 && $blFirst -eq 1 ]]; then
blFirst=0
else
osid=$strSuggestedOS
if [[ -z $autoaccept && ! -z $osid ]]; then
echo " What version of Linux would you like to run the installation for?"
echo
echo " 1) Redhat Based Linux (Redhat, Alma, Rocky, CentOS, Mageia)"
echo " 2) Debian Based Linux (Debian, Ubuntu, Kubuntu, Edubuntu)"
echo " 3) Arch Linux"
echo
echo -n " Choice: [$strSuggestedOS] "
read osid
case $osid in
"")
osid=$strSuggestedOS
break
;;