Skip to content

Commit

Permalink
Enh/fix pecl php extensions (nextcloud#1830)
Browse files Browse the repository at this point in the history
  • Loading branch information
enoch85 authored Feb 19, 2021
1 parent fe291fe commit 3950bcd
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 22 deletions.
14 changes: 10 additions & 4 deletions addons/redis-server-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ exit 1
else
printf "${IGreen}\nPHP module installation OK!${Color_Off}\n"
fi
if [ ! -f $PHP_MODS_DIR/redis.ini ]
then
touch $PHP_MODS_DIR/redis.ini
fi
if ! grep -qFx extension=redis.so $PHP_MODS_DIR/redis.ini
then
echo "# PECL redis" > $PHP_MODS_DIR/redis.ini
echo "extension=redis.so" >> $PHP_MODS_DIR/redis.ini
check_command phpenmod -v ALL redis
fi
install_if_not redis-server

# Setting direct to PHP-FPM as it's installed with PECL (globally doesn't work)
print_text_in_color "$ICyan" "Adding extension=redis.so to $PHP_INI..."
echo 'extension=redis.so' >> "$PHP_INI"

# Prepare for adding redis configuration
sed -i "s|);||g" $NCPATH/config/config.php

Expand Down
8 changes: 6 additions & 2 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1633,9 +1633,13 @@ then
# export PHPVER=8.0
fi

export PHP_INI=/etc/php/"$PHPVER"/fpm/php.ini
export PHP_POOL_DIR=/etc/php/"$PHPVER"/fpm/pool.d
# Export other PHP variables based on PHPVER
export PHP_FPM_DIR=/etc/php/$PHPVER/fpm
export PHP_INI=$PHP_FPM_DIR/php.ini
export PHP_POOL_DIR=$PHP_FPM_DIR/pool.d
export PHP_MODS_DIR=/etc/php/"$PHPVER"/mods-available

# Show version
print_text_in_color "$IGreen" PHPVER="$PHPVER"
}

Expand Down
22 changes: 20 additions & 2 deletions nextcloud_install_production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,19 @@ then
fi
{
echo "# igbinary for PHP"
echo "extension=igbinary.so"
echo "session.serialize_handler=igbinary"
echo "igbinary.compact_strings=On"
} >> "$PHP_INI"
if [ ! -f $PHP_MODS_DIR/igbinary.ini ]
then
touch $PHP_MODS_DIR/igbinary.ini
fi
if ! grep -qFx extension=igbinary.so $PHP_MODS_DIR/igbinary.ini
then
echo "# PECL igbinary" > $PHP_MODS_DIR/igbinary.ini
echo "extension=igbinary.so" >> $PHP_MODS_DIR/igbinary.ini
check_command phpenmod -v ALL igbinary
fi
restart_webserver
fi

Expand All @@ -625,7 +634,6 @@ then
fi
{
echo "# APCu settings for Nextcloud"
echo "extension=apcu.so"
echo "apc.enabled=1"
echo "apc.max_file_size=5M"
echo "apc.shm_segments=1"
Expand All @@ -641,6 +649,16 @@ echo "apc.serializer=igbinary"
echo "apc.coredump_unmap=0"
echo "apc.preload_path"
} >> "$PHP_INI"
if [ ! -f $PHP_MODS_DIR/apcu.ini ]
then
touch $PHP_MODS_DIR/apcu.ini
fi
if ! grep -qFx extension=apcu.so $PHP_MODS_DIR/apcu.ini
then
echo "# PECL apcu" > $PHP_MODS_DIR/apcu.ini
echo "extension=apcu.so" >> $PHP_MODS_DIR/apcu.ini
check_command phpenmod -v ALL apcu
fi
restart_webserver
fi

Expand Down
73 changes: 59 additions & 14 deletions nextcloud_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,22 @@ then
yes no | pecl upgrade redis
systemctl restart redis-server.service
fi

