1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/zusam_ynh.git synced 2024-09-03 18:05:54 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 03:59:37 +02:00 committed by Alexandre Aubin
parent 6d127843cb
commit adce43dbc4
12 changed files with 94 additions and 155 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~
*.sw[op]
.DS_Store

View file

@ -1,2 +1,2 @@
# Run periodically to update your website
*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f api/bin/console zusam:cron >> __INSTALL_DIR__/api/var/log/cron.log
*/10 * * * * __APP__ /usr/bin/php__PHP_VERSION__ -f api/bin/console zusam:cron >> __INSTALL_DIR__/api/var/log/cron.log

View file

@ -1,4 +0,0 @@
; Additional php.ini defines, specific to this pool of workers.
php_admin_value[upload_max_filesize] = 2048M
php_admin_value[post_max_size] = 2048M

View file

@ -17,7 +17,7 @@
try_files $uri /api/index.php$is_args$args;
}
location ~ ^/api/index\.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_split_path_info ^(.+\.php)(/.*)$;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

View file

@ -17,7 +17,8 @@ admindoc = "https://github.com/zusam/zusam/tree/master/documentation"
code = "https://github.com/zusam/zusam"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true
ldap = false
@ -70,6 +71,7 @@ ram.runtime = "50M"
[resources.system_user]
[resources.install_dir]
group = "www-data:r-x"
[resources.data_dir]

View file

@ -1,17 +1,5 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================

View file

@ -1,44 +1,34 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
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"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
# 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"
#=================================================
# SPECIFIC BACKUP
@ -46,16 +36,16 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# BACKUP LOGROTATE
#=================================================
# ynh_backup --src_path="/etc/logrotate.d/$app"
# ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup "/etc/cron.d/$app"
#=================================================
# 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)."

View file

@ -1,24 +1,16 @@
#!/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=1
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# SPECIFIC MODIFICATIONS
@ -26,12 +18,10 @@ ynh_change_url_nginx_config
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,43 +1,39 @@
#!/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=2048M
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
email=$(ynh_user_get_info --username=$first_user --key=mail)
random_string="$(ynh_string_random --length=48)"
fpm_footprint="medium"
fpm_free_footprint=0
fpm_usage="medium"
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | fpm_footprint="medium"
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_free_footprint=0
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | fpm_usage="medium"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_script_progression "Storing installation settings..."
ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set --app=$app --key=first_user_pass --value=$first_user_pass
ynh_app_setting_set --app=$app --key=first_group --value=$first_group
ynh_app_setting_set --app=$app --key=random_string --value=$random_string
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
ynh_app_setting_set --key=email --value=$email
ynh_app_setting_set --key=first_user_pass --value=$first_user_pass
ynh_app_setting_set --key=first_group --value=$first_group
ynh_app_setting_set --key=random_string --value=$random_string
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value=$fpm_footprint
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_free_footprint --value=$fpm_free_footprint
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage
#=================================================
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source
ynh_setup_source --dest_dir="$install_dir"
@ -45,58 +41,55 @@ ynh_setup_source --dest_dir="$install_dir"
# Let's copy the webapp in the public directory
cp -R $install_dir/app/dist/* $install_dir/public/
ynh_script_progression --message="Pulling in external libraries with Composer..."
ynh_script_progression "Pulling in external libraries with Composer..."
ynh_install_composer -c "2.4.2" -w $install_dir/api/
chown -R $app:www-data "$install_dir"
ynh_composer_install
ynh_composer_exec install --no-dev -c "2.4.2" -w $install_dir/api/
#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 PHP-FPM config using conf/extra_php-fpm.conf
ynh_add_fpm_config
ynh_config_add_phpfpm
# Create a dedicated NGINX config using the conf/nginx.conf template
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated Fail2Ban config
# We'll see that in later versions
# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
# ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
# ADD A CONFIGURATION
#=================================================
# ynh_script_progression --message="Adding a configuration file..." --weight=1
# ynh_script_progression "Adding $app's configuration..."
# We'll take care of language later
# ynh_add_config --template="../conf/sample.env" --destination="$install_dir/api/.env"
# ynh_config_add --template="sample.env" --destination="$install_dir/api/.env"
chmod 600 "$install_dir/api/.env"
chown $app:www-data "$install_dir/api/.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 600 "$install_dir/api/.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:www-data "$install_dir/api/.env"
#=================================================
# DATABASE
#=================================================
ynh_script_progression --message="Initialiazing the database..." --weight=1
/usr/bin/php$phpversion $install_dir/api/bin/console zusam:init $email "$first_group" $first_user_pass
ynh_script_progression "Initialiazing the database..."
/usr/bin/php$php_version $install_dir/api/bin/console zusam:init $email "$first_group" $first_user_pass
chown -R $app:www-data $install_dir
#=================================================
# GENERIC FINALIZATION
#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
#=================================================
ynh_add_config --template="../conf/cronjob" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
ynh_config_add --template="cronjob" --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"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -13,18 +7,18 @@ source /usr/share/yunohost/helpers
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_remove_nginx_config
ynh_config_remove_nginx
ynh_remove_fpm_config
ynh_config_remove_phpfpm
# ynh_remove_logrotate
# ynh_config_remove_logrotate
# ynh_remove_fail2ban_config
# ynh_config_remove_fail2ban
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"

View file

@ -1,56 +1,47 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$install_dir"
chown -R $app:www-data "$install_dir"
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 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/logrotate.d/$app"
# ynh_restore "/etc/logrotate.d/$app"
# 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
# Other various files...
ynh_restore_file --origin_path="/etc/cron.d/$app"
ynh_restore "/etc/cron.d/$app"
#=================================================
# 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=php$phpversion-fpm --action=reload
ynh_systemctl --service=php$php_version-fpm --action=reload
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"

View file

@ -1,24 +1,17 @@
#!/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=2048M
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
#=================================================
@ -27,15 +20,16 @@ upgrade_type=$(ynh_check_app_version_changed)
# 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=1
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --full_replace
if [ -f $install_dir/api/config/packages/sensio_framework_extra.yaml ]
then
ynh_secure_remove $install_dir/api/config/packages/sensio_framework_extra.yaml
ynh_safe_rm $install_dir/api/config/packages/sensio_framework_extra.yaml
fi
fi
@ -43,38 +37,38 @@ fi
# ACTUAL UPDATE
#=================================================
ynh_script_progression --message="Proceeding to migration..."
ynh_script_progression "Proceeding to migration..."
pushd $install_dir
ynh_script_progression --message="Proceeding to migration..."
ynh_secure_remove $install_dir/api/var/cache/
php$phpversion api/bin/console doctrine:migration:migrate --no-interaction --allow-no-migration
php$phpversion api/bin/console zusam:migration
ynh_script_progression "Proceeding to migration..."
ynh_safe_rm $install_dir/api/var/cache/
php$php_version api/bin/console doctrine:migration:migrate --no-interaction --allow-no-migration
php$php_version api/bin/console zusam:migration
ynh_script_progression --message="Pulling in external libraries with Composer..."
ynh_install_composer -c "2.4.2" -w $install_dir/api/
ynh_script_progression "Pulling in external libraries with Composer..."
ynh_composer_install
ynh_composer_exec install --no-dev -c "2.4.2" -w $install_dir/api/
cp -r app/dist/* public/
popd
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 | 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..."
# This should be a literal copypasta of what happened in the install's "System configuration" section
ynh_add_fpm_config
ynh_config_add_phpfpm
ynh_add_nginx_config
ynh_config_add_nginx
# ynh_use_logrotate --non-append
# ynh_config_add_logrotate
# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
# ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"