From 056cd8c3df031b19786eeae292e973a8375100d7 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 01:08:56 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 1 + check_process | 57 ----------------------------------------- conf/extra_php-fpm.conf | 4 --- conf/nginx.conf | 2 +- manifest.toml | 4 ++- scripts/_common.sh | 22 ++++------------ scripts/backup | 25 ++++++------------ scripts/change_url | 14 +++------- scripts/install | 35 ++++++++++--------------- scripts/remove | 16 ++++-------- scripts/restore | 43 ++++++++++++------------------- scripts/upgrade | 27 ++++++++----------- 12 files changed, 67 insertions(+), 183 deletions(-) delete mode 100644 check_process 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/check_process b/check_process deleted file mode 100644 index ba9fb59..0000000 --- a/check_process +++ /dev/null @@ -1,57 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - is_public=1 - language="fr" - admin="john" - password="1Strong-Password" - with_sftp=1 - with_mysql=1 - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - # 1.4.0~ynh1 - upgrade=1 from_commit=fb4715fb8e60e6daddf6652bf563ad7c231deb74 - # 1.4.0~ynh2 - upgrade=1 from_commit=31629d4fcdfc0f6e400f90abce8f88acb59270a7 - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;; Test without sftp - ; Manifest - domain="domain.tld" - is_public=1 - language="fr" - admin="john" - password="1Strong-Password" - with_sftp=0 - with_mysql=1 - ; Checks - setup_sub_dir=0 - upgrade=1 - backup_restore=1 -;; Test without mysql - ; Manifest - domain="domain.tld" - is_public=1 - language="fr" - admin="john" - password="1Strong-Password" - with_sftp=1 - with_mysql=0 - ; Checks - setup_sub_dir=0 - upgrade=1 - backup_restore=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=fb4715fb8e60e6daddf6652bf563ad7c231deb74 - name=1.4.0~ynh1. 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 c6d5f4b..168070a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -31,7 +31,7 @@ location __PATH__/ { # Execute and serve PHP files 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 07f151d..6f07c8f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -18,7 +18,8 @@ code = "https://tildegit.org/Sbgodin/htmgem" website = "https://tildegit.org/Sbgodin/htmgem" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true @@ -67,6 +68,7 @@ ram.runtime = "50M" [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 5fd9929..4d3c0b2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,27 +1,15 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= _ynh_add_gemserv_config() { - ynh_add_config --template="server.toml" --destination="/etc/gemserv/config.d/$domain.toml" - ynh_systemd_action --service_name=gemserv --action=reload + ynh_config_add --template="server.toml" --destination="/etc/gemserv/config.d/$domain.toml" + ynh_systemctl --service=gemserv --action=reload } _ynh_remove_gemserv_config() { - ynh_secure_remove --file="/etc/gemserv/config.d/$domain.toml" - ynh_systemd_action --service_name=gemserv --action=reload + ynh_safe_rm "/etc/gemserv/config.d/$domain.toml" + ynh_systemctl --service=gemserv --action=reload } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 65412d5..f80aa99 100755 --- 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 VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/gemserv/config.d/$domain.toml" +ynh_backup "/etc/gemserv/config.d/$domain.toml" #================================================= # 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 690b1ba..39d37fc 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,25 +1,17 @@ #!/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..." +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 9f552dd..dbdee85 100755 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source ynh_apps source /usr/share/yunohost/helpers @@ -13,14 +7,14 @@ source /usr/share/yunohost/helpers #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Installing Gemserv..." +ynh_script_progression "Installing Gemserv..." # ynh_install_apps --apps="gemserv" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +ynh_script_progression "Configuring system user..." if [ "$with_sftp" -eq 1 ]; then usermod -a -G "sftp.app" "$app" @@ -30,22 +24,21 @@ if [ -n "$password" ]; then # Add the password to this user chpasswd <<< "${app}:${password}" # By default, passwords are not saved - ynh_app_setting_set --app="$app" --key=password --value="$password" + ynh_app_setting_set --key=password --value="$password" fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +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/www/htmgem" -chmod 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 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" # Home directory of the user needs to be owned by $app to allow SFTP connections -chown "$app:$app" "$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 "$app:$app" "$install_dir" setfacl -m g:"$app":r-x "$install_dir" setfacl -m g:"www-data":r-x "$install_dir" setfacl -m g:"gemserv":r-x "$install_dir" @@ -55,12 +48,12 @@ setfacl -m g:"gemserv":r-x "$install_dir" #================================================= # BUILD DEFAULT CAPSULE #================================================= -ynh_script_progression --message="Building default capsule..." +ynh_script_progression "Building default capsule..." if [ "$with_sftp" -eq 1 ]; then - ynh_add_config --template="index.gmi" --destination="$install_dir/www/index.gmi" + ynh_config_add --template="index.gmi" --destination="$install_dir/www/index.gmi" else - ynh_add_config --template="index_no_sftp.gmi" --destination="$install_dir/www/index.gmi" + ynh_config_add --template="index_no_sftp.gmi" --destination="$install_dir/www/index.gmi" fi chmod 644 "$install_dir/www/index.gmi" @@ -69,13 +62,13 @@ chown "$app:$app" "$install_dir/www/index.gmi" #================================================= # 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 -ynh_add_fpm_config +ynh_config_add_phpfpm # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated Gemserv config _ynh_add_gemserv_config @@ -84,4 +77,4 @@ _ynh_add_gemserv_config # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 17839ab..78d011b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source ynh_apps source /usr/share/yunohost/helpers @@ -13,20 +7,20 @@ 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 _ynh_remove_gemserv_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." +ynh_script_progression "Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_apps @@ -35,4 +29,4 @@ ynh_remove_apps # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index c231ed3..2cb6266 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 ../settings/scripts/ynh_apps @@ -14,7 +8,7 @@ source /usr/share/yunohost/helpers #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring the system user..." +ynh_script_progression "Configuring the system user..." if [ "$with_sftp" -eq 1 ]; then usermod -a -G "sftp.app" "$app" @@ -28,15 +22,14 @@ fi #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +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" # Home directory of the user needs to be owned by $app to allow SFTP connections -chown "$app:$app" "$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 "$app:$app" "$install_dir" setfacl -m g:"$app":r-x "$install_dir" setfacl -m g:"www-data":r-x "$install_dir" setfacl -m g:"gemserv":r-x "$install_dir" @@ -44,34 +37,32 @@ setfacl -m g:"gemserv":r-x "$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/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/gemserv/config.d/$domain.toml" -ynh_systemd_action --service_name=gemserv --action=reload +ynh_restore "/etc/gemserv/config.d/$domain.toml" +ynh_systemctl --service=gemserv --action=reload -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +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" +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 7c2747d..7ca5cc3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source ynh_apps source /usr/share/yunohost/helpers @@ -13,7 +7,7 @@ source /usr/share/yunohost/helpers #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +ynh_script_progression "Making sure dedicated system user exists..." if [ "$with_sftp" -eq 1 ]; then usermod -a -G "sftp.app" "$app" @@ -31,16 +25,15 @@ usermod -g "$app" "$app" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/www/htmgem" --full_replace=1 - -chmod -R o-rwx "$install_dir" -chown -R "$app:www-data" "$install_dir" +ynh_setup_source --dest_dir="$install_dir/www/htmgem" --full_replace +#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" # Home directory of the user needs to be owned by $app to allow SFTP connections -chown "$app:$app" "$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 "$app:$app" "$install_dir" setfacl -m g:"$app":r-x "$install_dir" setfacl -m g:"www-data":r-x "$install_dir" setfacl -m g:"gemserv":r-x "$install_dir" @@ -48,13 +41,13 @@ setfacl -m g:"gemserv":r-x "$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 PHP-FPM config -ynh_add_fpm_config +ynh_config_add_phpfpm # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx _ynh_add_gemserv_config @@ -62,4 +55,4 @@ _ynh_add_gemserv_config # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression "Upgrade of $app completed"