From b3755ebdee2342cd90b97d6c41c4012b45c67685 Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 8 Feb 2020 12:39:48 +0100 Subject: [PATCH 1/4] Set the default php version to use --- conf/nginx.conf | 2 +- conf/php-fpm.conf | 2 +- scripts/_common.sh | 2 +- scripts/backup | 3 ++- scripts/install | 4 +++- scripts/restore | 5 +++-- scripts/upgrade | 9 ++++++++- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f2277ea..37de41d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -18,7 +18,7 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index ab5dca9..ab1a471 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -33,7 +33,7 @@ group = __USER__ ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8bb05b4..7e55ac0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="deb1 deb2" +pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index d985aba..2f1b4b1 100755 --- a/scripts/backup +++ b/scripts/backup @@ -31,6 +31,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # STANDARD BACKUP STEPS @@ -60,7 +61,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1 -ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/install b/scripts/install index 4cbacc8..e03a016 100755 --- a/scripts/install +++ b/scripts/install @@ -75,6 +75,8 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=language --value=$language +ynh_app_setting_set --app=$app --key=phpversion --value=$YNH_DEFAULT_PHP_VERSION + #================================================= # STANDARD MODIFICATIONS #================================================= @@ -153,7 +155,7 @@ ynh_script_progression --message="Configuring nginx web server..." --time --weig ### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config php_version #================================================= # CREATE DEDICATED USER diff --git a/scripts/restore b/scripts/restore index a153a70..ab43d71 100755 --- a/scripts/restore +++ b/scripts/restore @@ -33,6 +33,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -78,7 +79,7 @@ chown -R root: $final_path # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # RESTORE FAIL2BAN CONFIGURATION @@ -148,7 +149,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 -ynh_systemd_action --service_name=php7.0-fpm --action=reload +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 243e85b..cb647b3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,7 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION @@ -62,6 +63,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# If phpversion doesn't exist, create it +if [ -z "$phpversion" ]; then + phpversion=$YNH_DEFAULT_PHP_VERSION + ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -115,7 +122,7 @@ fi ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config php_version #================================================= # UPGRADE DEPENDENCIES From 426f0b2ddf29cf80abe51228ea4d4410106bb4f7 Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 8 Feb 2020 12:43:49 +0100 Subject: [PATCH 2/4] Move nginx after php --- scripts/upgrade | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index cb647b3..65727b4 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -116,14 +116,6 @@ then ynh_setup_source --dest_dir="$final_path" fi -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 - -# Create a dedicated nginx config -ynh_add_nginx_config php_version - #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -147,6 +139,14 @@ ynh_script_progression --message="Upgrading php-fpm configuration..." --time --w # Create a dedicated php-fpm config ynh_add_fpm_config +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 + +# Create a dedicated nginx config +ynh_add_nginx_config php_version + #================================================= # SPECIFIC UPGRADE #================================================= From bcab74253f1042262a2a00a577ad1cffeee8af72 Mon Sep 17 00:00:00 2001 From: maniack Date: Sun, 9 Feb 2020 18:27:35 +0100 Subject: [PATCH 3/4] Adapt the code accordingly to https://github.com/YunoHost/yunohost/pull/879 --- scripts/install | 4 +--- scripts/upgrade | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/scripts/install b/scripts/install index e03a016..4cbacc8 100755 --- a/scripts/install +++ b/scripts/install @@ -75,8 +75,6 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=language --value=$language -ynh_app_setting_set --app=$app --key=phpversion --value=$YNH_DEFAULT_PHP_VERSION - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -155,7 +153,7 @@ ynh_script_progression --message="Configuring nginx web server..." --time --weig ### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config -ynh_add_nginx_config php_version +ynh_add_nginx_config #================================================= # CREATE DEDICATED USER diff --git a/scripts/upgrade b/scripts/upgrade index 65727b4..ef79017 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,7 +23,6 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION @@ -63,12 +62,6 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi -# If phpversion doesn't exist, create it -if [ -z "$phpversion" ]; then - phpversion=$YNH_DEFAULT_PHP_VERSION - ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -123,6 +116,14 @@ ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 ynh_install_app_dependencies $pkg_dependencies +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 + +# Create a dedicated nginx config +ynh_add_nginx_config + #================================================= # CREATE DEDICATED USER #================================================= @@ -139,14 +140,6 @@ ynh_script_progression --message="Upgrading php-fpm configuration..." --time --w # Create a dedicated php-fpm config ynh_add_fpm_config -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 - -# Create a dedicated nginx config -ynh_add_nginx_config php_version - #================================================= # SPECIFIC UPGRADE #================================================= From ba90882b20dc182210acb296494cc5cfd9428896 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 9 Feb 2020 18:29:41 +0100 Subject: [PATCH 4/4] Update upgrade --- scripts/upgrade | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index ef79017..243e85b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -109,13 +109,6 @@ then ynh_setup_source --dest_dir="$final_path" fi -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # NGINX CONFIGURATION #================================================= @@ -124,6 +117,13 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #=================================================