From 1869dd9cee295c14927fae4d9f26c9ed27b148ec Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 01:06:46 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 2 + manifest.toml | 3 +- scripts/_common.sh | 14 +----- scripts/backup | 25 ++++------- scripts/change_url | 24 +++------- scripts/install | 45 ++++++++----------- scripts/remove | 23 ++++------ scripts/restore | 38 +++++++--------- scripts/upgrade | 106 ++++++++++++++++++++------------------------- 9 files changed, 110 insertions(+), 170 deletions(-) diff --git a/.gitignore b/.gitignore index 9bea433..ace6f34 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .DS_Store +*~ +*.sw[op] diff --git a/manifest.toml b/manifest.toml index 76682a0..c481f50 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,8 @@ code = "https://github.com/minio/minio" cpe = "cpe:2.3:a:minio:minio" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = ["amd64", "arm64"] multi_instance = false 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 5e8ec3c..917db5f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,38 +1,29 @@ #!/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 DATA DIR #================================================= -ynh_print_info --message="WARNING : by default, the buckets are not saved (use is big option)..." -ynh_backup --src_path="$data_dir" --is_big +ynh_print_info "WARNING : by default, the buckets are not saved (use is big option)..." +ynh_backup "$data_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" #================================================= # SPECIFIC BACKUP @@ -40,16 +31,16 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP LOGROTATE #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app.service" #================================================= # 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 c5d2077..03c0d6f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,41 +1,31 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_systemctl --service=$app --action="stop" --log_path="systemd" #================================================= # 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 -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Console:" +ynh_systemctl --service=$app --action="start" --log_path="systemd" --wait_until="Console:" #================================================= # 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 1739c6e..2437510 100755 --- a/scripts/install +++ b/scripts/install @@ -1,76 +1,69 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=10 +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" --source_id="minio" +ynh_setup_source --dest_dir="$install_dir" --source_id="minio" + ynh_setup_source --dest_dir="$install_dir" --source_id="mc" -chmod 750 "$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 750 "$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" chmod +x "$install_dir/minio" chmod +x "$install_dir/mc" #================================================= # 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 systemd config -ynh_add_systemd_config +ynh_config_add_systemd # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate yunohost service add $app --description="A High Performance, Kubernetes Native Object Storage" --log="/var/log/$app/$app.log" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=2 +ynh_script_progression "Adding $app's configuration..." -ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" +ynh_config_add --template=".env" --destination="$install_dir/.env" -chmod 400 "$install_dir/.env" -chown $app:$app "$install_dir/.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 400 "$install_dir/.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:$app "$install_dir/.env" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=3 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Console:" +ynh_systemctl --service=$app --action="start" --log_path="systemd" --wait_until="Console:" #================================================= # SETUP MINIO CLIENT #================================================= -ynh_script_progression --message="Configuring MinIO client..." --weight=1 +ynh_script_progression "Configuring MinIO client..." pushd $install_dir - ynh_exec_warn_less sudo -u $app ./mc --no-color alias set minio "http://127.0.0.1:$port" "$admin" "$password" --api S3v4 + ynh_hide_warnings ynh_exec_as_app ./mc --no-color alias set minio "http://127.0.0.1:$port" "$admin" "$password" --api S3v4 popd #================================================= # 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 14783f7..a4eabad 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,39 +1,34 @@ #!/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..." # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null +if ynh_hide_warnings yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service integration..." --weight=3 + ynh_script_progression "Removing $app service integration..." yunohost service remove $app fi # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # 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 395ae9a..f9f9d3a 100755 --- 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,22 +7,22 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=2 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" +ynh_restore "$install_dir" -chmod 750 "$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 750 "$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" chmod +x "$install_dir/minio" chmod +x "$install_dir/mc" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=3 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" chown -R $app:www-data "$data_dir" @@ -37,30 +31,28 @@ chown -R $app:www-data "$data_dir" #================================================= # 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/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" yunohost service add $app --description="A High Performance, Kubernetes Native Object Storage" --log="/var/log/$app/$app.log" -#================================================= -# 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=$app --action="start" --log_path="systemd" --line_match="Console:" +ynh_systemctl --service=$app --action="start" --log_path="systemd" --wait_until="Console:" -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 352e65a..d5f1617 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,28 +1,16 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression "Ensuring downward compatibility..." -if ynh_compare_current_package_version --comparison le --version 2023.02.22~ynh1 +if ynh_app_upgrading_from_version_before_or_equal_to 2023.02.22~ynh1 then - ynh_script_progression --message="Mirroring old Filesystem to secure MinIO start" + ynh_script_progression "Mirroring old Filesystem to secure MinIO start" tmp="/tmp/minio" mkdir "$tmp" chown -R $app:www-data "$tmp" @@ -30,32 +18,32 @@ then for d in * ; do if [ "$d" == "*" ] then - ynh_script_progression --message="No buckets to migrate" + ynh_script_progression "No buckets to migrate" else - ynh_script_progression --message="Moving $d..." - ynh_exec_warn_less sudo -u $app $install_dir/mc mirror --preserve "minio/$d" "$tmp/$d" + ynh_script_progression "Moving $d..." + ynh_hide_warnings ynh_exec_as_app $install_dir/mc mirror --preserve "minio/$d" "$tmp/$d" fi done if ynh_compare_current_package_version --comparison eq --version 2022.09.01~ynh1 then - ynh_die --message="Sorry, your MinIO instance requires a complex manual migration. Please contact Limezy on the YunoHost forum" + ynh_die "Sorry, your MinIO instance requires a complex manual migration. Please contact Limezy on the YunoHost forum" fi if ynh_compare_current_package_version --comparison eq --version 2022.11.11~ynh1 then - ynh_die --message="Sorry, your MinIO instance requires a complex manual migration. Please contact Limezy on the YunoHost forum" + ynh_die "Sorry, your MinIO instance requires a complex manual migration. Please contact Limezy on the YunoHost forum" fi if ynh_compare_current_package_version --comparison eq --version 2023.01.11~ynh1 then - ynh_die --message="Sorry, your MinIO instance requires a complex manual migration. Please contact Limezy on the YunoHost forum" + ynh_die "Sorry, your MinIO instance requires a complex manual migration. Please contact Limezy on the YunoHost forum" fi popd - ynh_secure_remove --file="$data_dir" - ynh_exec_warn_less mkdir "$data_dir" + ynh_safe_rm "$data_dir" + ynh_hide_warnings mkdir "$data_dir" chmod 750 "$data_dir" chmod -R o-rwx "$data_dir" chown -R $app:www-data "$data_dir" else - ynh_script_progression --message="No migration to be done" + ynh_script_progression "No migration to be done" fi # Retrieve the password from the .env file @@ -63,113 +51,113 @@ if [ -z "${password:-}" ]; then password=$(ynh_read_var_in_file --file="$install_dir/.env" --key="MINIO_ROOT_PASSWORD") fi -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=2 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_systemctl --service=$app --action="stop" --log_path="systemd" #================================================= # 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=5 + ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" --source_id="minio" + ynh_setup_source --dest_dir="$install_dir" --source_id="minio" + ynh_setup_source --dest_dir="$install_dir" --source_id="mc" fi -chmod 750 "$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 750 "$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" chmod +x "$install_dir/minio" chmod +x "$install_dir/mc" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression "Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate yunohost service add $app --description="A High Performance, Kubernetes Native Object Storage" --log="/var/log/$app/$app.log" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." +ynh_script_progression "Updating configuration..." -ynh_add_config --template=".env" --destination="$install_dir/.env" +ynh_config_add --template=".env" --destination="$install_dir/.env" -chmod 400 "$install_dir/.env" -chown $app:$app "$install_dir/.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 400 "$install_dir/.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:$app "$install_dir/.env" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=3 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Console:" +ynh_systemctl --service=$app --action="start" --log_path="systemd" --wait_until="Console:" #================================================= # SETUP MINIO CLIENT #================================================= -ynh_script_progression --message="Configuring MinIO client..." --weight=1 +ynh_script_progression "Configuring MinIO client..." pushd $install_dir - ynh_exec_warn_less sudo -u $app ./mc --no-color alias set minio "https://$domain" "$admin" "$password" --api S3v4 + ynh_hide_warnings ynh_exec_as_app ./mc --no-color alias set minio "https://$domain" "$admin" "$password" --api S3v4 popd #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression "Ensuring downward compatibility..." -if ynh_compare_current_package_version --comparison le --version 2023.02.22~ynh1 +if ynh_app_upgrading_from_version_before_or_equal_to 2023.02.22~ynh1 then - ynh_script_progression --message="Migration from Filesystem to Single-Node Single-Drive mode" + ynh_script_progression "Migration from Filesystem to Single-Node Single-Drive mode" pushd "$tmp/" for d in * ; do if [ "$d" == "*" ] then - ynh_script_progression --message="No buckets to migrate" + ynh_script_progression "No buckets to migrate" else - ynh_script_progression --message="Migrating bucket $d" + ynh_script_progression "Migrating bucket $d" pushd $install_dir - ynh_exec_warn_less sudo -u $app ./mc mb minio/"$d" - ynh_exec_warn_less sudo -u $app ./mc mirror --preserve "$tmp/$d" "minio/$d" + ynh_hide_warnings ynh_exec_as_app ./mc mb minio/"$d" + ynh_hide_warnings ynh_exec_as_app ./mc mirror --preserve "$tmp/$d" "minio/$d" # This is a hack, but it will make outline_ynh users' lifes much easier ! if [ "$d" == "outlinestorage" ] then - ynh_exec_warn_less sudo -u $app ./mc anonymous set public minio/outlinestorage + ynh_hide_warnings ynh_exec_as_app ./mc anonymous set public minio/outlinestorage else - ynh_script_progression --message="Bucket is migrated and objects are now mirrored. However, make sure to set properly access policy of bucket $d. That part of the migration can't be automated, sorry ! You can log into the minio console to perform your changes." + ynh_script_progression "Bucket is migrated and objects are now mirrored. However, make sure to set properly access policy of bucket $d. That part of the migration can't be automated, sorry ! You can log into the minio console to perform your changes." fi popd - ynh_secure_remove --file="DATA_$d" + ynh_safe_rm "DATA_$d" fi done popd - ynh_secure_remove --file="$tmp" + ynh_safe_rm "$tmp" else - ynh_script_progression --message="No migration required" + ynh_script_progression "No migration required" fi #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"