php-hotfix/installer/src/deps/php.sh

29 lines
988 B
Bash

function install_ext_php {
debug "Checking for the PHP GnuPG extension"
PHP_HAS_GNUPG=$(php -r "echo is_callable('gnupg_encrypt');")
PHP_VERSION=$(php -r "echo substr(PHP_VERSION_ID,0,1);")
if [ "$PHP_HAS_GNUPG" == "1" ]; then
info "GnuPG extension is installed"
else
info "Installing the GnuPG extension using pecl"
case $PHP_VERSION in
7)
exec "sudo pecl install gnupg-1.4.0RC1"
echo 'extension=gnupg.so' | sudo tee /etc/php/7.0/mods-available/gnupg.ini &>/dev/null
exec "sudo chmod 0744 /etc/php/7.0/mods-available/gnupg.ini"
sudo phpenmod gnupg
;;
*)
exec "sudo pecl install gnupg"
echo 'extension=gnupg.so' | sudo tee /etc/php5/cli/conf.d/gnupg.ini &>/dev/null
exec "sudo chmod 0744 /etc/php5/cli/conf.d/gnupg.ini"
;;
esac
exec "sudo chmod 0744 /usr/lib/php/*/gnupg.so";
fi
}
install_ext_php