Use YNH_DEFAULT_PHP_VERSION instead of 7.0

This commit is contained in:
Maniack Crudelis 2020-04-10 00:31:06 +02:00 committed by GitHub
parent d649fad13e
commit 017b0e929c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -195,9 +195,9 @@ ynh_install_php () {
# Store phpversion into the config of this app
ynh_app_setting_set $app phpversion $phpversion
if [ "$phpversion" == "7.0" ]
if [ "$phpversion" == "$YNH_DEFAULT_PHP_VERSION" ]
then
ynh_die "Do not use ynh_install_php to install php7.0"
ynh_die "Do not use ynh_install_php to install php$YNH_DEFAULT_PHP_VERSION"
fi
# Store the ID of this app and the version of php requested for it
@ -211,12 +211,12 @@ ynh_install_php () {
ynh_add_app_dependencies --package="php${phpversion}-fpm"
ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package"
# Set php7.0 back as the default version for php-cli.
update-alternatives --set php /usr/bin/php7.0
# Set the default php version back as the default version for php-cli.
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
# Pin this extra repository after packages are installed to prevent sury of doing shit
ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version
ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append
ynh_pin_repo --package="php${$YNH_DEFAULT_PHP_VERSION}*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append
# Advertise service in admin panel
yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log"
@ -229,11 +229,11 @@ ynh_remove_php () {
# Get the version of php used by this app
local phpversion=$(ynh_app_setting_get $app phpversion)
if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ]
if [ "$phpversion" == "$YNH_DEFAULT_PHP_VERSION" ] || [ -z "$phpversion" ]
then
if [ "$phpversion" == "7.0" ]
if [ "$phpversion" == "$YNH_DEFAULT_PHP_VERSION" ]
then
ynh_print_err "Do not use ynh_remove_php to install php7.0"
ynh_print_err "Do not use ynh_remove_php to install php$YNH_DEFAULT_PHP_VERSION"
fi
return 0
fi