Skip to content

Commit 3f16f77

Browse files
authored
rearrange install script (#2551)
1 parent fd92b6e commit 3f16f77

File tree

2 files changed

+107
-109
lines changed

2 files changed

+107
-109
lines changed

addons/redis-server-ubuntu.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ then
5656
fi
5757
install_if_not redis-server
5858

59-
# Add the needed config to Nextclouds config.php
60-
nextcloud_occ config:system:set memcache.local --value='\OC\Memcache\Redis'
61-
nextcloud_occ config:system:set filelocking.enabled --value='true'
62-
nextcloud_occ config:system:set memcache.distributed --value='\OC\Memcache\Redis'
63-
nextcloud_occ config:system:set memcache.locking --value='\OC\Memcache\Redis'
64-
65-
nextcloud_occ config:system:set redis host --value="$REDIS_SOCK"
66-
nextcloud_occ config:system:set redis port --value=0
67-
nextcloud_occ config:system:set redis dbindex --value=0
68-
nextcloud_occ config:system:set redis timeout --value=0.5
69-
nextcloud_occ config:system:set redis timeout --value="$REDIS_PASS"
70-
7159
## Redis performance tweaks ##
7260
if ! grep -Fxq "vm.overcommit_memory = 1" /etc/sysctl.conf
7361
then
@@ -102,4 +90,16 @@ apt-get update -q4 & spinner_loading
10290
apt-get autoremove -y
10391
apt-get autoclean
10492

93+
# Add the needed config to Nextclouds config.php
94+
nextcloud_occ config:system:set memcache.local --value='\OC\Memcache\Redis'
95+
nextcloud_occ config:system:set filelocking.enabled --value='true'
96+
nextcloud_occ config:system:set memcache.distributed --value='\OC\Memcache\Redis'
97+
nextcloud_occ config:system:set memcache.locking --value='\OC\Memcache\Redis'
98+
99+
nextcloud_occ config:system:set redis host --value="$REDIS_SOCK"
100+
nextcloud_occ config:system:set redis port --value=0
101+
nextcloud_occ config:system:set redis dbindex --value=0
102+
nextcloud_occ config:system:set redis timeout --value=0.5
103+
nextcloud_occ config:system:set redis timeout --value="$REDIS_PASS"
104+
105105
exit

nextcloud_install_production.sh

Lines changed: 95 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -63,50 +63,6 @@ fi
6363
# Restart mode: (l)ist only, (i)nteractive or (a)utomatically.
6464
sed -i "s|#\$nrconf{restart} = .*|\$nrconf{restart} = 'a';|g" /etc/needrestart/needrestart.conf
6565

66-
# Fix LVM on BASE image
67-
if grep -q "LVM" /etc/fstab
68-
then
69-
if [ -n "$PROVISIONING" ] || yesno_box_yes "Do you want to make all free space available to your root partition?"
70-
then
71-
# Resize LVM (live installer is &%¤%/!
72-
# VM
73-
print_text_in_color "$ICyan" "Extending LVM, this may take a long time..."
74-
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
75-
76-
# Run it again manually just to be sure it's done
77-
while :
78-
do
79-
lvdisplay | grep "Size" | awk '{print $3}'
80-
if ! lvextend -L +10G /dev/ubuntu-vg/ubuntu-lv >/dev/null 2>&1
81-
then
82-
if ! lvextend -L +1G /dev/ubuntu-vg/ubuntu-lv >/dev/null 2>&1
83-
then
84-
if ! lvextend -L +100M /dev/ubuntu-vg/ubuntu-lv >/dev/null 2>&1
85-
then
86-
if ! lvextend -L +1M /dev/ubuntu-vg/ubuntu-lv >/dev/null 2>&1
87-
then
88-
resize2fs /dev/ubuntu-vg/ubuntu-lv
89-
break
90-
fi
91-
fi
92-
fi
93-
fi
94-
done
95-
fi
96-
fi
97-
98-
# Install needed dependencies
99-
install_if_not lshw
100-
install_if_not net-tools
101-
install_if_not whiptail
102-
install_if_not apt-utils
103-
install_if_not keyboard-configuration
104-
105-
# Nice to have dependencies
106-
install_if_not bash-completion
107-
install_if_not htop
108-
install_if_not iputils-ping
109-
11066
# Check for flags
11167
if [ "$1" = "" ]
11268
then
@@ -156,6 +112,50 @@ Enabling this will also force an automatic reboot after running the update scrip
156112
fi
157113
fi
158114

115+
# Fix LVM on BASE image
116+
if grep -q "LVM" /etc/fstab
117+
then
118+
if [ -n "$PROVISIONING" ] || yesno_box_yes "Do you want to make all free space available to your root partition?"
119+
then
120+
# Resize LVM (live installer is &%¤%/!
121+
# VM
122+
print_text_in_color "$ICyan" "Extending LVM, this may take a long time..."
123+
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
124+
125+
# Run it again manually just to be sure it's done
126+
while :
127+
do
128+
lvdisplay | grep "Size" | awk '{print $3}'
129+
if ! lvextend -L +10G /dev/ubuntu-vg/ubuntu-lv >/dev/null 2>&1
130+
then
131+
if ! lvextend -L +1G /dev/ubuntu-vg/ubuntu-lv >/dev/null 2>&1
132+
then
133+
if ! lvextend -L +100M /dev/ubuntu-vg/ubuntu-lv >/dev/null 2>&1
134+
then
135+
if ! lvextend -L +1M /dev/ubuntu-vg/ubuntu-lv >/dev/null 2>&1
136+
then
137+
resize2fs /dev/ubuntu-vg/ubuntu-lv
138+
break
139+
fi
140+
fi
141+
fi
142+
fi
143+
done
144+
fi
145+
fi
146+
147+
# Install needed dependencies
148+
install_if_not lshw
149+
install_if_not net-tools
150+
install_if_not whiptail
151+
install_if_not apt-utils
152+
install_if_not keyboard-configuration
153+
154+
# Nice to have dependencies
155+
install_if_not bash-completion
156+
install_if_not htop
157+
install_if_not iputils-ping
158+
159159
# Download needed libraries before execution of the first script
160160
mkdir -p "$SCRIPTS"
161161
download_script GITHUB_REPO lib
@@ -542,7 +542,7 @@ This is used when you login to Nextcloud itself, i.e. on the web."
542542
fi
543543

544544
# Install Nextcloud
545-
print_text_in_color "$ICyan" "Installing Nextcloud..."
545+
print_text_in_color "$ICyan" "Installing Nextcloud, it might take a while..."
546546
cd "$NCPATH"
547547
nextcloud_occ maintenance:install \
548548
--data-dir="$NCDATA" \
@@ -552,11 +552,59 @@ nextcloud_occ maintenance:install \
552552
--database-pass="$PGDB_PASS" \
553553
--admin-user="$GUIUSER" \
554554
--admin-pass="$GUIPASS"
555-
echo
556555
print_text_in_color "$ICyan" "Nextcloud version:"
557556
nextcloud_occ status
558557
sleep 3
559-
echo
558+
559+
# Install PECL dependencies
560+
install_if_not php"$PHPVER"-dev
561+
562+
# Install Redis (distributed cache)
563+
run_script ADDONS redis-server-ubuntu
564+
565+
# Install smbclient
566+
# php"$PHPVER"-smbclient does not yet work in PHP 7.4
567+
install_if_not libsmbclient-dev
568+
yes no | pecl install smbclient
569+
if [ ! -f "$PHP_MODS_DIR"/smbclient.ini ]
570+
then
571+
touch "$PHP_MODS_DIR"/smbclient.ini
572+
fi
573+
if ! grep -qFx extension=smbclient.so "$PHP_MODS_DIR"/smbclient.ini
574+
then
575+
echo "# PECL smbclient" > "$PHP_MODS_DIR"/smbclient.ini
576+
echo "extension=smbclient.so" >> "$PHP_MODS_DIR"/smbclient.ini
577+
check_command phpenmod -v ALL smbclient
578+
fi
579+
580+
# Enable igbinary for PHP
581+
# https://github.com/igbinary/igbinary
582+
if is_this_installed "php$PHPVER"-dev
583+
then
584+
if ! yes no | pecl install -Z igbinary
585+
then
586+
msg_box "igbinary PHP module installation failed"
587+
exit
588+
else
589+
print_text_in_color "$IGreen" "igbinary PHP module installation OK!"
590+
fi
591+
{
592+
echo "# igbinary for PHP"
593+
echo "session.serialize_handler=igbinary"
594+
echo "igbinary.compact_strings=On"
595+
} >> "$PHP_INI"
596+
if [ ! -f "$PHP_MODS_DIR"/igbinary.ini ]
597+
then
598+
touch "$PHP_MODS_DIR"/igbinary.ini
599+
fi
600+
if ! grep -qFx extension=igbinary.so "$PHP_MODS_DIR"/igbinary.ini
601+
then
602+
echo "# PECL igbinary" > "$PHP_MODS_DIR"/igbinary.ini
603+
echo "extension=igbinary.so" >> "$PHP_MODS_DIR"/igbinary.ini
604+
check_command phpenmod -v ALL igbinary
605+
fi
606+
restart_webserver
607+
fi
560608

561609
# Prepare cron.php to be run every 5 minutes
562610
crontab -u www-data -l | { cat; echo "*/5 * * * * php -f $NCPATH/cron.php > /dev/null 2>&1"; } | crontab -u www-data -
@@ -662,56 +710,6 @@ echo "pgsql.ignore_notice = 0"
662710
echo "pgsql.log_notice = 0"
663711
} >> "$PHP_FPM_DIR"/conf.d/20-pdo_pgsql.ini
664712

