-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathnc_install.sh
1765 lines (1615 loc) Β· 48.3 KB
/
nc_install.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
#
## Piet's Host ## - Β©2017, https://piets-host.de
#
# Tested on:
# CentOS 6.8 & 7.4,
# Ubuntu 12.04, 14.04, 16.04, 18.04,
# Debian 7 & 8,
# Fedora 23, 24 & 25,
#
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
# disable user input
stty -echo
clear
# Import sources
source functions.sh
source variables.sh
source apps.sh
# Set colors for printf output
red='\e[31m'
green='\e[32m'
yellow='\e[33m'
reset='\e[0m'
redbg='\e[41m'
lightred='\e[91m'
blue='\e[34m'
cyan='\e[36m'
ugreen='\e[4;32m'
while :; do
case $1 in
-h|-\?|--help|\?) # Call "show_help" function , then exit.
show_help
stty echo
exit
;;
-v|--version) # Takes an option argument, ensuring it has been specified.
if [ -n "$2" ]; then
version="$2"
shift
else
printf $redbg'ERROR: "--version" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-p|--password)
if [ -n "$2" ]; then
database_root="$2"
shift
else
printf $redbg'ERROR: "--password" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-r|--root)
if [ -n "$2" ]; then
dbruser="$2"
shift
else
printf $redbg'ERROR: "--root" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-m|--mysqlhost)
if [ -n "$2" ]; then
dbhost="$2"
shift
else
printf $redbg'ERROR: "--mysqlhost" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-n|--name)
if [ -n "$2" ]; then
ncname="$2"
shift
else
printf $redbg'ERROR: "--name" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-i|--icon)
if [ -n "$2" ]; then
icon="$2"
shift
else
printf $redbg'ERROR: "--icon" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-c|--config)
if [ -n "$2" ]; then
if [ -f "$2" ]; then
config_to_read="$2"
isconfig="true"
else
printf $redbg'ERROR: "--config" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
fi
;;
-u|--url)
if [ -n "$2" ]; then
url1="$2"
shift
else
printf $redbg'ERROR: "--url" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-d|--directory)
if [ -n "$2" ]; then
html="$2"
shift
else
printf $redbg'ERROR: "--directory" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
--cron)
if [ -n "$2" ]; then
cron="$2"
shift
else
printf $redbg'ERROR: "--cron" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-f|--folder)
folder="$2"
shift
;;
-s|--smtp)
if [ -n "$2" ]; then
smtp="$2"
shift
else
printf $redbg'ERROR: "--smtp" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
-a|--apps)
if [ -n "$2" ]; then
appsinstall="$2"
shift
else
printf $redbg'ERROR: "--apps" requires a non-empty option argument.' >&2
printf $reset"\n"
stty echo
exit 1
fi
;;
--) # End of all options.
shift
break
;;
-?*)
printf $redbg'Invalid option: %s' "$1" >&2
printf $reset"\n"
stty echo
exit 0
;;
*) # Default case: If no more options then break out of the loop.
break
esac
shift
done
# Set Header
header=' _____ _ _ _ _ _
| __ (_) | | | | | | | |
| |__) | ___| |_ ___ | |__| | ___ ___| |_
| ___/ |/ _ \ __/ __| | __ |/ _ \/ __| __| +-+-+-+-+
| | | | __/ |_\__ \ | | | | (_) \__ \ |_ | v 2.0 |
|_| |_|\___|\__|___/ |_| |_|\___/|___/\__| +-+-+-+-+'
# Set color for Status
check_ok=$green" OK "$reset
check_miss=$redbg"MISSING"$reset
# Define latest Nextcloud version
ncrepo="https://download.nextcloud.com/server/releases"
# Must be root
[[ `id -u` -eq 0 ]] || { echo "Root privileges required, type: sudo -i"; stty echo; exit 1; }
printhead
echo ""
# Read JSON config
if [[ "$isconfig" = "true" ]]; then
begin=$(date +%s)
jsonconfig
else
# Apps
contactsinstall='true'
calendarinstall='true'
mailinstall='false'
notesinstall='false'
tasksinstall='false'
galleryinstall='false'
impinstall='false'
fi
###################################
###### BEFORE SETUP START #####
###################################
printf "Checking minimal system requirements...\n"
sleep 4 & spinner
echo ""
# Check CPUs
cpus="$(nproc)"
if [[ "${cpus}" -lt 2 ]]; then
echo ""
printf $red"Attention: 2 CPUs recommended to install Nextcloud!\n"$reset
printf $red"Current CPU: ("$((cpus))")\n"$reset
anykey
else
printf $green"CPU for Nextcloud OK! ("$((cpus))")\n"$reset
echo ""
fi
# Check RAM
ram="$(awk '/MemTotal/{print $2}' /proc/meminfo)"
if [ "$ram" -lt "$((1*1002400))" ]; then
echo ""
printf $red"Attention: 1 GB RAM recommended to install Nextcloud!\n"$reset
printf $red"Current RAM is: ("$((ram/1002400))" GB)\n"$reset
anykey
else
printf $green"Enough RAM for Nextcloud found! ("$((ram/1002400))" GB)\n"$reset
fi
echo ""
# Check internet connection
wget -q --tries=10 --timeout=10 https://www.google.com -O /tmp/test.pgx &> /dev/null
if [ ! -s /tmp/test.pgx ]
then
printf $red"Sorry, no Internet Connection available. Try again later!\n"$reset
sleep 2
echo ""
exit 1
fi
# Ensure the OS is compatible with the installer
if [ -f /etc/centos-release ]; then
os="CentOs"
verfull=$(sed 's/^.*release //;s/ (Fin.*$//' /etc/centos-release)
ver=${verfull:0:1}
elif [ -f /etc/lsb-release ]; then
os=$(grep DISTRIB_ID /etc/lsb-release | sed 's/^.*=//')
ver=$(grep DISTRIB_RELEASE /etc/lsb-release | sed 's/^.*=//')
elif [ -f /etc/fedora-release ]; then
os=$(grep -w ID /etc/os-release | sed 's/^.*=//')
ver=$(grep VERSION_ID /etc/os-release | cut -c 12-)
elif [ -f /etc/os-release ]; then
os=$(grep -w ID /etc/os-release | sed 's/^.*=//')
ver=$(grep VERSION_ID /etc/os-release | sed 's/^.*"\(.*\)"/\1/')
else
os=$(uname -s)
ver=$(uname -r)
fi
arch=$(uname -m)
printf $yellow"Detected : $os $ver $arch\n"$reset
echo ""
sleeping
if [[ "$os" = "CentOs" && ("$ver" = "6" || "$ver" = "7" ) ||
"$os" = "Ubuntu" && ("$ver" = "12.04" || "$ver" = "14.04" || "$ver" = "16.04" || "$ver" = "18.04" ) ||
"$os" = "debian" && ("$ver" = "7" || "$ver" = "8" ) ||
"$os" = "fedora" && ("$ver" = "23" || "$ver" = "24" || "$ver" = "25") ]]; then
printf $green"Very Good! Your OS is compatible.\n"$reset
echo ""
sleeping
else
printf $red"Unfortunately, this OS is not supported by Piet's Host Installation-Script for Nextcloud.\n"$reset
sleeping2
abort
fi
sleeping
if [[ "$os" = "Ubuntu" && ("$ver" = "12.04" || "$ver" = "14.04" || "$ver" = "16.04" || "$ver" = "18.04" ) ]]; then
if [[ "$overwrite" = "true" ]]; then
#Check for Plesk installation
echo "checking additional control panels..."
echo ""
if dpkg -l | grep -q psa; then
plesk
fi
rootuser='root'
dbruser='root'
htgroup='www-data'
htuser='www-data'
else
if [[ "$isconfig" = "true" ]]; then
readusers
fi
fi
elif [[ "$os" = "debian" && ("$ver" = "7" || "$ver" = "8" ) ]]; then
if [[ "$overwrite" = "true" ]]; then
#Check for Plesk installation
echo "checking additional control panels..."
echo ""
if dpkg -l | grep -qw psa; then
plesk
fi
rootuser='root'
dbruser='root'
htgroup='www-data'
htuser='www-data'
else
if [[ "$isconfig" = "true" ]]; then
readusers
fi
fi
elif [[ "$os" = "CentOs" && ("$ver" = "6" || "$ver" = "7" ) ]]; then
if [[ "$overwrite" = "true" ]]; then
#Check for Plesk installation
echo "checking additional control panels..."
echo ""
if rpm -qa | grep -q psa; then
plesk
fi
rootuser='root'
dbruser='root'
htgroup='apache'
htuser='apache'
else
if [[ "$isconfig" = "true" ]]; then
readusers
fi
fi
elif [[ "$os" = "fedora" && ("$ver" = "23" || "$ver" = "25") ]]; then
if [[ "$overwrite" = "true" ]]; then
#Check for Plesk installation
echo "checking additional control panels..."
echo ""
if rpm -qa | grep -qw psa; then
plesk
fi
rootuser='root'
dbruser='root'
htgroup='apache'
htuser='apache'
else
if [[ "$isconfig" = "true" ]]; then
readusers
fi
fi
fi
if [[ "$depend" = "false" ]]; then
printf $yellow"Skipping dependencies check...\n"$reset
sleeping
else
printf $yellow"Installing dependencies...(may take some time)\n"$reset
{
if [[ "$os" = "Ubuntu" && ("$ver" = "12.04" || "$ver" = "14.04" || "$ver" = "16.04" || "$ver" = "18.04" ) ]]; then
dpkg -l | grep -qw pv || apt-get install pv -y
dpkg -l | grep -qw bzip2 || apt-get install bzip2 -y
dpkg -l | grep -qw rsync || apt-get install rsync -y
dpkg -l | grep -qw bc || apt-get install bc -y
dpkg -l | grep -qw xmlstarlet || apt-get install xmlstarlet -y
dpkg -l | grep -qw php-zip || apt-get install php-zip -y
dpkg -l | grep -qw php-dom || apt-get install php-dom -y
dpkg -l | grep -qw php-gd || apt-get install php-gd -y
dpkg -l | grep -qw php-curl || apt-get install php-curl -y
dpkg -l | grep -qw php-mbstring || apt-get install php-mbstring -y
dpkg -l | grep -qw curl || apt-get install curl -y
service apache2 restart
if [[ "$overwrite" = "true" ]]; then
rootuser='root'
dbruser='root'
htgroup='www-data'
htuser='www-data'
else
if [[ "$isconfig" = "true" ]]; then
readusers
fi
fi
elif [[ "$os" = "debian" && ("$ver" = "7" || "$ver" = "8" ) ]]; then
apt-get install pv -y
if dpkg -l | grep -qw bzip2; then echo "bzip2 INSTALLIERT"; else apt-get install bzip2 -y; fi;
if dpkg -l | grep -qw rsync; then echo "rsync INSTALLIERT"; else apt-get install rsync -y; fi;
if dpkg -l | grep -qw bc; then echo "bc INSTALLIERT"; else apt-get install bc -y; fi;
if dpkg -l | grep -qw xmlstarlet; then echo "xmlstarlet INSTALLIERT"; else apt-get install xmlstarlet -y; fi;
if dpkg -l | grep -qw php5-gd; then echo "php5-gd INSTALLIERT"; else apt-get install php5-gd -y; fi;
if dpkg -l | grep -qw php5-curl; then echo "php-5curl INSTALLIERT"; else apt-get install php5-curl -y; fi;
apt-get install curl -y
service apache2 restart
if [[ "$overwrite" = "true" ]]; then
rootuser='root'
dbruser='root'
htgroup='www-data'
htuser='www-data'
else
if [[ "$isconfig" = "true" ]]; then
readusers
fi
fi
elif [[ "$os" = "CentOs" && ("$ver" = "6" || "$ver" = "7" ) ]]; then
rpm -qa | grep -qw pv || yum install pv -y
rpm -qa | grep -qw bc || yum install bc -y
rpm -qa | grep -qw bzip2 || yum install bzip2 -y
rpm -qa | grep -qw rsync || yum install rsync -y
rpm -qa | grep -qw php-process || yum install php-process -y
rpm -qa | grep -qw xmlstarlet || yum install xmlstarlet -y
rpm -qa | grep -qw curl || yum install curl -y
if [[ "$overwrite" = "true" ]]; then
rootuser='root'
dbruser='root'
htgroup='apache'
htuser='apache'
else
if [[ "$isconfig" = "true" ]]; then
readusers
fi
fi
elif [[ "$os" = "fedora" && ("$ver" = "23" || "$ver" = "25") ]]; then
rpm -qa | grep -qw pv || dnf install pv -y
rpm -qa | grep -qw bc || dnf install bc -y
rpm -qa | grep -qw bzip2 || dnf install bzip2 -y
rpm -qa | grep -qw rsync || dnf install rsync -y
rpm -qa | grep -qw php-process || dnf install php-process -y
rpm -qa | grep -qw xmlstarlet || dnf install xmlstarlet -y
rpm -qa | grep -qw curl || dnf install curl -y
rpm -qa | grep -qw php-zip || dnf install php-zip -y
rpm -qa | grep -qw php-gd || dnf install php-gd -y
service httpd restart
if [[ "$overwrite" = "true" ]]; then
rootuser='root'
dbruser='root'
htgroup='apache'
htuser='apache'
else
if [[ "$isconfig" = "true" ]]; then
readusers
fi
fi
fi
} &> /dev/null
if [ "$perm" = "plesk" ]; then
echo ""
printf $cyan"Plesk detected...Setting DB-user and DB-password\n"$reset
sleeping2
fi
fi
#################################
###### BEFORE SETUP END #####
#################################
# Check Status on startup
folderstat="$check_ok"
iconstat="$check_ok"
check
#################################
###### INITIALIZATION ######
#################################
# enable user input
stty echo
# clear user input
read -t 1 -n 100 discard
if [[ "$isconfig" = "true" ]]; then
sleeping2
else
printhead
echo ""
echo "--------------------------------------------------------"
echo " Welcome to Piet's Host Nextcloud Install-Script "
echo "------+------------------------------------------+------"
######## |------------------------------------------|"$var
echo " | This Script will install Nextcloud |"
echo " | for you. To make it work, you have |"
echo " | to enter some variables on the |"
echo " | following pages. |"
echo " | Please read the documentation at |"
echo " | github for further information, |"
echo " | what syntax is required to make the |"
echo " | script work. |"
echo " | |"
echo " | Note: you can not go back within |"
echo " | this script! please read carefully |"
echo " | what is required. |"
echo " | |"
printf " | $yellow Database-Name, Database-password and $reset |\n"
printf " | $yellow Admin-password will be generated $reset |\n"
printf " | $yellow automatically. $reset |\n"
echo "------+------------------------------------------+------"
echo " | |"
echo "------+------------------------------------------+------"
read -n1 -r -p " | Press any key to continue... | " key
if [ "$key" = '' ]; then
return
fi
fi
echo ""
stty -echo
printhead
echo ""
####################################
###### INITIALIZATION END ######
####################################
###################################
###### Setup Page 1 Start #####
###################################
regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
regexmail="^[a-z0-9!#\$%&'*+/=?^_\`{|}~-]+(\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]([a-z0-9-]*[a-z0-9])?\$"
regexhttps='(https|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
stty echo
if [[ "$isconfig" = "true" ]]; then
echo ""
echo "Skipping Page 1"
else
check
clear
while true; do
printhead
echo ""
echo "--------------------------------------------------------------------------"
echo " Setup Page 1/3"
echo "------+------------+-----------------+------------------------------------"
echo " Nr. | Status | description | value"
echo "------+------------+-----------------+------------------------------------"
########### |xx-----------xxx|xxxxxxxxxXXXXXX:x|x"$var
printf " 1 | $domainstat | Domain: | "$url1"\n"
printf " 2 | $namestat | name: | "$ncname"\n"
printf " 3 | $htmlstat | directory: | "$html"\n"
printf " 4 | $folderstat | folder: | "$folder"\n"
echo ""
printf " 5 | $dbtypestat | DB-Type: | "$dbtype"\n"
printf " 6 | $dbhoststat | DB-Host: | "$dbhost"\n"
echo "------+------------+-----------------+------------------------------------"
printf "Type [1-6] to change value or ${cyan}[s]${reset} to save and go to next page\n"
printf "${red}[q]${reset} Quit\n"
echo -n "Enter [1-6], [s] or [q]: ";key1=$(readOne)
if [ "$key1" = "1" ]; then
echo ""
stty echo
echo -n "Enter url (with http:// or https://): "
read url1
# Check for correct input
if [[ $url1 =~ $regex ]]; then
[ -z "$url1" ] && domainstat="$check_miss" || domainstat="$check_ok"
if [[ $url1 =~ $regexhttps ]]; then
printf $redbg"Make sure you have a valid SSL-Certificate or Nextcloud won't work as expected\n"$reset
sleep 4
anykey
fi
else
printf $redbg"Wrong input format. Enter a valid URL..."$reset
url1="http://example.com"
sleep 3
continue
fi
elif [ "$key1" = "2" ]; then
echo ""
stty echo
echo -n "Enter name: "
read ncname
[ -z "$ncname" ] && namestat="$check_miss" || namestat="$check_ok"
elif [ "$key1" = "3" ]; then
echo ""
stty echo
echo -n "Enter html-directory (e.g. /var/www/html): "
read html
# Check for correct input
while ! [[ -d $html ]]; do
printf $redbg"Wrong input format or choosen directory does not exist... Enter html-directory: "$reset
read html
done
[ -z "$html" ] && htmlstat="$check_miss" || htmlstat="$check_ok"
elif [ "$key1" = "4" ]; then
echo ""
stty echo
echo -n "Enter folder name (Leave empty, if you want to install to root directory): "
read folder
[ "$folder" ] && folderstat="$check_ok"
elif [ "$key1" = "5" ]; then
echo ""
stty echo
echo -n "Enter Database-Type (e.g. mysql, sqlite, etc.): "
read dbtype
[ -z "$dbtype" ] && dbtypestat="$check_miss" || dbtypestat="$check_ok"
elif [ "$key1" = "6" ]; then
echo ""
stty echo
echo -n "Enter Database-Host (e.g. localhost): "
read dbhost
[ -z "$dbhost" ] && dbhoststat="$check_miss" || dbhoststat="$check_ok"
elif [ "$key1" = "s" ]; then
stty echo
if [ -z "$url1" ] || [ -z "$ncname" ] || [ -z "$html" ] || [ -z "$dbtype" ] || [ -z "$dbhost" ]; then
printf $redbg"One or more variables are undefined. Aborting..."$reset
sleep 3
continue
else
echo ""
echo "-----------------------------"
break
fi
elif [ "$key1" = "q" ]; then
abort
fi
done
fi
stty -echo
standardpath=$html/nextcloud
ncpath=$html/$folder
sleeping
#################################
###### Setup Page 1 End #####
#################################
# Check if Nextcloud is already installed.
if [ -f "$ncpath/occ" ]; then
chmod +x $ncpath/occ
CURRENTVERSION=$(sudo -u $htuser php $ncpath/occ status | grep "versionstring" | awk '{print $3}')
echo ""
printf $redbg"Nextcloud is already installed...\n"$reset
echo ""
echo "If your version isn't up to date make use of the Piet's Host ncupdate-script."
echo ""
sleeping2
abort
else
echo ""
printf $green"No Nextcloud installation found! Installing continues...\n"$reset
echo ""
sleeping3
fi
stty echo
######### Warning Apache & MySQL
{
type mysql >/dev/null 2>&1
} &> /dev/null
if [ $? -eq 0 ]; then
printf $green"MySQL installation found! Installing continues...\n"$reset
echo ""
sleeping3
else
printf $redbg"MySQL is not installed. Aborting...\n"$reset
sleeping3
abort
fi
{
ps -A | grep 'apache\|httpd\|nginx'
} &> /dev/null
if [ $? -eq 0 ]; then
printf $green"Apache/nginx installation found! Installing continues...\n"$reset
echo ""
sleeping3
else
printf $redbg"Apache/nginx is not installed/not running. Aborting..."$reset
echo ""
sleeping3
abort
fi
iconstat="$check_ok"
#########
###################################
###### Setup Page 2 Start #####
###################################
if [[ "$isconfig" = "true" ]]; then
echo "Skipping Page 2"
else
clear
while true; do
printhead
echo ""
stty echo
echo "--------------------------------------------------------------------------"
echo " Setup Page 2/3"
echo "------+------------+------------------+------------------------------------"
echo " Nr. | Status | description | value"
echo "------+------------+------------------+------------------------------------"
printf " 1 | $emailstat | E-Mail: | "$email"\n"
printf " 2 | $adusrstat | Admin Username: | "$adminuser"\n"
echo ""
printf " 3 | $dbusrstat | DB Username: | "$dbruser"\n"
echo -e " 4 | $dbrootstat |Database Root-PW: | "$database_root
echo ""
printf " 5 | $htusrstat | WWW User: | "$htuser"\n"
printf " 6 | $htgrpstat | WWW Group: | "$htgroup"\n"
printf " 7 | $rootusrstat | root user: | "$rootuser"\n"
printf " 8 | $cronstat | cronjob: | "$cron"\n"
printf " 9 | $iconstat | favicon: | "$icon"\n"
echo "------+------------+------------------+------------------------------------"
printf "Type [1-9] to change value or ${cyan}[s]${reset} to save and go to next page\n"
printf "${red}[q]${reset} Quit\n"
echo -en "Enter [1-9], [s] or [q]: ";key3=$(readOne)
if [ "$key3" = "1" ]; then
echo ""
stty echo
echo -n "Enter your E-mail: "
read email
# Check for correct input
if [[ $email =~ $regexmail ]]; then
[ -z "$email" ] && emailstat="$check_miss" || emailstat="$check_ok"
else
printf $redbg"Wrong input format. Enter a valid email address..."$reset
email='[email protected]'
sleep 3
continue
fi
elif [ "$key3" = "2" ]; then
echo ""
stty echo
echo -n "Please enter desired admin username for Nextcloud: "
read adminuser
# Make security advise in case of root or admin as username
shopt -s nocasematch
if [[ "$adminuser" = "root" ]] || [[ "$adminuser" = "admin" ]]; then
[ -z "$adminuser" ] && adusrstat="$check_miss" || adusrstat="$check_ok"
printf $redbg"Please don't use this username for security reasons. You should choose a unique username :) \n"$reset
anykey
else
[ -z "$adminuser" ] && adusrstat="$check_miss" || adusrstat="$check_ok"
fi
shopt -u nocasematch
elif [ "$key3" = "3" ]; then
echo ""
stty echo
echo -n "Please enter Database Root username: "
read dbruser
[ -z "$dbruser" ] && dbusrstat="$check_miss" || dbusrstat="$check_ok"
elif [ "$key3" = "4" ]; then
echo ""
stty echo
echo -n "Please enter password for database root account (won't be stored): "
read database_root
while ! mysqlcheck ; do
printf $redbg"Wrong password! Please enter the MySQL root password!: "$reset
read database_root
done
[ -z "$database_root" ] && dbrootstat="$check_miss" || dbrootstat="$check_ok"
elif [ "$key3" = "5" ]; then
echo ""
stty echo
echo -n "Enter WWW-User (e.g. apache, apache2, etc.): "
read htuser
while ! id "$htuser" >/dev/null 2>&1; do
printf $redbg"This user does not exist! Enter WWW-User: "$reset
read htuser
done
[ -z "$htuser" ] && htusrstat="$check_miss" || htusrstat="$check_ok"
if [ "$perm" = "plesk" ]; then
rootuser="$htuser"
fi
elif [ "$key3" = "6" ]; then
echo ""
stty echo
echo -n "Enter WWW-Group (e.g. apache, www-data, etc.): "
read htgroup
while ! grep -q $htgroup /etc/group >/dev/null 2>&1; do
printf $redbg"This user does not exist! Enter WWW-Group: "$reset
read htgroup
done
[ -z "$htgroup" ] && htgrpstat="$check_miss" || htgrpstat="$check_ok"
elif [ "$key3" = "7" ]; then
echo ""
stty echo
if [ "$perm" = "plesk" ]; then
rootuser="$htuser"
else
echo -n "Enter root user (usually: root): "
read rootuser
while ! id "$rootuser" >/dev/null 2>&1; do
printf $redbg"This user does not exist! Enter root user: "$reset
read rootuser
done
[ -z "$rootuser" ] && rootusrstat="$check_miss" || rootusrstat="$check_ok"
fi
elif [ "$key3" = "8" ]; then
if [ "$cron" = "true" ]; then
cron='false'
cronstat="$check_ok"
printf $red"Cronjob turned off\n"$reset
sleep 1
elif [ "$cron" = "false" ]; then
cron='true'
cronstat="$check_ok"
printf $green"Cronjob turned on\n"$reset
sleep 1
fi
elif [ "$key3" = "9" ]; then
echo ""
stty echo
echo -n "Enter favicon-location (e.g. /home/favicon.ico): "
read icon
iconstat="$check_ok"
elif [ "$key3" = "s" ]; then
stty echo
if [ -z "$email" ] || [ -z "$htuser" ] || [ -z "$htgroup" ] || [ -z "$rootuser" ] || [ -z "$dbruser" ] || [ -z "$adminuser" ] || [ -z "$database_root" ]; then
printf $redbg"One or more variables are undefined (Page 2). Aborting..."$reset
sleep 3
continue
else
echo ""
echo "-----------------------------"
break
fi
elif [ "$key3" = "q" ]; then
abort
fi
done
fi
sleeping
#################################
###### Setup Page 2 End #####
#################################
###################################
###### Setup Page 3 Start #####
###################################
if [[ "$isconfig" = "true" ]]; then
echo ""
echo "Skipping Page 3"
else
clear
while true; do
printhead
echo ""
stty echo
echo "--------------------------------------------------------------------------"
echo " Setup Page 3/3"
echo "------+------------+-------------------------------+-----------------------"
echo " Nr. | Status | description | value"
echo "------+------------+-------------------------------+-----------------------"
printf " 1 | $dpnamestat | allow change of display name: | "$displayname"\n"
printf " 2 | $rlchanstat | Release Channel: | "$rlchannel"\n"
printf " 3 | $memstat | Memcache: | "$memcache"\n"
printf " 4 | $maintstat | maintenance mode: | "$maintenance"\n"
printf " 5 | $singlestat | singleuser mode: | "$singleuser"\n"
printf " 6 | $skeletonstat | custom skeleton directory: | "$skeleton"\n"
printf " 7 | $skeletonstat | default language: | "$default_language"\n"
printf " 8 | $skeletonstat | enable avatars: | "$enable_avatars"\n"
printf " 9 | $skeletonstat | pretty URLs: | "$rewritebase"\n"
echo "------+------------+-------------------------------+---------------------------------"
printf "Type [1-9] to change value or ${cyan}[s]${reset} to save and go to next page\n"
printf "${red}[q]${reset} Quit\n"
echo -en "Enter [1-9], [s] or [q]: ";key4=$(readOne)
if [ "$key4" = "1" ]; then
if [ "$displayname" = "true" ]; then
displayname='false'
dpnamestat="$check_ok"
printf $red"allow change of display name set to false\n"$reset
sleeping
elif [ "$displayname" = "false" ]; then
displayname='true'
dpnamestat="$check_ok"
printf $green"allow change of display name set to true\n"$reset
sleeping
fi
elif [ "$key4" = "2" ]; then
echo ""
stty echo
echo -n "The channel that Nextcloud should use to look for updates (daily, beta, stable, production) "
read rlchannel
# Check for correct input
shopt -s nocasematch
if [[ "$rlchannel" = "daily" ]] || [[ "$rlchannel" = "beta" ]] || [[ "$rlchannel" = "stable" ]] || [[ "$rlchannel" = "production" ]]; then
[ -z "$rlchannel" ] && rlchanstat="$check_miss" || rlchanstat="$check_ok"
else
printf $redbg"Wrong input format. Please type daily, beta, stable or production..."$reset
rlchannel='stable'
sleep 3
continue
fi
shopt -u nocasematch
elif [ "$key4" = "3" ]; then
echo ""
stty echo
echo -n "Do you want to use memcache? (none, APCu): "
read memcache
# Check for correct input
shopt -s nocasematch
if [[ "$memcache" = "none" ]] || [[ "$memcache" = "APCu" ]]; then
[ -z "$memcache" ] && memstat="$check_miss" || memstat="$check_ok"
else
printf $redbg"Wrong input format. Please type none or APCu..."$reset
memcache='none'
sleep 3
continue
fi
shopt -u nocasematch
elif [ "$key4" = "4" ]; then
if [ "$maintenance" = "true" ]; then
maintenance='false'
maintstat="$check_ok"
printf $red"maintenance mode set to false\n"$reset
sleeping
elif [ "$maintenance" = "false" ]; then
maintenance='true'
maintstat="$check_ok"
printf $green"maintenance mode set to true\n"$reset
sleeping
fi
elif [ "$key4" = "5" ]; then
if [ "$singleuser" = "true" ]; then
singleuser='false'
singlestat="$check_ok"
printf $red"singleuser mode set to false\n"$reset
sleeping
elif [ "$singleuser" = "false" ]; then
singleuser='true'
singlestat="$check_ok"
printf $green"singleuser mode set to true\n"$reset
sleeping
fi
elif [ "$key4" = "6" ]; then
echo ""
stty echo
echo -n "Enter custom skeleton directory or type none for default: "
read skeleton
shopt -s nocasematch
if [ "$skeleton" = "none" ]; then
[ -z "$skeleton" ] && skeletonstat="$check_miss" || skeletonstat="$check_ok"
skeleton='none'