1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lstu_ynh.git synced 2024-09-03 19:36:12 +02:00
lstu_ynh/scripts/restore

102 lines
3.1 KiB
Text
Raw Normal View History

2017-04-21 12:54:39 +02:00
#!/bin/bash
2019-02-03 01:04:22 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-04-21 12:54:39 +02:00
2019-02-03 01:04:22 +01:00
source ../settings/scripts/_common.sh
2017-04-21 12:54:39 +02:00
source /usr/share/yunohost/helpers
2019-02-03 01:04:22 +01:00
#=================================================
# 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 SETTINGS
#=================================================
2017-04-21 12:54:39 +02:00
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
2019-02-03 01:04:22 +01:00
path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
2019-02-03 21:39:45 +01:00
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
# Define and install dependencies
ynh_install_app_dependencies build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql
2019-02-03 01:04:22 +01:00
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_restore_file "$final_path"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
db_pwd=$(ynh_app_setting_get $app psqlpwd)
ynh_psql_setup_db $db_name $db_name $db_pwd
2019-02-03 22:39:25 +01:00
ynh_psql_connect_as $db_name $db_pwd < ./db.sql
2019-02-03 01:04:22 +01:00
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_restore_file "/etc/systemd/system/$app.service"
systemctl enable $app.service
2019-02-03 21:24:02 +01:00
ynh_systemd_action -n $app -a start -l "Server available at" -p "systemd"
2019-02-03 01:04:22 +01:00
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --log "/var/log/$app.log"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file "/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx
yunohost app ssowatconf