1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/grist_ynh.git synced 2024-09-03 20:36:18 +02:00

Upgrade + backup + restore + change_url

This commit is contained in:
Florent 2023-11-11 20:48:16 +01:00 committed by Florent F
parent c1d8ce077c
commit a7e654d400
5 changed files with 21 additions and 62 deletions

View file

@ -15,11 +15,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that
### creates and fills the archive with the files happens in the core after this
### script is called. Hence ynh_backups calls take basically 0 seconds to run.
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
@ -39,19 +34,6 @@ ynh_backup --src_path="$data_dir" --is_big
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/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"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
@ -66,24 +48,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup --src_path="/etc/$app/"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
### (However, things like MySQL dumps *do* take some time to run, though the
### copy of the generated dump to the archive still happens later)
ynh_mysql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -25,6 +25,9 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
ynh_change_url_nginx_config ynh_change_url_nginx_config
ynh_script_progression --message="Updating env configuration file..." --weight=1
ynh_add_config --template="default.env" --destination="$install_dir/default.env"
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================

View file

@ -30,7 +30,7 @@ pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --pure-lockfile ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install:python ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install:python
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH:$install_dir/node_modules/.bin yarn run build:prod ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH:$install_dir/node_modules/.bin yarn run build:prod
# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean
popd popd
pushd "$install_dir/sandbox/pyodide" pushd "$install_dir/sandbox/pyodide"

View file

@ -32,13 +32,6 @@ ynh_restore_file --origin_path="$data_dir" --not_mandatory
# (Same as for install dir) # (Same as for install dir)
chown -R $app:www-data "$data_dir" chown -R $app:www-data "$data_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
@ -48,8 +41,6 @@ ynh_script_progression --message="Restoring system configurations related to $ap
# This should be a symetric version of what happens in the install script # This should be a symetric version of what happens in the install script
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
@ -59,15 +50,6 @@ yunohost service add $app --description="A short description of the app" --log="
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/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
# Other various files...
ynh_restore_file --origin_path="/etc/cron.d/$app"
ynh_restore_file --origin_path="/etc/$app/"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -77,7 +59,6 @@ ynh_script_progression --message="Reloading NGINX web server and $app's service.
# Typically you only have either $app or php-fpm but not both at the same time... # Typically you only have either $app or php-fpm but not both at the same time...
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -51,6 +51,21 @@ fi
# ownership to all files such as after the ynh_setup_source step # ownership to all files such as after the ynh_setup_source step
chown -R $app:www-data "$install_dir" chown -R $app:www-data "$install_dir"
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
pushd "$install_dir"
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --pure-lockfile
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install:python
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH:$install_dir/node_modules/.bin yarn run build:prod
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean
popd
pushd "$install_dir/sandbox/pyodide"
ynh_exec_warn_less ynh_exec_as $app make setup
popd
fi
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
@ -58,8 +73,6 @@ ynh_script_progression --message="Upgrading system configurations related to $ap
# This should be a literal copypaste of what happened in the install's "System configuration" section # This should be a literal copypaste of what happened in the install's "System configuration" section
ynh_add_fpm_config
ynh_add_nginx_config ynh_add_nginx_config
ynh_add_systemd_config ynh_add_systemd_config
@ -68,8 +81,6 @@ yunohost service add $app --description="A short description of the app" --log="
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#================================================= #=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#================================================= #=================================================
@ -82,7 +93,7 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
### The file will automatically be backed-up if it's found to be manually modified (because ### The file will automatically be backed-up if it's found to be manually modified (because
### ynh_add_config keeps track of the file's checksum) ### ynh_add_config keeps track of the file's checksum)
ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file" ynh_add_config --template="default.env" --destination="$install_dir/default.env"
# FIXME: this should be handled by the core in the future # FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400, # You may need to use chmod 600 instead of 400,