665-
# Install PECL dependencies
666-
install_if_not php"$PHPVER"-dev
667-
668-
# Install Redis (distributed cache)
669-
run_script ADDONS redis-server-ubuntu
670-
671-
# Install smbclient
672-
# php"$PHPVER"-smbclient does not yet work in PHP 7.4
673-
install_if_not libsmbclient-dev
674-
yes no | pecl install smbclient
675-
if [ ! -f "$PHP_MODS_DIR"/smbclient.ini ]
676-
then
677-
touch "$PHP_MODS_DIR"/smbclient.ini
678-
fi
679-
if ! grep -qFx extension=smbclient.so "$PHP_MODS_DIR"/smbclient.ini
680-
then
681-
echo "# PECL smbclient" > "$PHP_MODS_DIR"/smbclient.ini
682-
echo "extension=smbclient.so" >> "$PHP_MODS_DIR"/smbclient.ini
683-
check_command phpenmod -v ALL smbclient
684-
fi
685-
686-
# Enable igbinary for PHP
687-
# https://github.com/igbinary/igbinary
688-
if is_this_installed "php$PHPVER"-dev
689-
then
690-
if ! yes no | pecl install -Z igbinary
691-
then
692-
msg_box "igbinary PHP module installation failed"
693-
exit
694-
else
695-
print_text_in_color "$IGreen" "igbinary PHP module installation OK!"
696-
fi
697-
{
698-
echo "# igbinary for PHP"
699-
echo "session.serialize_handler=igbinary"
700-
echo "igbinary.compact_strings=On"
701-
} >> "$PHP_INI"
702-
if [ ! -f "$PHP_MODS_DIR"/igbinary.ini ]
703-
then
704-
touch "$PHP_MODS_DIR"/igbinary.ini
705-
fi
706-
if ! grep -qFx extension=igbinary.so "$PHP_MODS_DIR"/igbinary.ini
707-
then
708-
echo "# PECL igbinary" > "$PHP_MODS_DIR"/igbinary.ini
709-
echo "extension=igbinary.so" >> "$PHP_MODS_DIR"/igbinary.ini
710-
check_command phpenmod -v ALL igbinary
711-
fi
712-
restart_webserver
713-
fi
714-
715713
# Fix https://github.com/nextcloud/vm/issues/714
716714
print_text_in_color "$ICyan" "Optimizing Nextcloud..."
717715
yes | nextcloud_occ db:convert-filecache-bigint

0 commit comments

Comments
 (0)