2021-03-11 00:34:24 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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
|
|
|
|
|
|
|
|
#=================================================
|
2024-02-28 22:22:42 +01:00
|
|
|
# REINSTALL DEPENDENCIES
|
2021-03-11 00:34:24 +01:00
|
|
|
#=================================================
|
2024-02-28 22:22:42 +01:00
|
|
|
ynh_script_progression --message="Reinstalling NodeJS..." --weight=5
|
2021-03-11 00:34:24 +01:00
|
|
|
|
2024-02-28 22:22:42 +01:00
|
|
|
# Define and install dependencies
|
|
|
|
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
2021-03-11 00:34:24 +01:00
|
|
|
|
2021-08-05 23:28:50 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
|
|
|
|
2024-02-28 22:22:42 +01:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2021-03-11 00:34:24 +01:00
|
|
|
|
2024-02-28 22:22:42 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2021-03-11 00:34:24 +01:00
|
|
|
|
2024-02-28 22:22:42 +01:00
|
|
|
mkdir -p "$install_dir/dist"
|
|
|
|
chown -R "$app:$app" "$install_dir/dist" "$install_dir/global" "$install_dir/config"
|
2021-03-11 00:34:24 +01:00
|
|
|
|
|
|
|
#=================================================
|
2024-02-28 22:22:42 +01:00
|
|
|
# RESTORE VARIOUS FILES
|
2021-03-11 00:34:24 +01:00
|
|
|
#=================================================
|
|
|
|
|
2022-07-29 01:48:52 +02:00
|
|
|
# restore dato.ini config in couch
|
|
|
|
if [[ $autosynchronize == true ]]; then
|
2024-02-28 22:22:42 +01:00
|
|
|
ynh_restore_file --origin_path="/opt/couchdb/etc/local.d/$app.ini"
|
2022-07-29 01:48:52 +02:00
|
|
|
fi
|
2021-03-11 00:34:24 +01:00
|
|
|
|
|
|
|
#=================================================
|
2024-02-28 22:22:42 +01:00
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
2021-03-11 00:34:24 +01:00
|
|
|
#=================================================
|
2024-02-28 22:22:42 +01:00
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
2021-03-11 00:34:24 +01:00
|
|
|
|
2024-02-28 22:22:42 +01:00
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2021-03-11 00:34:24 +01:00
|
|
|
|
2024-02-28 22:22:42 +01:00
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|
|
|
systemctl enable "$app.service" --quiet
|
|
|
|
yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
|
2021-03-11 00:34:24 +01:00
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
|
|
|
|
#=================================================
|
2024-02-28 22:22:42 +01:00
|
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
2022-07-29 01:48:52 +02:00
|
|
|
#=================================================
|
2024-02-28 22:22:42 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
2021-03-11 00:34:24 +01:00
|
|
|
|
2024-02-28 22:22:42 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
|
2021-03-11 00:34:24 +01:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|