From adce43dbc4b0c01308c196df90c3565da611f642 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 03:59:37 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 1 + conf/cronjob | 2 +- conf/extra_php-fpm.conf | 4 --- conf/nginx.conf | 2 +- manifest.toml | 4 ++- scripts/_common.sh | 14 +------- scripts/backup | 28 +++++----------- scripts/change_url | 16 ++------- scripts/install | 73 +++++++++++++++++++---------------------- scripts/remove | 18 ++++------ scripts/restore | 39 +++++++++------------- scripts/upgrade | 48 ++++++++++++--------------- 12 files changed, 94 insertions(+), 155 deletions(-) delete mode 100644 conf/extra_php-fpm.conf diff --git a/.gitignore b/.gitignore index 783a4ae..8f144f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store diff --git a/conf/cronjob b/conf/cronjob index e327886..5bc301e 100644 --- a/conf/cronjob +++ b/conf/cronjob @@ -1,2 +1,2 @@ # Run periodically to update your website -*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f api/bin/console zusam:cron >> __INSTALL_DIR__/api/var/log/cron.log +*/10 * * * * __APP__ /usr/bin/php__PHP_VERSION__ -f api/bin/console zusam:cron >> __INSTALL_DIR__/api/var/log/cron.log diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf deleted file mode 100644 index c535997..0000000 --- a/conf/extra_php-fpm.conf +++ /dev/null @@ -1,4 +0,0 @@ -; Additional php.ini defines, specific to this pool of workers. - -php_admin_value[upload_max_filesize] = 2048M -php_admin_value[post_max_size] = 2048M diff --git a/conf/nginx.conf b/conf/nginx.conf index 99f0b23..2f2d2c7 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -17,7 +17,7 @@ try_files $uri /api/index.php$is_args$args; } location ~ ^/api/index\.php(/|$) { - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi.conf; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; diff --git a/manifest.toml b/manifest.toml index 8816101..d82927b 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,8 @@ admindoc = "https://github.com/zusam/zusam/tree/master/documentation" code = "https://github.com/zusam/zusam" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = false @@ -70,6 +71,7 @@ ram.runtime = "50M" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.data_dir] diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..3d7f008 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,5 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 2b0b7d1..0d10729 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,44 +1,34 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= - -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= -# ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -# ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" +# ynh_backup "/etc/fail2ban/jail.d/$app.conf" +# ynh_backup "/etc/fail2ban/filter.d/$app.conf" #================================================= # SPECIFIC BACKUP @@ -46,16 +36,16 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" # BACKUP LOGROTATE #================================================= -# ynh_backup --src_path="/etc/logrotate.d/$app" +# ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/cron.d/$app" +ynh_backup "/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 2688d02..b05c814 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,24 +1,16 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS @@ -26,12 +18,10 @@ ynh_change_url_nginx_config # ... #================================================= -#================================================= -# GENERIC FINALISATION #================================================= #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 1e18414..fcefd0e 100755 --- a/scripts/install +++ b/scripts/install @@ -1,43 +1,39 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers +ynh_app_setting_set --key=php_upload_max_filesize --value=2048M + #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= email=$(ynh_user_get_info --username=$first_user --key=mail) random_string="$(ynh_string_random --length=48)" -fpm_footprint="medium" -fpm_free_footprint=0 -fpm_usage="medium" +#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | fpm_footprint="medium" +#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_free_footprint=0 +#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | fpm_usage="medium" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_script_progression "Storing installation settings..." -ynh_app_setting_set --app=$app --key=email --value=$email -ynh_app_setting_set --app=$app --key=first_user_pass --value=$first_user_pass -ynh_app_setting_set --app=$app --key=first_group --value=$first_group -ynh_app_setting_set --app=$app --key=random_string --value=$random_string -ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint -ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint -ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage +ynh_app_setting_set --key=email --value=$email +ynh_app_setting_set --key=first_user_pass --value=$first_user_pass +ynh_app_setting_set --key=first_group --value=$first_group +ynh_app_setting_set --key=random_string --value=$random_string +#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value=$fpm_footprint +#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_free_footprint --value=$fpm_free_footprint +#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage #================================================= # APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source ynh_setup_source --dest_dir="$install_dir" @@ -45,58 +41,55 @@ ynh_setup_source --dest_dir="$install_dir" # Let's copy the webapp in the public directory cp -R $install_dir/app/dist/* $install_dir/public/ -ynh_script_progression --message="Pulling in external libraries with Composer..." +ynh_script_progression "Pulling in external libraries with Composer..." -ynh_install_composer -c "2.4.2" -w $install_dir/api/ - -chown -R $app:www-data "$install_dir" +ynh_composer_install +ynh_composer_exec install --no-dev -c "2.4.2" -w $install_dir/api/ +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated PHP-FPM config using conf/extra_php-fpm.conf -ynh_add_fpm_config +ynh_config_add_phpfpm # Create a dedicated NGINX config using the conf/nginx.conf template -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated Fail2Ban config # We'll see that in later versions -# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" +# ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" #================================================= # APP INITIAL CONFIGURATION #================================================= # ADD A CONFIGURATION #================================================= -# ynh_script_progression --message="Adding a configuration file..." --weight=1 +# ynh_script_progression "Adding $app's configuration..." # We'll take care of language later -# ynh_add_config --template="../conf/sample.env" --destination="$install_dir/api/.env" +# ynh_config_add --template="sample.env" --destination="$install_dir/api/.env" -chmod 600 "$install_dir/api/.env" -chown $app:www-data "$install_dir/api/.env" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/api/.env" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:www-data "$install_dir/api/.env" #================================================= # DATABASE #================================================= -ynh_script_progression --message="Initialiazing the database..." --weight=1 -/usr/bin/php$phpversion $install_dir/api/bin/console zusam:init $email "$first_group" $first_user_pass +ynh_script_progression "Initialiazing the database..." +/usr/bin/php$php_version $install_dir/api/bin/console zusam:init $email "$first_group" $first_user_pass -chown -R $app:www-data $install_dir - -#================================================= -# GENERIC FINALIZATION +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data $install_dir #================================================= -ynh_add_config --template="../conf/cronjob" --destination="/etc/cron.d/$app" -chown root: "/etc/cron.d/$app" -chmod 644 "/etc/cron.d/$app" +ynh_config_add --template="cronjob" --destination="/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 5356c15..368766a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -13,18 +7,18 @@ source /usr/share/yunohost/helpers # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_remove_nginx_config +ynh_config_remove_nginx -ynh_remove_fpm_config +ynh_config_remove_phpfpm -# ynh_remove_logrotate +# ynh_config_remove_logrotate -# ynh_remove_fail2ban_config +# ynh_config_remove_fail2ban -ynh_secure_remove --file="/etc/cron.d/$app" +ynh_safe_rm "/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index ecf114d..c2efdf9 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,56 +1,47 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 - -ynh_restore_file --origin_path="$install_dir" -chown -R $app:www-data "$install_dir" +ynh_script_progression "Restoring the app main directory..." +ynh_restore "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf" -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -# ynh_restore_file --origin_path="/etc/logrotate.d/$app" +# ynh_restore "/etc/logrotate.d/$app" -# ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" -# ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" -# ynh_systemd_action --action=restart --service_name=fail2ban +# ynh_restore "/etc/fail2ban/jail.d/$app.conf" +# ynh_restore "/etc/fail2ban/filter.d/$app.conf" +# ynh_systemctl --action=restart --service=fail2ban # Other various files... -ynh_restore_file --origin_path="/etc/cron.d/$app" +ynh_restore "/etc/cron.d/$app" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemctl --service=php$php_version-fpm --action=reload -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index c2f456c..04059c2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,24 +1,17 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers +ynh_app_setting_set_default --key=php_upload_max_filesize --value=2048M + ### This helper will compare the version of the currently installed app and the version of the upstream package. ### $upgrade_type can have 2 different values ### - UPGRADE_APP if the upstream app version has changed ### - UPGRADE_PACKAGE if only the YunoHost package has changed ### ynh_check_app_version_changed will stop the upgrade if the app is up to date. ### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. -upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# STANDARD UPGRADE STEPS #================================================= #================================================= @@ -27,15 +20,16 @@ upgrade_type=$(ynh_check_app_version_changed) # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed +if ynh_app_upstream_version_changed then - ynh_script_progression --message="Upgrading source files..." --weight=1 + ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --full_replace if [ -f $install_dir/api/config/packages/sensio_framework_extra.yaml ] then - ynh_secure_remove $install_dir/api/config/packages/sensio_framework_extra.yaml + ynh_safe_rm $install_dir/api/config/packages/sensio_framework_extra.yaml fi fi @@ -43,38 +37,38 @@ fi # ACTUAL UPDATE #================================================= -ynh_script_progression --message="Proceeding to migration..." +ynh_script_progression "Proceeding to migration..." pushd $install_dir - ynh_script_progression --message="Proceeding to migration..." - ynh_secure_remove $install_dir/api/var/cache/ - php$phpversion api/bin/console doctrine:migration:migrate --no-interaction --allow-no-migration - php$phpversion api/bin/console zusam:migration + ynh_script_progression "Proceeding to migration..." + ynh_safe_rm $install_dir/api/var/cache/ + php$php_version api/bin/console doctrine:migration:migrate --no-interaction --allow-no-migration + php$php_version api/bin/console zusam:migration - ynh_script_progression --message="Pulling in external libraries with Composer..." - ynh_install_composer -c "2.4.2" -w $install_dir/api/ + ynh_script_progression "Pulling in external libraries with Composer..." + ynh_composer_install +ynh_composer_exec install --no-dev -c "2.4.2" -w $install_dir/api/ cp -r app/dist/* public/ popd -chown -R $app:www-data "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # This should be a literal copypasta of what happened in the install's "System configuration" section -ynh_add_fpm_config +ynh_config_add_phpfpm -ynh_add_nginx_config +ynh_config_add_nginx -# ynh_use_logrotate --non-append +# ynh_config_add_logrotate -# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" +# ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"