From 81169c4e1e9ffc4a37ec9ae450ea159cda266ea8 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 11 Jan 2022 11:09:56 +0100 Subject: [PATCH] Fix --- scripts/backup | 73 ++++++++++++++++++++++++++++++++++++++----------- scripts/install | 16 +++++++++++ 2 files changed, 73 insertions(+), 16 deletions(-) diff --git a/scripts/backup b/scripts/backup index 01a0761..910eee9 100644 --- a/scripts/backup +++ b/scripts/backup @@ -3,35 +3,76 @@ #================================================= # 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 +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors -# Load common variables and helpers -source ../settings/scripts/_common.sh +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading installation settings..." # Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) +domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +#================================================= +# BACKUP THE APP MAIN DIR #================================================= -# Copy the app source files -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" -# Copy the data files -ynh_backup "$DATADIR" +#================================================= +# BACKUP THE DATA DIR +#================================================= -# Copy the conf files -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" -ynh_backup "/etc/systemd/system/${app}.service" +ynh_backup --src_path="$DATADIR" -# Backup logs -ynh_backup "/var/log/$app" +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= -# Dump the database -ynh_mysql_dump_db "$dbname" > ./db.sql \ No newline at end of file +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + +#================================================= +# BACKUP VARIOUS FILES +#================================================= + +ynh_backup --src_path="/var/log/$app" + +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= +ynh_print_info --message="Backing up the MySQL database..." + +ynh_mysql_dump_db --database="$db_name" > db.sql + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 5dfa367..389900b 100644 --- a/scripts/install +++ b/scripts/install @@ -65,9 +65,19 @@ ynh_setup_source $final_path $architecture # Configure gogs with app.ini file config_gogs +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." --weight=1 + # Configure init script ynh_add_systemd_config +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 + # Modify Nginx configuration file and copy it to Nginx conf directory config_nginx @@ -89,3 +99,9 @@ ynh_use_logrotate "/var/log/$app" # Reload services #ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gogs.log" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --last