From 17adecd5e393406746ede4ddef0f26afdd7307ba Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 00:58:31 +0200 Subject: [PATCH 1/2] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 1 + conf/cron | 2 +- conf/extra_php-fpm.conf | 4 +- conf/nginx.conf | 2 +- config_panel.toml.example | 30 ------------- manifest.toml | 4 +- scripts/_common.sh | 14 +----- scripts/backup | 31 +++++-------- scripts/change_url | 24 ++++------ scripts/config | 95 --------------------------------------- scripts/install | 45 +++++++++---------- scripts/remove | 18 +++----- scripts/restore | 49 +++++++++----------- scripts/upgrade | 45 ++++++++----------- 14 files changed, 92 insertions(+), 272 deletions(-) delete mode 100644 config_panel.toml.example delete mode 100644 scripts/config diff --git a/.gitignore b/.gitignore index f487cfe..4fe46e3 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ Thumbs.db ################ #config.php #data/files +*.sw[op] diff --git a/conf/cron b/conf/cron index cbddb73..b978e04 100644 --- a/conf/cron +++ b/conf/cron @@ -1,2 +1,2 @@ # Execute the daily cronjob at 8am -0 8 * * * __APP__ /usr/bin/php__PHPVERSION__ __INSTALL_DIR__/cli cronjob > /dev/null +0 8 * * * __APP__ /usr/bin/php__PHP_VERSION__ __INSTALL_DIR__/cli cronjob > /dev/null diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf index 3c943c9..2439ef9 100644 --- a/conf/extra_php-fpm.conf +++ b/conf/extra_php-fpm.conf @@ -1,7 +1,5 @@ ; Additional php.ini defines, specific to this pool of workers. -php_value[upload_max_filesize] = 100M -php_value[post_max_size] = 100M php_value[default_charset] = UTF-8 -php_value[session.save_path] = /var/www/__NAMETOCHANGE__/sessions +php_value[session.save_path] = /var/www/__APP__/sessions diff --git a/conf/nginx.conf b/conf/nginx.conf index f95318a..d6037cd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -17,7 +17,7 @@ location __PATH__/ { try_files $uri $uri/ __PATH__/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/config_panel.toml.example b/config_panel.toml.example deleted file mode 100644 index c43df57..0000000 --- a/config_panel.toml.example +++ /dev/null @@ -1,30 +0,0 @@ -version = "1.0" - -[main] -name = "Kanboard configuration" - - [main.php_fpm_config] - name = "PHP-FPM configuration" - - [main.php_fpm_config.fpm_footprint] - ask = "Memory footprint" - type = "select" - choices.low = "Low, <= 20Mb per pool" - choices.medium = "Medium, between 20Mb and 40Mb per pool" - choices.high = "High, > 40Mb per pool" - choices.specific = "Use specific value" - default = "low" - - [main.php_fpm_config.fpm_free_footprint] - visible = "fpm_footprint == 'specific'" - ask = "Memory footprint of the service?" - type = "number" - default = "0" - help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values." - - [main.php_fpm_config.fpm_usage] - ask = "Expected usage" - type = "select" - choices = ["low", "medium", "high"] - default = "low" - help = "low: Personal usage, behind the SSO. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.
medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.
high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding." diff --git a/manifest.toml b/manifest.toml index ca9fa0c..cfcfce4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -18,7 +18,8 @@ code = "https://github.com/kanboard/kanboard" fund = "https://kanboard.org/#donations" [integration] -yunohost = ">= 11.2.27" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true @@ -58,6 +59,7 @@ ram.runtime = "50M" allow_email = true [resources.install_dir] + group = "www-data:r-x" [resources.data_dir] subdirs = ["cache", "files"] diff --git a/scripts/_common.sh b/scripts/_common.sh index 1e47ce7..253c6fe 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,19 +1,7 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= # PHP APP SPECIFIC #================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index ff96bd2..229457a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,55 +1,46 @@ #!/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 #================================================= # Only relevant if there is a "data_dir" resource for this app -ynh_backup --src_path="$data_dir" --is_big +ynh_backup "$data_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" -ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" +ynh_backup "/etc/fail2ban/jail.d/$app.conf" +ynh_backup "/etc/fail2ban/filter.d/$app.conf" -ynh_backup --src_path="/etc/cron.d/$app" +ynh_backup "/etc/cron.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 9828506..52bb1bd 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,49 +1,41 @@ #!/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 #================================================= # SETUP FAIL2BAN #================================================= -ynh_script_progression --message="Configuring Fail2Ban..." --weight=10 +ynh_script_progression "Configuring Fail2Ban..." # Remove the config file with $old_domain -ynh_remove_fail2ban_config +ynh_config_remove_fail2ban # Add config file with $new_domain -ynh_add_fail2ban_config --logpath="/var/log/nginx/${new_domain}-error.log" --failregex="^.*authentication failure\" while reading response header from upstream, client: ,.*$" --max_retry=5 +ynh_config_add_fail2ban --logpath="/var/log/nginx/${new_domain}-error.log" --failregex="^.*authentication failure\" while reading response header from upstream, client: ,.*$" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=2 +ynh_script_progression "Updating configuration..." if [ $change_domain -eq 1 ] then # Change domain in Kanboard configuration - ynh_replace_string --match_string="'${old_domain}'" --replace_string="'${new_domain}'" --target_file="${install_dir}/config.php" + ynh_replace --match="'${old_domain}'" --replace="'${new_domain}'" --file="${install_dir}/config.php" fi #================================================= # 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/config b/scripts/config deleted file mode 100644 index 91c2de7..0000000 --- a/scripts/config +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source _common.sh -source /usr/share/yunohost/helpers - -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) - -#================================================= -# SPECIFIC GETTERS FOR TOML SHORT KEY -#================================================= - -get__fpm_footprint() { - # Free footprint value for php-fpm - # Check if current_fpm_footprint is an integer - if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null - then - echo "specific" - else - echo "$current_fpm_footprint" - fi -} - -get__free_footprint() { - # Free footprint value for php-fpm - # Check if current_fpm_footprint is an integer - if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null - then - # If current_fpm_footprint is an integer, that's a numeric value for the footprint - echo "$current_fpm_footprint" - else - echo "0" - fi -} - -#================================================= -# SPECIFIC SETTERS FOR TOML SHORT KEYS -#================================================= - -set__fpm_footprint() { - if [ "$fpm_footprint" != "specific" ] - then - ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint" - fi -} - -set__fpm_free_footprint() { - if [ "$fpm_footprint" = "specific" ] - then - ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_free_footprint" - fi -} - -#================================================= -# GENERIC FINALIZATION -#================================================= - -ynh_app_config_validate() { - _ynh_app_config_validate - - if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[fpm_free_footprint]}" == "true" ]; then - # If fpm_footprint is set to 'specific', use $fpm_free_footprint value. - if [ "$fpm_footprint" = "specific" ] - then - fpm_footprint=$fpm_free_footprint - fi - - if [ "$fpm_footprint" == "0" ] - then - ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below." - - exit 0 - fi - fi -} - -ynh_app_config_apply() { - _ynh_app_config_apply - - ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint -} - -ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index 920d8bb..92e8db7 100644 --- a/scripts/install +++ b/scripts/install @@ -1,18 +1,14 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers +ynh_app_setting_set --key=php_upload_max_filesize --value=100M + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=2 +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" @@ -21,54 +17,53 @@ mkdir -p $install_dir/sessions/ chown -R $app $install_dir/{plugins,sessions} chmod -R 700 $install_dir/sessions -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" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=16 +ynh_script_progression "Configuring PHP-FPM..." # 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_config --template="cron" --destination="/etc/cron.d/$app" -chown root: "/etc/cron.d/$app" -chmod 644 "/etc/cron.d/$app" +ynh_config_add --template="cron" --destination="/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure\" while reading response header from upstream, client: ,.*$" --max_retry=5 +ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure\" while reading response header from upstream, client: ,.*$" #================================================= # SPECIFIC SETUP #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." dir="__DIR__" -ynh_add_config --template="config.php" --destination="$install_dir/config.php" +ynh_config_add --template="config.php" --destination="$install_dir/config.php" -chmod 400 "$install_dir/config.php" -chown $app "$install_dir/config.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 400 "$install_dir/config.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.php" #================================================= # DATABASE INITIALIZATION #================================================= -ynh_script_progression --message="Initializing database..." --weight=7 +ynh_script_progression "Initializing database..." -ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/app/Schema/Sql/mysql.sql" +ynh_mysql_db_shell < "$install_dir/app/Schema/Sql/mysql.sql" pushd $install_dir # Launch database migration - php$phpversion cli db:migrate --no-interaction --verbose + php$php_version cli db:migrate --no-interaction --verbose 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 b65e33a..cd4604b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,33 +1,27 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 +ynh_script_progression "Removing NGINX web server configuration..." # 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 the dedicated Fail2Ban config -ynh_remove_fail2ban_config +ynh_config_remove_fail2ban # Remove a cron file -ynh_secure_remove --file="/etc/cron.d/$app" +ynh_safe_rm "/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index bd6a502..cc74697 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,18 +7,17 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=5 +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 DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" # (Same as for install dir) chown -R $app:www-data "$data_dir" @@ -32,41 +25,39 @@ chown -R $app:www-data "$data_dir" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=3 +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=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/fail2ban/jail.d/$app.conf" -ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" -ynh_systemd_action --action=restart --service_name=fail2ban +ynh_restore "/etc/fail2ban/jail.d/$app.conf" +ynh_restore "/etc/fail2ban/filter.d/$app.conf" +ynh_systemctl --action=restart --service=fail2ban -ynh_restore_file --origin_path="/etc/cron.d/$app" -chown root: "/etc/cron.d/$app" -chmod 644 "/etc/cron.d/$app" +ynh_restore "/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=2 +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 af49510..ba039f0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,18 +1,14 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers +ynh_app_setting_set_default --key=php_upload_max_filesize --value=100M + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=3 +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --keep="config.php" @@ -21,52 +17,49 @@ mkdir -p $install_dir/sessions/ chown -R $app $install_dir/{plugins,sessions} chmod -R 700 $install_dir/sessions -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" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=5 +ynh_script_progression "Upgrading PHP-FPM configuration..." # 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 Fail2Ban config -ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure\" while reading response header from upstream, client: ,.*$" --max_retry=5 +ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure\" while reading response header from upstream, client: ,.*$" -ynh_add_config --template="cron" --destination="/etc/cron.d/$app" -chown root: "/etc/cron.d/$app" -chmod 644 "/etc/cron.d/$app" +ynh_config_add --template="cron" --destination="/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." #dir="__DIR__" -#ynh_add_config --template="config.php" --destination="$install_dir/config.php" +#ynh_config_add --template="config.php" --destination="$install_dir/config.php" -#chmod 400 "$install_dir/config.php" -#chown $app "$install_dir/config.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 400 "$install_dir/config.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.php" -#================================================= -# SPECIFIC UPGRADE #================================================= # UPGRADE KANBOARD #================================================= -ynh_script_progression --message="Upgrading the app..." --weight=2 +ynh_script_progression "Upgrading the app..." pushd $install_dir # Launch database migration - php$phpversion cli db:migrate --no-interaction --verbose + php$php_version cli db:migrate --no-interaction --verbose popd #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" From 5bbd5b3703321cb42ab3f27a296c29014f814622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 31 Aug 2024 21:47:23 +0200 Subject: [PATCH 2/2] cleaning --- manifest.toml | 2 +- scripts/_common.sh | 2 -- scripts/backup | 2 -- scripts/change_url | 3 --- scripts/install | 13 +------------ scripts/remove | 4 ---- scripts/restore | 5 ----- scripts/upgrade | 13 +------------ 8 files changed, 3 insertions(+), 41 deletions(-) diff --git a/manifest.toml b/manifest.toml index cfcfce4..7168620 100644 --- a/manifest.toml +++ b/manifest.toml @@ -18,7 +18,7 @@ code = "https://github.com/kanboard/kanboard" fund = "https://kanboard.org/#donations" [integration] -yunohost = ">= 11.2.18" +yunohost = ">= 11.2.29" helpers_version = "2.1" architectures = "all" multi_instance = true diff --git a/scripts/_common.sh b/scripts/_common.sh index 253c6fe..3d7f008 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,5 +3,3 @@ #================================================= # COMMON VARIABLES AND CUSTOM HELPERS #================================================= -# PHP APP SPECIFIC -#================================================= diff --git a/scripts/backup b/scripts/backup index 229457a..c716ce9 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,6 +1,5 @@ #!/bin/bash -# 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 @@ -16,7 +15,6 @@ ynh_backup "$install_dir" # BACKUP THE DATA DIR #================================================= -# Only relevant if there is a "data_dir" resource for this app ynh_backup "$data_dir" #================================================= diff --git a/scripts/change_url b/scripts/change_url index 52bb1bd..11d037a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -17,10 +17,8 @@ ynh_config_change_url_nginx #================================================= ynh_script_progression "Configuring Fail2Ban..." -# Remove the config file with $old_domain ynh_config_remove_fail2ban -# Add config file with $new_domain ynh_config_add_fail2ban --logpath="/var/log/nginx/${new_domain}-error.log" --failregex="^.*authentication failure\" while reading response header from upstream, client: ,.*$" #================================================= @@ -30,7 +28,6 @@ ynh_script_progression "Updating configuration..." if [ $change_domain -eq 1 ] then - # Change domain in Kanboard configuration ynh_replace --match="'${old_domain}'" --replace="'${new_domain}'" --file="${install_dir}/config.php" fi diff --git a/scripts/install b/scripts/install index 92e8db7..97e0663 100644 --- a/scripts/install +++ b/scripts/install @@ -10,31 +10,24 @@ ynh_app_setting_set --key=php_upload_max_filesize --value=100M #================================================= 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" mkdir -p $install_dir/sessions/ chown -R $app $install_dir/{plugins,sessions} chmod -R 700 $install_dir/sessions -#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" + #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression "Configuring PHP-FPM..." -# Create a dedicated PHP-FPM config ynh_config_add_phpfpm -# Create a dedicated NGINX config ynh_config_add_nginx ynh_config_add --template="cron" --destination="/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" -# Create a dedicated Fail2Ban config ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure\" while reading response header from upstream, client: ,.*$" #================================================= @@ -47,9 +40,6 @@ ynh_script_progression "Adding $app's configuration..." dir="__DIR__" ynh_config_add --template="config.php" --destination="$install_dir/config.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 400 "$install_dir/config.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.php" - #================================================= # DATABASE INITIALIZATION #================================================= @@ -58,7 +48,6 @@ ynh_script_progression "Initializing database..." ynh_mysql_db_shell < "$install_dir/app/Schema/Sql/mysql.sql" pushd $install_dir - # Launch database migration php$php_version cli db:migrate --no-interaction --verbose popd diff --git a/scripts/remove b/scripts/remove index cd4604b..9a99b95 100644 --- a/scripts/remove +++ b/scripts/remove @@ -8,16 +8,12 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression "Removing NGINX web server configuration..." -# Remove the dedicated NGINX config ynh_config_remove_nginx -# Remove the dedicated PHP-FPM config ynh_config_remove_phpfpm -# Remove the dedicated Fail2Ban config ynh_config_remove_fail2ban -# Remove a cron file ynh_safe_rm "/etc/cron.d/$app" #================================================= diff --git a/scripts/restore b/scripts/restore index cc74697..984d08a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,6 +1,5 @@ #!/bin/bash -# 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 @@ -11,7 +10,6 @@ ynh_script_progression "Restoring the app main directory..." ynh_restore "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= @@ -19,7 +17,6 @@ ynh_script_progression "Restoring the data directory..." ynh_restore "$data_dir" -# (Same as for install dir) chown -R $app:www-data "$data_dir" #================================================= @@ -45,8 +42,6 @@ ynh_restore "/etc/fail2ban/filter.d/$app.conf" ynh_systemctl --action=restart --service=fail2ban ynh_restore "/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM diff --git a/scripts/upgrade b/scripts/upgrade index ba039f0..68e0b64 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,32 +10,25 @@ ynh_app_setting_set_default --key=php_upload_max_filesize --value=100M #================================================= ynh_script_progression "Upgrading source files..." -# Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --keep="config.php" mkdir -p $install_dir/sessions/ chown -R $app $install_dir/{plugins,sessions} chmod -R 700 $install_dir/sessions -#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" + #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression "Upgrading PHP-FPM configuration..." -# Create a dedicated PHP-FPM config ynh_config_add_phpfpm -# Create a dedicated NGINX config ynh_config_add_nginx -# Create a dedicated Fail2Ban config ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authentication failure\" while reading response header from upstream, client: ,.*$" ynh_config_add --template="cron" --destination="/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" #================================================= # ADD A CONFIGURATION @@ -45,16 +38,12 @@ ynh_script_progression "Adding $app's configuration..." #dir="__DIR__" #ynh_config_add --template="config.php" --destination="$install_dir/config.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 400 "$install_dir/config.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.php" - #================================================= # UPGRADE KANBOARD #================================================= ynh_script_progression "Upgrading the app..." pushd $install_dir - # Launch database migration php$php_version cli db:migrate --no-interaction --verbose popd