Fix extension setup

This commit is contained in:
Shivam Mathur 2021-05-31 03:00:22 +05:30
parent d58b967b58
commit baab28a534
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -89,9 +89,7 @@ pecl_install() {
# Function to enable existing extensions. # Function to enable existing extensions.
enable_extension() { enable_extension() {
if [ -e /tmp/setup_php_dismod ] && grep -q "$1" /tmp/setup_php_dismod; then sudo find /var/lib/php/modules/"$version" -path "*disabled*$1" -delete
sudo phpenmod -v "$version" "$1" >/dev/null 2>&1
fi
if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then
echo "$2=$ext_dir/$1.so" | sudo tee -a "$pecl_file" >/dev/null echo "$2=$ext_dir/$1.so" | sudo tee -a "$pecl_file" >/dev/null
fi fi
@ -114,6 +112,7 @@ delete_extension() {
sudo sed -Ei "/=(.*\/)?\"?$extension/d" "$pecl_file" sudo sed -Ei "/=(.*\/)?\"?$extension/d" "$pecl_file"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
sudo sed -i "/Package: php$version-$extension/,/^$/d" /var/lib/dpkg/status
} }
# Function to disable and delete extensions # Function to disable and delete extensions
@ -121,7 +120,6 @@ remove_extension() {
extension=$1 extension=$1
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
sudo phpdismod -v "$version" "$extension" sudo phpdismod -v "$version" "$extension"
echo "$extension" | sudo tee -a /tmp/setup_php_dismod >/dev/null 2>&1
fi fi
delete_extension "$extension" delete_extension "$extension"
} }
@ -131,9 +129,8 @@ add_extension() {
extension=$1 extension=$1
install_command=$2 install_command=$2
prefix=$3 prefix=$3
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then enable_extension "$extension" "$prefix"
echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" if check_extension "$extension"; then
elif check_extension "$extension"; then
add_log "$tick" "$extension" "Enabled" add_log "$tick" "$extension" "Enabled"
elif ! check_extension "$extension"; then elif ! check_extension "$extension"; then
eval "$install_command" >/dev/null 2>&1 || eval "$install_command" >/dev/null 2>&1 ||
@ -153,9 +150,7 @@ add_pecl_extension() {
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
pecl_version=$(get_pecl_version "$extension" "$pecl_version") pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi fi
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then enable_extension "$extension" "$prefix"
echo "$prefix=$ext_dir/$extension.so" >>"$pecl_file"
fi
ext_version=$(php -r "echo phpversion('$extension');") ext_version=$(php -r "echo phpversion('$extension');")
if [ "$ext_version" = "$pecl_version" ]; then if [ "$ext_version" = "$pecl_version" ]; then
add_log "$tick" "$extension" "Enabled" add_log "$tick" "$extension" "Enabled"