From f1bd85f6006a2b6c4c3d9d37b7bc065d852fcb8f Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 30 Aug 2024 22:51:04 +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 | 17 ++++++------- scripts/change_url | 12 +++------- scripts/install | 53 ++++++++++++++++++++--------------------- scripts/remove | 12 +++++----- scripts/restore | 33 ++++++++++++------------- scripts/upgrade | 51 +++++++++++++++++---------------------- 10 files changed, 85 insertions(+), 119 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 a8d186e..7d15cac 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -11,7 +11,7 @@ location / { 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 b713aef..4181082 100644 --- a/manifest.toml +++ b/manifest.toml @@ -21,7 +21,8 @@ cpe = "cpe:2.3:a:elabftw:elabftw" fund = "https://github.com/sponsors/NicolasCARPi" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = true @@ -50,6 +51,7 @@ ram.runtime = "200M" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 36debfc..0d26f82 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,20 +2,8 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= nodejs_version=16 -YNH_COMPOSER_VERSION="2.2.7" - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= +composer_version="2.2.7" diff --git a/scripts/backup b/scripts/backup index 1933aeb..ccc6a1c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -7,34 +7,31 @@ 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" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" #================================================= # 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 0e8ed9e..92b8317 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,24 +1,18 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." # this will most likely adjust NGINX config correctly -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # 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 89e2587..ddc87ff 100644 --- a/scripts/install +++ b/scripts/install @@ -12,68 +12,67 @@ source /usr/share/yunohost/helpers #================================================= secret_key=$(ynh_string_random --length=137) -ynh_app_setting_set --app=$app --key="secret_key" --value="$secret_key" +ynh_app_setting_set --key="secret_key" --value="$secret_key" #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing NodeJS..." --weight=1 +ynh_script_progression "Installing NodeJS..." -ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_nodejs_install #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=7 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/sources" mkdir -p "$install_dir/sources/"{cache,uploads} -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" #================================================= # INSTALL AND INITIALIZE COMPOSER #================================================= -ynh_script_progression --message="Installing $app with Composer..." --weight=30 +ynh_script_progression "Installing $app with Composer..." pushd "$install_dir/sources" - ynh_install_composer --workdir="$install_dir/sources" --install_args="--no-dev" + 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/sources" --no-dev - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn install --pure-lockfile --prod - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn run buildall + ynh_hide_warnings ynh_exec_as_app node_load_PATH" yarn install --pure-lockfile --prod + ynh_hide_warnings ynh_exec_as_app node_load_PATH" yarn run buildall - ynh_composer_exec --workdir="$install_dir/sources" --commands="install --prefer-dist --no-cache --no-progress --no-dev -a" + ynh_composer_exec # FIXMEhelpers2.1 (replace with composer_workdir=... prior to calling this helper, default is $intall_dir) --workdir="$install_dir/sources" install --prefer-dist --no-cache --no-progress --no-dev -a - ynh_secure_remove node_modules - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn cache clean + ynh_safe_rm node_modules + ynh_hide_warnings ynh_exec_as_app node_load_PATH" yarn cache clean - ynh_add_config --template="config.php" --destination="$install_dir/sources/config.php" - ynh_exec_as "$app" "php$phpversion" "bin/install" start -q + ynh_config_add --template="config.php" --destination="$install_dir/sources/config.php" + ynh_exec_as_app "php$php_version" "bin/install" start -q popd -# ynh_script_progression --message="Configuring LDAP and emails..." --weight=2 -# ynh_add_config --template="sql.template" --destination="$install_dir/ldap_sql" -# ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/ldap_sql" -# ynh_secure_remove --file="$install_dir/ldap_sql" - -chmod -R o-rwx "$install_dir" -chown -R "$app:www-data" "$install_dir" +# ynh_script_progression "Configuring LDAP and emails..." +# ynh_config_add --template="sql.template" --destination="$install_dir/ldap_sql" +# ynh_mysql_db_shell < "$install_dir/ldap_sql" +# ynh_safe_rm "$install_dir/ldap_sql" +#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..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated PHP-FPM config -ynh_add_fpm_config +ynh_config_add_phpfpm #================================================= # 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 3cd684c..8501310 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,24 +10,24 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove the dedicated PHP-FPM config -ynh_remove_fpm_config +ynh_config_remove_phpfpm #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing NodeJS..." --weight=1 +ynh_script_progression "Removing NodeJS..." # Remove NodeJS -ynh_remove_nodejs +ynh_nodejs_remove #================================================= # 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 603c142..585c807 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,51 +10,48 @@ source /usr/share/yunohost/helpers #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling NodeJS..." --weight=1 +ynh_script_progression "Reinstalling NodeJS..." -ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_nodejs_install #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$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 | chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=1 +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 #================================================= -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/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" # Restore the file first, so it can have a backup if different -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf" # Recreate a dedicated PHP-FPM config -# ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion +# ynh_config_add_phpfpm -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -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_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 c58435c..be670f9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,18 +1,12 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 +ynh_script_progression "Ensuring downward compatibility..." # Move sources to subdir if [ ! -d "$install_dir/sources" ]; then @@ -23,58 +17,57 @@ fi #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading NodeJS..." --weight=1 +ynh_script_progression "Upgrading NodeJS..." -ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_nodejs_install #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=7 +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1 --keep="config.php" +ynh_setup_source --dest_dir="$install_dir/sources" --full_replace --keep="config.php" mkdir -p "$install_dir/sources/"{cache,uploads} -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" #================================================= # INSTALL AND INITIALIZE COMPOSER #================================================= -ynh_script_progression --message="Building $app with Composer..." --weight=30 +ynh_script_progression "Building $app with Composer..." pushd "$install_dir/sources" - ynh_install_composer --workdir="$install_dir/sources" --install_args="--no-dev" + 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/sources" --no-dev - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn install --pure-lockfile --prod - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn run buildall + ynh_hide_warnings ynh_exec_as_app node_load_PATH" yarn install --pure-lockfile --prod + ynh_hide_warnings ynh_exec_as_app node_load_PATH" yarn run buildall - ynh_composer_exec --workdir="$install_dir/sources" --commands="install --prefer-dist --no-cache --no-progress --no-dev -a" + ynh_composer_exec # FIXMEhelpers2.1 (replace with composer_workdir=... prior to calling this helper, default is $intall_dir) --workdir="$install_dir/sources" install --prefer-dist --no-cache --no-progress --no-dev -a - ynh_secure_remove node_modules - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn cache clean + ynh_safe_rm node_modules + ynh_hide_warnings ynh_exec_as_app node_load_PATH" yarn cache clean - ynh_exec_as "$app" "php$phpversion" "bin/console" db:update + ynh_exec_as_app "php$php_version" "bin/console" db:update popd -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..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated PHP-FPM config -ynh_add_fpm_config +ynh_config_add_phpfpm #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"