1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/diaspora_ynh.git synced 2024-09-03 18:26:13 +02:00
diaspora_ynh/scripts/restore

82 lines
3.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
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression "Reinstalling Ruby..."
ynh_ruby_install
ynh_script_progression "Reinstalling NodeJS..."
ynh_nodejs_install
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression "Restoring the app main directory..."
ynh_restore "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression "Restoring the PostgreSQL database..."
ynh_psql_db_shell < ./db.sql
#=================================================
# BUILD APP
#=================================================
ynh_script_progression "Building app..."
pushd "$install_dir/live"
gem install "bundler:$bundler_version"
ynh_exec_as_app ruby_load_path" "$ld_preload" script/configure_bundler
popd
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/systemd/system/${app}_web.service"
ynh_restore "/etc/systemd/system/${app}_sidekiq.service"
ynh_restore "/etc/systemd/system/${app}.target"
systemctl enable "${app}_web" "${app}_sidekiq" "$app.target" --quiet
yunohost service add "$app.target" --description "Diaspora service (unicorn web and sidekiq)" \
--log "$install_dir/live/log/production.log" \
"$install_dir/live/log/unicorn-stderr.log" \
"$install_dir/live/log/unicorn-stdout.log" \
"$install_dir/live/log/sidekiq.log"
ynh_restore "/etc/tmpfiles.d/${app}.conf"
systemd-tmpfiles --create
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression "Reloading NGINX web server and $app's service..."
systemctl restart "${app}.target"
ynh_systemctl --service="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --wait_until="successfully configured the federation library"
ynh_systemctl --service="${app}_sidekiq.service" --action=restart --log_path="systemd" --wait_until="Running in ruby"
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Restoration completed for $app"