# Double check if redis.so is enabled
if ! grep -qFx extension=redis.so "$PHP_INI"
# Remove old redis
if grep -qFx extension=redis.so "$PHP_INI"
then
sed -i "/extension=redis.so/d" "$PHP_INI"
fi
# Check if redis is enabled and create the file if not
if [ ! -f $PHP_MODS_DIR/redis.ini ]
then
touch $PHP_MODS_DIR/redis.ini
fi
# Enable new redis
if ! grep -qFx extension=redis.so $PHP_MODS_DIR/redis.ini
then
echo "extension=redis.so" >> "$PHP_INI"
echo "# PECL redis" > $PHP_MODS_DIR/redis.ini
echo "extension=redis.so" >> $PHP_MODS_DIR/redis.ini
check_command phpenmod -v ALL redis
fi

# Upgrade APCu and igbinary
Expand All @@ -277,10 +288,22 @@ then
if pecl list | grep igbinary >/dev/null 2>&1
then
yes no | pecl upgrade igbinary
# Check if igbinary.so is enabled
if ! grep -qFx extension=igbinary.so "$PHP_INI"
# Remove old igbinary
if grep -qFx extension=igbinary.so "$PHP_INI"
then
sed -i "/extension=igbinary.so/d" "$PHP_INI"
fi
# Check if igbinary is enabled and create the file if not
if [ ! -f $PHP_MODS_DIR/igbinary.ini ]
then
touch $PHP_MODS_DIR/igbinary.ini
fi
# Enable new igbinary
if ! grep -qFx extension=igbinary.so $PHP_MODS_DIR/igbinary.ini
then
echo "extension=igbinary.so" >> "$PHP_INI"
echo "# PECL igbinary" > $PHP_MODS_DIR/igbinary.ini
echo "extension=igbinary.so" >> $PHP_MODS_DIR/igbinary.ini
check_command phpenmod -v ALL igbinary
fi
fi
if pecl list | grep -q smbclient
Expand All @@ -301,25 +324,47 @@ then
# Remove old smbclient
if grep -qFx extension=smbclient.so "$PHP_INI"
then
sed -i "s|extension=smbclient.so||g" "$PHP_INI"
sed -i "/extension=smbclient.so/d" "$PHP_INI"
fi
fi
if pecl list | grep -q apcu
then
yes no | pecl upgrade apcu
# Check if apcu.so is enabled
if ! grep -qFx extension=apcu.so "$PHP_INI"
# Remove old igbinary
if grep -qFx extension=apcu.so "$PHP_INI"
then
echo "extension=apcu.so" >> "$PHP_INI"
sed -i "/extension=apcu.so/d" "$PHP_INI"
fi
# Check if apcu is enabled and create the file if not
if [ ! -f $PHP_MODS_DIR/apcu.ini ]
then
touch $PHP_MODS_DIR/apcu.ini
fi
# Enable new apcu
if ! grep -qFx extension=apcu.so $PHP_MODS_DIR/apcu.ini
then
echo "# PECL apcu" > $PHP_MODS_DIR/apcu.ini
echo "extension=apcu.so" >> $PHP_MODS_DIR/apcu.ini
check_command phpenmod -v ALL apcu
fi
fi
if pecl list | grep -q inotify
then
# Remove old inotify
if grep -qFx extension=inotify.so "$PHP_INI"
then
sed -i "/extension=inotify.so/d" "$PHP_INI"
fi
yes no | pecl upgrade inotify
# Check if inotify.so is enabled
if ! grep -qFx extension=inotify.so "$PHP_INI"
if [ ! -f $PHP_MODS_DIR/inotify.ini ]
then
touch $PHP_MODS_DIR/inotify.ini
fi
if ! grep -qFx extension=inotify.so $PHP_MODS_DIR/inotify.ini
then
echo "extension=inotify.so" >> "$PHP_INI"
echo "# PECL inotify" > $PHP_MODS_DIR/inotify.ini
echo "extension=inotify.so" >> $PHP_MODS_DIR/inotify.ini
check_command phpenmod -v ALL inotify
fi
fi
fi
Expand Down

0 comments on commit 3950bcd

Please sign in to comment.