From 5ec310465760a8ce47d9e00c374a9a0527f1501a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 15 Jul 2020 18:12:26 +0200 Subject: [PATCH] php --- check_process | 9 ++++----- scripts/_common.sh | 4 +++- scripts/backup | 3 ++- scripts/install | 16 +++++++--------- scripts/restore | 16 ++-------------- scripts/upgrade | 15 ++------------- 6 files changed, 20 insertions(+), 43 deletions(-) diff --git a/check_process b/check_process index 6da670e..586f849 100644 --- a/check_process +++ b/check_process @@ -6,20 +6,19 @@ ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) - root_access=0 + root_access=1 is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 setup_sub_dir=1 - setup_root=0 + setup_root=1 setup_nourl=1 - setup_private=0 + setup_private=1 setup_public=1 upgrade=1 backup_restore=1 multi_instance=1 - # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. - # incorrect_path=1 + #incorrect_path=1 port_already_use=0 (66) change_url=1 ;;;; Levels diff --git a/scripts/_common.sh b/scripts/_common.sh index 9ea8430..c0aacd4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,9 @@ #================================================= # dependencies used by the app -pkg_dependencies="php7.0-mysql php7.0-sqlite3 php7.0-pgsql" +extra_php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-sqlite3 php${YNH_PHP_VERSION}-pgsql" + +YNH_PHP_VERSION="7.3" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 69abc4f..aee48a7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -29,6 +29,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) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -53,7 +54,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PHP-FPM CONFIGURATION #================================================= -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" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 4a3b933..e7e7fdd 100644 --- a/scripts/install +++ b/scripts/install @@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -92,7 +88,7 @@ ynh_system_user_create --username=$app # Set permissions to app files chown -R www-data:www-data $final_path -chmod 755 -R $final_path/adminer.php +chmod -R 755 $final_path/adminer.php #================================================= # NGINX CONFIGURATION @@ -108,18 +104,20 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring PHP-fpm..." --weight=1 # Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_add_fpm_config --package="$extra_php_dependencies" +phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion) #================================================= # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring SSOwat..." --weight=1 -# Make app public if necessary +# Make app public if necessary or protect it if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission "main" --add "visitors" fi #================================================= diff --git a/scripts/restore b/scripts/restore index bb80ac7..cf579c1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,10 +14,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -57,14 +53,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$final_path" -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=10 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -85,7 +73,7 @@ chmod 755 -R $final_path/adminer.php # 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" #================================================= # GENERIC FINALIZATION @@ -94,7 +82,7 @@ ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-fpm..." --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 fdf4edb..ee6fa0f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) root_access=$(ynh_app_setting_get --app=$app --key=root_access) +phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -101,19 +102,7 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 # Create a dedicated php-fpm config -ynh_add_fpm_config - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi +ynh_add_fpm_config --package="$extra_php_dependencies" #================================================= # RELOAD NGINX