-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathnextcloud-ins.sh
More file actions
3016 lines (2840 loc) · 114 KB
/
nextcloud-ins.sh
File metadata and controls
3016 lines (2840 loc) · 114 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
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
# Nextcloud Install Script
# Made for freshly installed, server Linux distributions using AMD64(x86_64) architecture:
# Debian (11 - 13), Enterprise Linux (9 - 10), Ubuntu Server (22 - 24), Fedora Server (39 - 42).
#
# It will update OS, preconfigure everything, install neeeded packages and Nextcloud.
# There is also support for upgrading Nextcloud and OS packages - just download and run latest version of this script again.
# It will create backup of current Nextcloud (but without users files) with it's database,
# and then it will upgrade OS, software packages, and Nextcloud to the newest major version.
#
# This Nextcloud installer allows Nextcloud to work locally and thru Internet:
# - by local IP address with and without SSL (it use self signed SSL certificate for https protocol),
# - or using domain name (local and over Internet), if domain is already configured correctly (it will use free Let's Encrypt service for certificate signing).
# Software packages that are installed are Apache (web server), MariaDB (database server), PHP (programming language with interpreter),
# NTP (time synchronization service), and Redis/Valkey (cache server).
# Some other software is also installed for better preview/thumbnails generation by Nextcloud like LibreOffice, Krita, ImageMagick etc.
# Also new service for Nextcloud "cron" is generated that starts every 5 minutes so Nextcloud can do some work while users are not connected.
#
# To use it just use this command (as root):
# "wget -q https://github.com/nicrame/Linux-Scripts/raw/master/nextcloud-ins.sh && chmod +x nextcloud-ins.sh && ./nextcloud-ins.sh"
#
# You may also add specific variables (lang, mail, dns) that will be used, by adding them to command above, e.g:
# "wget -q https://github.com/nicrame/Linux-Scripts/raw/master/nextcloud-ins.sh && chmod +x nextcloud-ins.sh && ./nextcloud-ins.sh -lang=pl -mail=my@email.com -dm=domain.com -nv=24 -fdir=/mnt/sdc5/nextcloud-data"
# -lang (for language) variable will install additional packages specific for choosed language and setup Nextcloud default language.
# Currently supported languages are: none (default value is none/empty that will use web browser language), Arabic (ar), Chinese (zh), French (fr), Hindi (hi), Polish (pl), Spanish (es) and Ukrainian (uk),
# -mail variable is for information about Your email address, that will be presented to let's encrypt, so you'll be informed if domain name SSL certificate couldn't be refreshed (default value is empty),
# -dm variable is used when you got (already prepared and configured) domain name, it will be configured for Nextcloud server and Let's encrypt SSL (default value is empty),
# -nv variable allows You to choose older version to install, supported version are: 24-28, empty (it will install newest, currently v28),
# -fdir variable gives possibility to specify where user files and nextcloud.log files are stored, by default this settings will leave default location that is /var/www/nextcloud/data.
# selecting different location will not change Nextcloud configuration, but will bind (using mount) default Nextcloud location, to the specified one,
# so using security mechanism like chroot/jail/SELinux etc. will work correctly without additional configuration for them, web server etc.
# For example if option -fdir=/mnt/sdc5/nextcloud-data will be used, then entering directory /var/www/nextcloud/data will actually show content of /mnt/sdc5/nextcloud-data.
# If you want to use spaces between words in directory name, then put path inside double quotes, eg. -fdir="/mnt/sdx/users data folder"
# To remember data directory settings, and mount them each OS start /etc/fstab file is modified.
# -restore argument is used for recovering older Nextcloud files/database. Since v 1.11 this script generate backup of Nextcloud files (excluding users data) and database,
# when it's started for upgrade process (which is default scenario when script is started another time after first use).
# You may use -restore=list to check the list of previously created backups, or -restore=filename.tar.bz2 to select one of those files, and use them to restore Nextcloud.
# IMPORTANT: When -restore argument is used with any kind of parameters, then any other is ignored. It means You can't use -restore variable with others.
# -backup argument starts backup process without doing any other tasks. It will just create backup of current Nextcloud install with database, excluding users files.
# Similar to -restore, -backup argument must be used by itself (any other one used with it will be ignored).
# -purge is used as standalone argument - it will remove all software installed by this script, and it's configuration. Also it will remove Nextcloud, with all files (also user data files), and database.
# It should be used only when first run didn't work correctly somehow - so this will do something like "revert" changes, so it is possible to start again.
#
# After install You may use Your web browser to access Nextcloud using local IP address,
# or domain name, if You have configured it before (DNS settings and router configuration should be done earlier by You).
# Both HTTP and HTTPS protocols are enabled by default. Localhost, self signed certificate is generated by default.
# For additional domain name certificate is made with Let's encrypt service (if You use -dns command variable).
#
# It was tested with many Nextcloud versions since v24.
#
# Updates of Nextcloud after using this script:
# By default this script disable "updatenotification" app that allow You to update Nextcloud using its own administration panel.
# The main reason is that such updates sometimes leave files that shouldn't stay, which brakes their update system at some points (i had many such problems in the past).
# So, to update Your Nextcloud there are two options:
# 1. You may start the script again, so it will upgrade OS with software packages and Nextcloud to the newest version (it will update between major releases too),
# so for example if You have version 28.0.3, it will update it to 31.0.4(that was newest version when this text was edited).
# But if You selected version to install with "-nv" argument (eg. -nv=28) when script was used for the first time, then starting script again will not update anything,
# and leave You with selected version, without updating minor release.
# So if You got 28.0.3 it will not update to 28.0.9 (because when this script is released, i do not know how many minor releases will be in the future).
# 2. You may also enable updatenotification app using Nextcloud GUI - go to Apps -> Disabled apps -> click on Enable button near "Update notification" app.
# Then go to "Administration settings" -> Overview, where will be information about new version available for updating.
#
# In case of problems, LOG output is generated at /var/log/nextcloud-installer.log.
# Attach it if You want to report errors with installation process.
#
# If You want to report errors that You think may be made by the script, please add logs of Apache web server, PHP and Nextcloud.
# This script was never tested, and not reccommended to be used on containerization environment (like Docker, LXC etc.),
# but it was working well on virtual machines under KVM and Virtualbox.
#
# More info:
# [PL/ENG] https://www.marcinwilk.eu/pl/projects/linux-scripts/nextcloud-debian-install/
#
# Feel free to contact me: marcin@marcinwilk.eu
# www.marcinwilk.eu
# Marcin Wilk
#
# License:
# 1. You use it at your own risk. Author is not responsible for any damage made with that script.
# 2. Any changes of scripts must be shared with author with authorization to implement them and share.
#
# V 1.12.4 - 24.11.2025
# - backup argument checks if Nextcloud was already installed
# - tweaks regarding the way script is started and running
# - check for firewalld and if it is installed in Debian, then do not add UFW, just it's own rules
# V 1.12.3 - 23.11.2025
# - Nextcloud Hub 25 (v32) support
# - little documentation changes
# - check if script is started in full login shell
# - new -purge option added that will remove software installed by this script with NC and whole database, so it's possible to start install process again with fresh data
# V 1.12.2 - 09.09.2025
# - fixes for better upgrade process from older NC versions
# V 1.12.1 - 09.09.2025
# - small tewaks and fixes
# V 1.12 - 07.09.2025
# - make PHP 8.4 the default version
# - change the way PHP configuration is stored (new, different config file instead of changing installed by packages)
# - Debian 13 support added
# - EL 10 support added (uses Valkey instead of Redis, tested on Rocky and RHEL)
# - Fedora 42 Server support added
# - Ubuntu 24 LTS Server support added
# V 1.11.5 - 25.05.2025
# - another portion of small tweaks
# V 1.11.4 - 24.05.2025
# - Nextcloud Hub 10 (v31) is now default/latest
# - small tweaks
# V 1.11.3 - 12.09.2024
# - Nextcloud Hub 9 (v30) is now default/latest
# - updated default versions to newest releases when using -nv parameter
# - add few commands to be sure that PHP 8.3 is used as default version
# - small tweaks and fixes
# V 1.11.2 - 16.05.2024
# - new arguments: -backup (create backup) and -restore (that can be used with "list" argument to show previously created backups, or with filename to be used to restore from it)
# - modify backup file names to show more data (date, time and Nextcloud version that is backed up)
# V 1.11 - 16.05.2024
# - update documentation inside script
# - first attempt to backup/restore feature
# V 1.10 - 19.04.2024
# - Nextcloud Hub 8 (v29) is now default/latest
# - PHP 8.3 is used as default PHP version
# - Fixed error that didn't allow installing older versions of NC (and PHP 7.4)
# V 1.9.2 - 13.03.2024
# - checking if "fdir" parameter is configured for already existing directory and inform if not
# - fix spaces in directory names saved in fstab, configured with -fdir argument (fstab do not support spaces in directory names)
# V 1.9.1 - 12.03.2024
# - some description update, and few code changes that do not affect the way script is working
# - add PHP 8.3 install code (currently disabled) for future NC versions
# V 1.9 - 04.03.2024
# - new argument that allow to configure location of "data" directory, where user files are stored (it use mount/fstab for security mechanisms compatibility)
# V 1.8.1 - 07.02.2024
# - first release with Fedora Server 39, and Ubuntu Server LTS (22) distributions support
# V 1.8 - 04.02.2024
# - first release with Rocky Linux (9), and other Enterprise Linux distributions support
# - a little more code optimizations
# V 1.7.1 - 01.02.2024
# - code cleanup
# - add maintenance window start time configuration (for 28.0.2 released today)
# V 1.7 - 30.01.2024
# - tweaks for thumbnails/preview generation
# - disabe sleep/hibernate modes in OS
# - add HTTP2 protocol support
# - small security fix
# - description improvements
# - packages installer will now wait for background jobs (started by OS) to finish
# V 1.6.4 - 04.01.2024
# - add bz2 module for PHP (for Nextcloud Hub 7)
# - Happy New Year!
# V 1.6.3 - 04.11.2023
# - more tests and fixes
# V 1.6.2 - 04.08.2023
# - few more languages are now supported with -lang= parameter (Arabic (ar), Chinese (zh), French (fr), Hindi (hi), Polish (pl), Spanish (es) and Ukrainian (uk))
# V 1.6.1 - 03.08.2023
# - small tweaks
# V 1.6 - 03.08.2023
# - new variable that allows installing older version of Nextcloud (users reported problems with NC27)
# - the script rename itself after finished work (so installer command always refer to newest version)
# - script is prepared now for few future updates (up to Nextcloud v28)
# V 1.5.5 - 12.07.2023
# - better description of variables use on error
# V 1.5.4 - 07.07.2023
# - fixed some logical problem
# - add support for Debian 12
# - add support for Nextcloud Hub 5 (v27)
# V 1.5.3 - 15.04.2023
# - using older PHP (8.1) version for upgrade process before removing it (Nextcloud do not finish upgrade process on never PHP version)
# - check for currently installed Nextcloud version and update it so many times it needs (till version 26) - when upgrading from script version 1.4 or older
# V 1.5.2 - 05.04.2023
# - twofactor_webauthn app installing and enabling for more security (tested with Yubikey)
# V 1.5.1 - 05.04.2023
# - upgrading from 1.4 and lower added to the script
# V 1.5 - 25.03.2023
# - use Nextcloud Hub 4 (v26)
# - enable opcache again (it looks it's working fine now)
# - use PHP version 8.2
# - install ddclient (dynamic DNS client - https://ddclient.net/)
# - install miniupnpc ans start it for port 80 and 443 to open ports (it should be unncessary)
# - added more variables to use (language, e_mail)
# - installer is now creating file with it's version number for future upgrades
# - installer detects if older versions of script were used, and in the next release it will upgrade everything (nextcloud included)
# V 1.4.3 - 24.02.2023
# - allow self-signed certificate config option in nextcloud (it may be needed sometimes)
# V 1.4.2 - 10.02.2023
# - completely disable opcache because of many segfaults even when JIT is completely disabled
# V 1.4.1 - 08.02.2023
# - opcache jit cache in php has been disabled because of many segfaults reported
# V 1.4 - 31.01.2023
# - fixes thanks to "maybe" user from hejto.pl portal (ufw, redis, chmods etc.) Thank You!
# V 1.3 - 30.01.2023
# - fix PHP 8.1 installing
# - more data stored to log for better error handling
# V 1.2 - 23.01.2023
# - some performance fixes (better support for large files)
# V 1.1 - 04.08.2022
# - added support for adding domain name as command line variable (with let's ecnrypt support)
# - added crontab job for certbot (Let's encrypt) and some more description
# V 1.0 - 20.06.2022
# - initial version based on private install script (for EL)
#
# Future plans:
# - add option to delete very old backups
# - add High Performance Backend (HPB) for Nextcloud (Push Service)
# - make backup of Nextcloud script (excluding users files) and database for recovery before upgrade (done with v1.11)
# - add option to restore previosly created backup (done with v1.11).
export LC_ALL=C
ver=1.12
cpu=$( uname -m )
user=$( whoami )
debvf=/etc/debian_version
ubuvf=/etc/dpkg/origins/ubuntu
if [[ $EUID -ne 0 ]]; then
echo -e "You must be \e[38;5;214mroot\e[39;0m. Mission aborted!"
echo -e "You are trying to start this script as: \e[1;31m$user\e[39;0m"
unset LC_ALL
exit 0
fi
if [ -e $debvf ]
then
if [ -e $ubuvf ]
then
ubuv=$( cat /etc/lsb-release | grep "Ubuntu " | awk -F '"' '{print $2}' )
unset debv
debv=$ubuv
ubu19=$( cat /etc/lsb-release | grep "Ubuntu 19" )
ubu20=$( cat /etc/lsb-release | grep "Ubuntu 20" )
ubu21=$( cat /etc/lsb-release | grep "Ubuntu 21" )
ubu22=$( cat /etc/lsb-release | grep "Ubuntu 22" )
ubu23=$( cat /etc/lsb-release | grep "Ubuntu 23" )
ubu24=$( cat /etc/lsb-release | grep "Ubuntu 24" )
ubu25=$( cat /etc/lsb-release | grep "Ubuntu 25" )
ubu26=$( cat /etc/lsb-release | grep "Ubuntu 26" )
ubu27=$( cat /etc/lsb-release | grep "Ubuntu 27" )
ubu28=$( cat /etc/lsb-release | grep "Ubuntu 28" )
else
debv=$( cat $debvf )
fi
fi
elvf=/etc/redhat-release
fedvf=/etc/fedora-release
if [ -e $elvf ]
then
elv=$( cat $elvf )
rhel=$( cat /etc/redhat-release | grep "Red Hat Enterprise Linux" )
el6=$( cat /etc/redhat-release | grep "release 6" )
el7=$( cat /etc/redhat-release | grep "release 7" )
el8=$( cat /etc/redhat-release | grep "release 8" )
el9=$( cat /etc/redhat-release | grep "release 9" )
el10=$( cat /etc/redhat-release | grep "release 10" )
rhel10=$( cat /etc/redhat-release | grep "Red Hat Enterprise Linux release 10" )
el11=$( cat /etc/redhat-release | grep "release 11" )
rhel11=$( cat /etc/redhat-release | grep "Red Hat Enterprise Linux release 11" )
if [ -e $fedvf ]
then
fed36=$( cat /etc/redhat-release | grep "release 36" )
fed37=$( cat /etc/redhat-release | grep "release 37" )
fed38=$( cat /etc/redhat-release | grep "release 38" )
fed39=$( cat /etc/redhat-release | grep "release 39" )
fed40=$( cat /etc/redhat-release | grep "release 40" )
fed41=$( cat /etc/redhat-release | grep "release 41" )
fed42=$( cat /etc/redhat-release | grep "release 42" )
fed43=$( cat /etc/redhat-release | grep "release 43" )
fed44=$( cat /etc/redhat-release | grep "release 44" )
fi
fi
TTY=$(tty 2>/dev/null || echo "notty")
TTY_SAN=$(echo "$TTY" | tr '/ ' '__')
FNAME=$(basename "$0")
MARKER="/tmp/.${FNAME}_rl_${TTY_SAN}"
if [ ! -f "$MARKER" ]; then
ORIG_CWD=$(pwd)
case "$0" in
/*) SCRIPT_PATH="$0" ;;
*) SCRIPT_PATH="$ORIG_CWD/$0" ;;
esac
: > "$MARKER" || {
echo "Error - cannot create file /tmp/$MARKER" >&2
exit 1
}
exec su - root -c '
ORIG_CWD=$1
SCRIPT_PATH=$2
shift 2
cd "$ORIG_CWD" || {
echo "Error - cannot access $ORIG_CWD directory." >&2
exit 1
}
exec "$SCRIPT_PATH" "$@"
' dummy "$ORIG_CWD" "$SCRIPT_PATH" -- "$@"
fi
trap 'rm -f "$MARKER"' EXIT
trap 'rm -f "$MARKER"; exit 130' INT
trap 'rm -f "$MARKER"; exit 143' TERM
addr=$( hostname -I )
addr1=$( hostname -I | awk '{print $1}' )
cdir=$( pwd )
if [ -e $debvf ]
then
websrv_usr=www-data
fi
if [ -e $elvf ]
then
websrv_usr=apache
fi
lang=""
mail=""
dm=""
nv=""
fdir=""
restore=""
insl=/var/log/nextcloud-installer.log
rstl=/var/log/nextcloud-ins-rst.log
ver_file=/var/local/nextcloud-installer.ver
nbckd=/var/local/nextcloud-installer-backups
nbckf=nextcloud.tar
scrpt=nextcloud-ins
backup=false
purge=false
while [ "$#" -gt 0 ]; do
case "$1" in
-lang=*) lang="${1#*=}" ;;
-mail=*) mail="${1#*=}" ;;
-dm=*) dm="${1#*=}" ;;
-nv=*) nv="${1#*=}" ;;
-fdir=*) fdir="${1#*=}" ;;
-restore=*) restore="${1#*=}" ;;
-backup) backup=true ;;
-purge) purge=true ;;
*)
echo "Unknown parameter: $1" >&2;
echo "Remember to add one, or more variables after equals sign:";
echo -e "Eg. \e[1;32m-\e[39;0mmail\e[1;32m=\e[39;0mmail@example.com \e[1;32m-\e[39;0mlang\e[1;32m=\e[39;0mpl \e[1;32m-\e[39;0mdm\e[1;32m=\e[39;0mdomain.com \e[1;32m-\e[39;0mnv\e[1;32m=\e[39;0m24 \e[1;32m-\e[39;0mfdir\e[1;32m=\e[39;0m/mnt/sdc5/nextcloud-data";
echo "or in case of backup, restore and purge argument (used individually):";
echo -e "\e[1;32m-\e[39;0mbackup";
echo -e "\e[1;32m-\e[39;0mrestore\e[1;32m=\e[39;0mlist";
echo -e "\e[1;32m-\e[39;0mrestore\e[1;32m=\e[39;0mfilename-from-list.tar.bz2";
echo -e "\e[1;32m-\e[39;0m\e[1;31mpurge\e[39;0m";
exit 1
;;
esac
shift
done
# More complex tasks are functions now:
function restart_websrv {
if [ -e $debvf ]
then
systemctl stop apache2 >> $insl 2>&1
fi
if [ -e $elvf ]
then
systemctl stop httpd >> $insl 2>&1
if [ -d /etc/opt/remi/php74 ]
then
systemctl stop php74-php-fpm >> $insl 2>&1
rm -rf /var/opt/remi/php74/lib/php/opcache/* >> $insl 2>&1
systemctl start php74-php-fpm >> $insl 2>&1
fi
fi
if [ -d /etc/opt/remi/php81 ]
then
systemctl stop php81-php-fpm >> $insl 2>&1
rm -rf /var/opt/remi/php81/lib/php/opcache/* >> $insl 2>&1
systemctl start php81-php-fpm >> $insl 2>&1
fi
if [ -d /etc/opt/remi/php82 ]
then
systemctl stop php82-php-fpm >> $insl 2>&1
rm -rf /var/opt/remi/php82/lib/php/opcache/* >> $insl 2>&1
systemctl start php82-php-fpm >> $insl 2>&1
fi
if [ -d /etc/opt/remi/php83 ]
then
systemctl stop php83-php-fpm >> $insl 2>&1
rm -rf /var/opt/remi/php83/lib/php/opcache/* >> $insl 2>&1
systemctl start php83-php-fpm >> $insl 2>&1
fi
if [ -d /etc/opt/remi/php84 ]
then
systemctl stop php84-php-fpm >> $insl 2>&1
rm -rf /var/opt/remi/php84/lib/php/opcache/* >> $insl 2>&1
systemctl start php84-php-fpm >> $insl 2>&1
fi
if [ -d /etc/opt/remi/php85 ]
then
systemctl stop php85-php-fpm >> $insl 2>&1
rm -rf /var/opt/remi/php85/lib/php/opcache/* >> $insl 2>&1
systemctl start php85-php-fpm >> $insl 2>&1
fi
if [ -d /etc/opt/remi/php86 ]
then
systemctl stop php86-php-fpm >> $insl 2>&1
rm -rf /var/opt/remi/php86/lib/php/opcache/* >> $insl 2>&1
systemctl start php86-php-fpm >> $insl 2>&1
fi
if [ -e $elvf ]
then
systemctl start httpd >> $insl 2>&1
fi
if [ -e $debvf ]
then
systemctl start apache2 >> $insl 2>&1
fi
}
function maintenance_window_setup {
if grep -q "maintenance_window_start" "/var/www/nextcloud/config/config.php"
then
echo "!!!!!!! Maintenance window time already configured." >> $insl 2>&1
else
echo "!!!!!!! Adding maintenance window time inside NC config." >> $insl 2>&1
sed -i "/installed' => true,/a\ \ 'maintenance_window_start' => '1'," /var/www/nextcloud/config/config.php
fi
}
# Check if Nextcloud was updated with nv variable, and if yes, skip doing anything to not brake it.
# This is version made for newer version of script, so it report that it was running under $ver_file.
function nv_check_upd {
echo "Older version of Nextcloud configured, skipping updates and exit."
echo "Older version of Nextcloud configured, skipping updates and exit." >> $insl 2>&1
echo -e "pver=$ver lang=$lang mail=$mail dm=$dm nv=$nv fdir=$fdir\n$(</var/local/nextcloud-installer.ver)" > $ver_file
echo -e "Version $ver was succesfully installed at $(date +%d-%m-%Y_%H:%M:%S)\n$(</var/local/nextcloud-installer.ver)" > $ver_file
mv $cdir/$scrpt.sh $scrpt-$(date +"%FT%H%M").sh
unset LC_ALL
exit 0
}
function nv_check_upd_cur {
echo "Older version of Nextcloud configured, skipping updates and exit."
echo "Older version of Nextcloud configured, skipping updates and exit." >> $insl 2>&1
mv $cdir/$scrpt.sh $scrpt-$(date +"%FT%H%M").sh
unset LC_ALL
exit 0
}
function nv_upd_simpl {
rm -rf /var/www/nextcloud/composer.lock >> $insl 2>&1
rm -rf /var/www/nextcloud/package-lock.json >> $insl 2>&1
rm -rf /var/www/nextcloud/package.json >> $insl 2>&1
rm -rf /var/www/nextcloud/composer.json >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ db:add-missing-indices >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/updater/updater.phar --no-interaction >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ upgrade >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ maintenance:mode --off >> $insl 2>&1
}
function update_os {
if [ -e $debvf ]
then
apt-get update -o DPkg::Lock::Timeout=-1 >> $insl 2>&1 && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y --force-yes -o Dpkg::Options::="--force-confold" -o DPkg::Lock::Timeout=-1 >> $insl 2>&1 && apt-get autoremove -y >> $insl 2>&1
fi
if [ -e $elvf ]
then
dnf update -y -q >> $insl 2>&1
fi
}
function install_soft {
echo "!!!!!!! Installing all needed standard packages." >> $insl 2>&1
if [ -e $debvf ]
then
DEBIAN_FRONTEND=noninteractive apt-get install -y -o DPkg::Lock::Timeout=-1 git lbzip2 unzip zip lsb-release locales-all rsync wget curl sed screen gawk mc sudo net-tools ethtool vim nano apt-transport-https ca-certificates miniupnpc jq libfontconfig1 libfuse2 socat tree ffmpeg imagemagick webp libreoffice ghostscript bindfs >> $insl 2>&1
# Package below do not appear in Debian 13 anymore
DEBIAN_FRONTEND=noninteractive apt-get install -y -o DPkg::Lock::Timeout=-1 software-properties-common >> $insl 2>&1
yes | sudo DEBIAN_FRONTEND=noninteractive apt-get -yqq -o DPkg::Lock::Timeout=-1 install ddclient >> $insl 2>&1
fi
if [ -e $elvf ]
then
if [ -e $fedvf ]
then
dnf install -y -q https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm >> $insl 2>&1
dnf config-manager -y --enable fedora-cisco-openh264 >> $insl 2>&1
else
if [ -n "rhel" ]
then
subscription-manager repos --enable codeready-builder-for-rhel-$(rpm -E %rhel)-$(arch)-rpms >> $insl 2>&1
dnf install -y -q https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %rhel).noarch.rpm >> $insl 2>&1
/usr/bin/crb enable >> $insl 2>&1
dnf install -q --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm -y >> $insl 2>&1
dnf install -q --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm -y >> $insl 2>&1
else
dnf -q config-manager --set-enabled crb >> $insl 2>&1
dnf install -y -q epel-release >> $insl 2>&1
dnf install -q --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm -y >> $insl 2>&1
dnf install -q --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm -y >> $insl 2>&1
fi
fi
dnf install -y -q git unzip bzip2 zip lsb-release rsync wget curl sed screen gawk mc sudo net-tools ethtool vim nano ca-certificates miniupnpc jq fontconfig-devel socat tree ffmpeg ImageMagick libwebp ghostscript >> $insl 2>&1
dnf install -y -q dnf-utils dnf-plugins-core >> $insl 2>&1
dnf update -y -q >> $insl 2>&1
dnf install -y -q libreoffice >> $insl 2>&1
dnf install -y -q ddclient >> $insl 2>&1
dnf install -y -q lbzip2 >> $insl 2>&1
dnf install -y -q openssl >> $insl 2>&1
fi
}
function ins_php {
if [ -e $debvf ]
then
if [ -e $ubuvf ]
then
add-apt-repository -y ppa:ondrej/php >> $insl 2>&1
DEBIAN_FRONTEND=noninteractive
else
curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg >> $insl 2>&1
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' >> $insl 2>&1
fi
apt-get update >> $insl 2>&1
apt-get install -y -o DPkg::Lock::Timeout=-1 php$dpv libapache2-mod-php$dpv php$dpv-mysql php$dpv-common php$dpv-redis php$dpv-dom php$dpv-curl php$dpv-exif php$dpv-fileinfo php$dpv-bcmath php$dpv-gmp php$dpv-imagick php$dpv-mbstring php$dpv-xml php$dpv-zip php$dpv-iconv php$dpv-intl php$dpv-simplexml php$dpv-xmlreader php$dpv-ftp php$dpv-ssh2 php$dpv-sockets php$dpv-gd php$dpv-imap php$dpv-soap php$dpv-xmlrpc php$dpv-apcu php$dpv-dev php$dpv-cli >> $insl 2>&1
apt-get install -y -o DPkg::Lock::Timeout=-1 libmagickcore-6.q16-6-extra >> $insl 2>&1
apt-get install -y -o DPkg::Lock::Timeout=-1 libmagickcore-7.q16-10-extra >> $insl 2>&1
apt-get install -y -o DPkg::Lock::Timeout=-1 php$dpv-bz2 >> $insl 2>&1
fi
if [ -e $elvf ]
then
if [ "$epv" = "81" ]
then
dnf remove -y -q php74-syspaths php74-mod_php >> $insl 2>&1
fi
if [ "$epv" = "82" ]
then
dnf remove -y -q php74-syspaths php74-mod_php >> $insl 2>&1
dnf remove -y -q php81-syspaths php81-mod_php >> $insl 2>&1
fi
if [ "$epv" = "83" ]
then
dnf remove -y -q php74-syspaths php74-mod_php >> $insl 2>&1
dnf remove -y -q php81-syspaths php81-mod_php >> $insl 2>&1
dnf remove -y -q php82-syspaths php82-mod_php >> $insl 2>&1
fi
if [ "$epv" = "84" ]
then
dnf remove -y -q php74-syspaths php74-mod_php >> $insl 2>&1
dnf remove -y -q php81-syspaths php81-mod_php >> $insl 2>&1
dnf remove -y -q php82-syspaths php82-mod_php >> $insl 2>&1
dnf remove -y -q php82-syspaths php83-mod_php >> $insl 2>&1
fi
if [ -e $fedvf ]
then
dnf install -y -q https://rpms.remirepo.net/fedora/remi-release-$(rpm -E %fedora).rpm >> $insl 2>&1
dnf config-manager --set-enabled remi >> $insl 2>&1
else
dnf install -y -q https://rpms.remirepo.net/enterprise/remi-release-$(rpm -E %rhel).rpm >> $insl 2>&1
fi
dnf install -y -q php$epv php$epv-php-apcu php$epv-php-opcache php$epv-php-mysql php$epv-php-bcmath php$epv-php-common php$epv-php-geos php$epv-php-gmp php$epv-php-pecl-imagick-im7 php$epv-php-pecl-lzf php$epv-php-pecl-mcrypt php$epv-php-pecl-recode php$epv-php-process php$epv-php-zstd php$epv-php-redis php$epv-php-dom php$epv-php-curl php$epv-php-exif php$epv-php-fileinfo php$epv-php-mbstring php$epv-php-xml php$epv-php-zip php$epv-php-iconv php$epv-php-intl php$epv-php-simplexml php$epv-php-xmlreader php$epv-php-ftp php$epv-php-ssh2 php$epv-php-sockets php$epv-php-gd php$epv-php-imap php$epv-php-soap php$epv-php-xmlrpc php$epv-php-apcu php$epv-php-cli php$epv-php-ast php$epv-php-brotli php$epv-php-enchant php$epv-php-ffi php$epv-php-lz4 php$epv-php-phalcon5 php$epv-php-phpiredis php$epv-php-smbclient php$epv-php-tidy php$epv-php-xz >> $insl 2>&1
dnf install -y -q php$epv-syspaths php$epv-mod_php >> $insl 2>&1
ln -s /var/opt/remi/php$epv/log/php-fpm /var/log/php$epv-fpm >> $insl 2>&1
fi
unset dpv
unset epv
}
function install_php74 {
dpv=7.4
epv=74
ins_php
}
function install_php81 {
dpv=8.1
epv=81
ins_php
}
function install_php82 {
dpv=8.2
epv=82
ins_php
}
function install_php83 {
dpv=8.3
epv=83
ins_php
}
function install_php84 {
dpv=8.4
epv=84
ins_php
}
function install_php85 {
dpv=8.5
epv=85
ins_php
}
function install_php86 {
dpv=8.6
epv=86
ins_php
}
# This is function for installing currently used latest version of PHP.
function install_php {
install_php84
}
# Check and add http2 support to Apache.
function add_http2 {
if [ -e $debvf ]
then
if grep -q "Protocols" "/etc/apache2/sites-available/nextcloud.conf"
then
echo "!!!!!!! HTTP2 already inside vhost config." >> $insl 2>&1
else
echo "!!!!!!! HTTP2 adding to vhost." >> $insl 2>&1
sed -i "/LimitRequestBody 0/a\ \ H2WindowSize 5242880" /etc/apache2/sites-available/nextcloud.conf
sed -i "/LimitRequestBody 0/a\ \ ProtocolsHonorOrder Off" /etc/apache2/sites-available/nextcloud.conf
sed -i "/LimitRequestBody 0/a\ \ Protocols h2 h2c http/1.1" /etc/apache2/sites-available/nextcloud.conf
fi
fi
}
function preview_tweaks {
echo "!!!!!!! Preview thumbnails tweaking in NC." >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\PNG" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 1 --value="OC\\Preview\\JPEG" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 2 --value="OC\\Preview\\GIF" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 3 --value="OC\\Preview\\BMP" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 4 --value="OC\\Preview\\XBitmap" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 5 --value="OC\\Preview\\MP3" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 6 --value="OC\\Preview\\TXT" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 7 --value="OC\\Preview\\MarkDown" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 8 --value="OC\\Preview\\OpenDocument" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 9 --value="OC\\Preview\\Krita" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 10 --value="OC\\Preview\\Illustrator" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 11 --value="OC\\Preview\\HEIC" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 12 --value="OC\\Preview\\HEIF" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 13 --value="OC\\Preview\\Movie" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 14 --value="OC\\Preview\\MSOffice2003" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 15 --value="OC\\Preview\\MSOffice2007" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 16 --value="OC\\Preview\\MSOfficeDoc" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 17 --value="OC\\Preview\\PDF" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 18 --value="OC\\Preview\\Photoshop" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 19 --value="OC\\Preview\\Postscript" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 20 --value="OC\\Preview\\StarOffice" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 21 --value="OC\\Preview\\SVG" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 22 --value="OC\\Preview\\TIFF" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 23 --value="OC\\Preview\\WEBP" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 24 --value="OC\\Preview\\EMF" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 25 --value="OC\\Preview\\Font" >> $insl 2>&1
sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:set enabledPreviewProviders 26 --value="OC\\Preview\\Image" >> $insl 2>&1
if [ -e $debvf ]
then
if [ -e /etc/ImageMagick-6/policy.xml ]
then
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*PS.*\/>\)/\1read|write\3/1' /etc/ImageMagick-6/policy.xml
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*PS2.*\/>\)/\1read|write\3/1' /etc/ImageMagick-6/policy.xml
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*PS3.*\/>\)/\1read|write\3/1' /etc/ImageMagick-6/policy.xml
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*EPS.*\/>\)/\1read|write\3/1' /etc/ImageMagick-6/policy.xml
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*PDF.*\/>\)/\1read|write\3/1' /etc/ImageMagick-6/policy.xml
fi
if [ -e /etc/ImageMagick-7/policy.xml ]
then
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*PS.*\/>\)/\1read|write\3/1' /etc/ImageMagick-7/policy.xml
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*PS2.*\/>\)/\1read|write\3/1' /etc/ImageMagick-7/policy.xml
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*PS3.*\/>\)/\1read|write\3/1' /etc/ImageMagick-7/policy.xml
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*EPS.*\/>\)/\1read|write\3/1' /etc/ImageMagick-7/policy.xml
sed -i 's/\(^ *<policy.*rights="\)\([^"]*\)\(".*PDF.*\/>\)/\1read|write\3/1' /etc/ImageMagick-7/policy.xml
fi
fi
}
function gen_phpini {
echo ";Configuration for Nextcloud
;Made by Nextcloud Installer Script - https://www.marcinwilk.eu/projects/linux-scripts/nextcloud-debian-install/
apc.enable_cli=1
opcache.enable_cli=1
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=20000
opcache.memory_consumption=256
opcache.save_comments=1
opcache.enable=1
mysqli.cache_size = 2000
memory_limit = 1024M
upload_max_filesize = 16G
post_max_size = 16G
max_file_uploads = 200
max_input_vars = 3000
max_input_time = 3600
max_execution_time = 3600
default_socket_timeout = 3600
output_buffering = Off" >> $php_ini
unset dpvi
unset epvi
}
function pvi {
echo "!!!!!!! PHP $dpvi config create." >> $insl 2>&1
if [ -e $debvf ]
then
touch /etc/php/$dpvi/mods-available/nextcloud-cfg.ini
php_ini=/etc/php/$dpvi/mods-available/nextcloud-cfg.ini
ln -s /etc/php/$dpvi/mods-available/nextcloud-cfg.ini /etc/php/$dpvi/apache2/conf.d/90-nextcloud-cfg.ini >> $insl 2>&1
ln -s /etc/php/$dpvi/mods-available/nextcloud-cfg.ini /etc/php/$dpvi/cli/conf.d/90-nextcloud-cfg.ini >> $insl 2>&1
fi
if [ -e $elvf ]
then
touch /etc/opt/remi/php$epvi/php.d/90-nextcloud-cfg.ini
php_ini=/etc/opt/remi/php$epvi/php.d/90-nextcloud-cfg.ini
fi
}
function php74_tweaks {
dpvi=7.4
epvi=74
pvi
gen_phpini
restart_websrv
}
function php81_tweaks {
dpvi=8.1
epvi=81
pvi
gen_phpini
a2dismod php7.4 >> $insl 2>&1
a2enmod php8.1 >> $insl 2>&1
restart_websrv
}
function php82_tweaks {
dpvi=8.2
epvi=82
pvi
gen_phpini
a2dismod php7.4 >> $insl 2>&1
a2dismod php8.1 >> $insl 2>&1
a2enmod php8.2 >> $insl 2>&1
restart_websrv
}
function php83_tweaks {
dpvi=8.3
epvi=83
pvi
gen_phpini
a2dismod php7.4 >> $insl 2>&1
a2dismod php8.1 >> $insl 2>&1
a2dismod php8.2 >> $insl 2>&1
a2enmod php8.3 >> $insl 2>&1
restart_websrv
}
function php84_tweaks {
dpvi=8.4
epvi=84
pvi
gen_phpini
a2dismod php7.4 >> $insl 2>&1
a2dismod php8.1 >> $insl 2>&1
a2dismod php8.2 >> $insl 2>&1
a2dismod php8.3 >> $insl 2>&1
a2enmod php8.4 >> $insl 2>&1
restart_websrv
}
function php85_tweaks {
dpvi=8.5
epvi=85
pvi
gen_phpini
a2dismod php7.4 >> $insl 2>&1
a2dismod php8.1 >> $insl 2>&1
a2dismod php8.2 >> $insl 2>&1
a2dismod php8.3 >> $insl 2>&1
a2dismod php8.4 >> $insl 2>&1
a2enmod php8.5 >> $insl 2>&1
restart_websrv
}
function php86_tweaks {
dpvi=8.6
epvi=86
pvi
gen_phpini
a2dismod php7.4 >> $insl 2>&1
a2dismod php8.1 >> $insl 2>&1
a2dismod php8.2 >> $insl 2>&1
a2dismod php8.3 >> $insl 2>&1
a2dismod php8.4 >> $insl 2>&1
a2dismod php8.5 >> $insl 2>&1
a2enmod php8.6 >> $insl 2>&1
restart_websrv
}
# This are tweaks for currently latest verion used.
function php_tweaks {
php84_tweaks
}
function save_version_info {
echo -e "pver=$ver lang=$lang mail=$mail dm=$dm nv=$nv fdir=$fdir\n$(</var/local/nextcloud-installer.ver)" > $ver_file
echo -e "Version $ver was succesfully installed at $(date +%d-%m-%Y_%H:%M:%S)\n$(</var/local/nextcloud-installer.ver)" > $ver_file
}
function save_upg_info {
echo -e "pver=$ver lang=$lang mail=$mail dm=$dm nv=$nv fdir=$fdir\n$(</var/local/nextcloud-installer.ver)" > $ver_file
echo -e "Succesfully upgraded to $ver at $(date +%d-%m-%Y_%H:%M:%S)\n$(</var/local/nextcloud-installer.ver)" > $ver_file
}
function disable_sleep {
echo "!!!!!!! Disabling sleep states." >> $insl 2>&1
echo "Disabling sleep states."
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target >> $insl 2>&1
}
# Check if nv option was used for every version, and exit without progress.
function nv_verify {
if [ "$nv" = "24" ]
then
nv_check_upd
fi
if [ "$nv" = "25" ]
then
nv_check_upd
fi
if [ "$nv" = "26" ]
then
nv_check_upd
fi
if [ "$nv" = "27" ]
then
nv_check_upd
fi
if [ "$nv" = "28" ]
then
maintenance_window_setup
nv_check_upd
fi
if [ "$nv" = "29" ]
then
nv_check_upd
fi
if [ "$nv" = "30" ]
then
nv_check_upd
fi
if [ "$nv" = "31" ]
then
nv_check_upd
fi
if [ "$nv" = "32" ]
then
nv_check_upd
fi
if [ "$nv" = "33" ]
then
nv_check_upd
fi
if [ "$nv" = "34" ]
then
nv_check_upd
fi
}
# Unset nver variable and read fresh value
function sncver {
unset ncver
ncver=$( sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:get version | awk -F '.' '{print $1}' )
}
function ncverf {
unset ncverf
ncverf=$( sudo -u $websrv_usr php /var/www/nextcloud/occ config:system:get version )
}
# Check for every version and update it one by one.
function nv_update {
sncver
if [ "$ncver" = "24" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "24" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "24" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "25" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "25" ]
then
install_php81
php81_tweaks
nv_upd_simpl
fi
sncver
if [ "$ncver" = "25" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "26" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "26" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "26" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "27" ]
then
install_php82
php82_tweaks
nv_upd_simpl
fi
sncver
if [ "$ncver" = "27" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "27" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "28" ]
then
install_php82
php82_tweaks
nv_upd_simpl
fi
sncver
if [ "$ncver" = "28" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "28" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "29" ]
then
install_php83
php83_tweaks
nv_upd_simpl
fi
sncver
if [ "$ncver" = "29" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "29" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "30" ]
then
nv_upd_simpl
fi
sncver
if [ "$ncver" = "30" ]
then
install_php83
php83_tweaks
nv_upd_simpl
fi
sncver
if [ "$ncver" = "30" ]
then
nv_upd_simpl