2021-09-18 14:27:12 +02:00
|
|
|
#!/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=2
|
|
|
|
|
2023-03-31 20:51:42 +02:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2021-09-18 14:27:12 +02:00
|
|
|
|
2023-03-31 20:51:42 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-09-18 14:27:12 +02:00
|
|
|
|
2021-09-18 14:36:33 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE DATA DIRECTORY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
|
|
|
|
2023-03-31 20:51:42 +02:00
|
|
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
2021-09-18 14:36:33 +02:00
|
|
|
|
2023-03-31 20:51:42 +02:00
|
|
|
mkdir -p $data_dir
|
2021-09-18 14:36:33 +02:00
|
|
|
|
2023-03-31 20:51:42 +02:00
|
|
|
chmod 750 "$data_dir"
|
|
|
|
chmod -R o-rwx "$data_dir"
|
|
|
|
chown -R $app:www-data "$data_dir"
|
2021-09-18 14:36:33 +02:00
|
|
|
|
2021-09-18 14:27:12 +02:00
|
|
|
#=================================================
|
|
|
|
# REINSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2023-03-31 20:51:42 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=7
|
2021-09-18 14:27:12 +02:00
|
|
|
|
|
|
|
# Install Nodejs
|
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
|
|
|
2022-08-18 11:24:30 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2021-09-18 14:36:33 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE MYSQL DATABASE
|
|
|
|
#=================================================
|
2023-03-31 20:58:08 +02:00
|
|
|
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
2021-09-18 14:36:33 +02:00
|
|
|
|
|
|
|
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
|
|
|
|
2021-09-18 14:27:12 +02:00
|
|
|
#=================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=3
|
|
|
|
|
2021-09-18 22:24:48 +02:00
|
|
|
yunohost service add $app --description="Workflow Automation Tool" --log="/var/log/$app/$app.log"
|
2021-09-18 14:27:12 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the systemd configuration..." --weight=8
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|
|
|
systemctl enable $app.service --quiet
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=8
|
|
|
|
|
2021-09-18 19:44:48 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action=restart --log_path=systemd --line_match="Editor is now accessible via:"
|
2021-09-18 14:27:12 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX AND PHP-FPM
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-09-18 15:01:21 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|