1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/onlyoffice_ynh.git synced 2024-09-03 19:56:11 +02:00
onlyoffice_ynh/scripts/restore
2024-08-01 16:23:38 +02:00

89 lines
3 KiB
Bash

#!/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
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
#=================================================
# INSTALL ONLYOFFICE
#=================================================
ynh_script_progression --message="Install OnlyOffice..."
_install_msfonts_deb
_install_onlyoffice_deb
#=================================================
# RESTORE THE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the configuration..."
ynh_restore_file --origin_path="/etc/onlyoffice"
#=================================================
# RESTORE THE CACHE
#=================================================
ynh_restore_file --origin_path="/var/lib/onlyoffice/documentserver/App_Data/cache/files"
#=================================================
# REGENERATE FONTS
#=================================================
ynh_script_progression --message="Generating fonts..."
/usr/bin/documentserver-generate-allfonts.sh 2>/dev/null
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R ds:ds "$install_dir"
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
for service in "ds-converter" "ds-docservice" "ds-metrics"; do
yunohost service add "$service"
done
#=================================================
# START SERVICES
#=================================================
for service in "ds-converter" "ds-docservice" "ds-metrics"; do
ynh_systemd_action --action=restart --service_name="$service"
done
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app"