From 0bd1e74ed1ff222c9d9d543de7239fd16b686ef9 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 30 Aug 2024 22:39:36 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- conf/extra_php-fpm.conf | 4 --- conf/nginx.conf | 2 +- manifest.toml | 4 ++- scripts/_common.sh | 16 ++------- scripts/backup | 25 +++++--------- scripts/change_url | 20 ++++------- scripts/install | 60 +++++++++++++++------------------ scripts/remove | 20 ++++------- scripts/restore | 39 +++++++++------------- scripts/upgrade | 74 +++++++++++++++++------------------------ 10 files changed, 98 insertions(+), 166 deletions(-) delete mode 100644 conf/extra_php-fpm.conf diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf deleted file mode 100644 index 700c37c..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] = 50M -php_admin_value[post_max_size] = 50M diff --git a/conf/nginx.conf b/conf/nginx.conf index e71b042..dc7a5e6 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,7 +16,7 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.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_index index.php; include fastcgi_params; diff --git a/manifest.toml b/manifest.toml index 1f725cc..32cd91c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -18,7 +18,8 @@ code = "https://github.com/ampache/ampache" fund = "https://ampache.org/donate.html" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true @@ -57,6 +58,7 @@ ram.runtime = "50M" allow_email = true [resources.install_dir] + group = "www-data:r-x" [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 1db13c2..4246532 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,20 +1,8 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= # Composer version -YNH_COMPOSER_VERSION="2.5.8" - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= +composer_version="2.5.8" diff --git a/scripts/backup b/scripts/backup index 6039e18..822a6d6 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,37 +1,28 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts 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" #================================================= # SPECIFIC BACKUP @@ -39,17 +30,17 @@ 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 THE MYSQL DATABASE #================================================= -ynh_print_info --message="Backing up the MySQL database..." +ynh_print_info "Backing up the MySQL database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_mysql_dump_db > db.sql #================================================= # 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 9c8ce2b..d72736b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,37 +1,29 @@ #!/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=2 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS #================================================= # CHANGE AMPACHE CONFIGURATION #================================================= -ynh_script_progression --message="Updating Ampache configuration..." +ynh_script_progression "Updating Ampache configuration..." conf_file="$install_dir/config/ampache.cfg.php" -ynh_replace_string --match_string="\(web_path.*=.*\)\"$old_path\"" --replace_string="\1\"$new_path\"" --target_file="$conf_file" -ynh_replace_string --match_string="\(http_host.*=.*\)\"$old_domain\"" --replace_string="\1\"$new_domain\"" --target_file="$conf_file" +ynh_replace --match="\(web_path.*=.*\)\"$old_path\"" --replace="\1\"$new_path\"" --file="$conf_file" +ynh_replace --match="\(http_host.*=.*\)\"$old_domain\"" --replace="\1\"$new_domain\"" --file="$conf_file" #================================================= # 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 9bc2150..9b1dd65 100644 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -19,65 +13,65 @@ secret_key=$(ynh_string_random --length=24) # STORE SETTINGS FROM MANIFEST #================================================= -ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key +ynh_app_setting_set --key=secret_key --value=$secret_key #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=2 +ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir" -chmod -R o-rwx "$install_dir" -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 | chmod -R o-rwx "$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" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app ..." --weight=1 +ynh_script_progression "Adding system configurations related to $app ..." -ynh_add_fpm_config +ynh_config_add_phpfpm -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # SPECIFIC SETUP #================================================= # LOAD DEFAULT DATABASE #================================================= -ynh_script_progression --message="Loading default database..." --weight=2 +ynh_script_progression "Loading default database..." -ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name < "$install_dir/resources/sql/ampache.sql" +ynh_mysql_db_shell < "$install_dir/resources/sql/ampache.sql" #================================================= # INSTALL MULTIMEDIA DIRECTORIES #================================================= -ynh_script_progression --message="Installing multimedia directories..." --weight=5 +ynh_script_progression "Installing multimedia directories..." ynh_multimedia_build_main_dir #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=2 +ynh_script_progression "Adding $app's configuration..." -ynh_add_config --template="ampache.cfg.php" --destination="$install_dir/config/ampache.cfg.php" +ynh_config_add --template="ampache.cfg.php" --destination="$install_dir/config/ampache.cfg.php" -chmod 650 "$install_dir/config/ampache.cfg.php" -chown $app: "$install_dir/config/ampache.cfg.php" +#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 650 "$install_dir/config/ampache.cfg.php" +#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: "$install_dir/config/ampache.cfg.php" #================================================= # INSTALL WITH COMPOSER #================================================= -ynh_script_progression --message="Installing with Composer..." --weight=45 +ynh_script_progression "Installing with Composer..." # Install composer -ynh_install_composer --workdir=$install_dir +ynh_composer_install +ynh_composer_exec install --no-dev # FIXMEhelpers2.1 (replace with composer_workdir=... prior to calling this helper, default is $intall_dir) --workdir=$install_dir #================================================= # SETUP APPLICATION WITH CURL #================================================= -ynh_script_progression --message="Setuping application with CURL..." --weight=5 +ynh_script_progression "Setuping application with CURL..." # Installation with curl ynh_local_curl /update.php?action=update @@ -85,28 +79,26 @@ ynh_local_curl /update.php?action=update #================================================= # LOAD ADMIN DATABASE #================================================= -ynh_script_progression --message="Loading admin database..." --weight=2 +ynh_script_progression "Loading admin database..." -ynh_add_config --template="admin.sql" --destination="/tmp/admin.sql" +ynh_config_add --template="admin.sql" --destination="/tmp/admin.sql" -ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name < /tmp/admin.sql +ynh_mysql_db_shell < /tmp/admin.sql -ynh_secure_remove --file=/tmp/admin.sql +ynh_safe_rm /tmp/admin.sql -#================================================= -# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression "Configuring log rotation..." mkdir -p "/var/log/$app" -chown $app: "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app: "/var/log/$app" # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate #================================================= # 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 1bc948b..a1b768a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,30 +1,24 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -# REMOVE SYSTEMD SERVICE +# REMOVE SYSTEMD SERVICE + #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." -ynh_remove_logrotate +ynh_config_remove_logrotate -ynh_remove_nginx_config - -ynh_remove_fpm_config +ynh_config_remove_nginx +ynh_config_remove_phpfpm #================================================= # 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 b9e34be..22dfa7b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,47 +7,44 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=3 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +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 | chmod -R o-rwx "$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 THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=2 +ynh_script_progression "Restoring the MySQL database..." -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_mysql_db_shell < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=5 +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" mkdir -p "/var/log/$app" -chown $app: "/var/log/$app" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app: "/var/log/$app" +ynh_restore "/etc/logrotate.d/$app" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 +ynh_script_progression "Reloading NGINX web server and PHP-FPM..." -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=php$php_version-fpm --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 f95ee28..0f82b23 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,87 +1,74 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." # If secret_key doesn't exist, create it +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=secret_key --value="$(grep "^secret_key" "$install_dir/config/ampache.cfg.php" | cut -d'"' -f2)" if [ -z "${secret_key:-}" ]; then secret_key="$(grep "^secret_key" "$install_dir/config/ampache.cfg.php" | cut -d'"' -f2)" - ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key + ynh_app_setting_set --key=secret_key --value=$secret_key fi #================================================= # 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=3 + ynh_script_progression "Upgrading source files..." ynh_setup_source --dest_dir="$install_dir" #--keep="config/ampache.cfg.php" fi -chmod -R o-rwx "$install_dir" -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 | chmod -R o-rwx "$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..." -ynh_add_fpm_config +ynh_config_add_phpfpm -ynh_add_nginx_config +ynh_config_add_nginx -#================================================= -# SPECIFIC UPGRADE #================================================= # UPDATE AMPACHE WITH COMPOSER #================================================= -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 $app with Composer..." --weight=30 + ynh_script_progression "Upgrading $app with Composer..." # Install composer - ynh_install_composer --workdir=$install_dir - ynh_composer_exec --workdir="$install_dir" --commands="config discard-changes true" + ynh_composer_install +ynh_composer_exec install --no-dev # FIXMEhelpers2.1 (replace with composer_workdir=... prior to calling this helper, default is $intall_dir) --workdir=$install_dir + ynh_composer_exec config discard-changes true fi #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression "Updating configuration..." -(cd $install_dir && ynh_exec_as "$app" php$phpversion bin/cli admin:updateDatabase -e) +(cd $install_dir && ynh_exec_as_app php$php_version bin/cli admin:updateDatabase -e) -ynh_add_config --template="ampache.cfg.php" --destination="$install_dir/config/ampache.cfg.php" +ynh_config_add --template="ampache.cfg.php" --destination="$install_dir/config/ampache.cfg.php" -chmod 650 "$install_dir/config/ampache.cfg.php" -chown $app: "$install_dir/config/ampache.cfg.php" +#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 650 "$install_dir/config/ampache.cfg.php" +#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: "$install_dir/config/ampache.cfg.php" #================================================= # UPDATE MULTIMEDIA DIRECTORIES #================================================= -ynh_script_progression --message="Updating multimedia directories..." +ynh_script_progression "Updating multimedia directories..." ynh_multimedia_build_main_dir @@ -89,27 +76,26 @@ ynh_multimedia_build_main_dir # UPGRADE AMPACHE WITH CURL #================================================= -#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_local_curl /update.php?action=update # sleep 1 -# (cd $install_dir && ynh_exec_as "$app" php$phpversion bin/cli admin:updateDatabase -e) +# (cd $install_dir && ynh_exec_as_app php$php_version bin/cli admin:updateDatabase -e) #fi -#================================================= -# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +ynh_script_progression "Upgrading logrotate configuration..." mkdir -p "/var/log/$app" -chown $app: "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app: "/var/log/$app" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"