mirror of
https://github.com/YunoHost-Apps/nomad_ynh.git
synced 2024-09-03 19:55:53 +02:00
85 lines
3.3 KiB
Bash
85 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
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
|
|
|
chown -R "$app:$app" "$install_dir"
|
|
|
|
#=================================================
|
|
# RESTORE THE DATA DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
|
|
|
chown -R "$app:$app" "$data_dir"
|
|
|
|
#=================================================
|
|
# RESTORE VARIOUS FILES
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring various files..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$config_path"
|
|
|
|
chmod -R go-rwx,u-w "$config_path"
|
|
chown -R "$app:$app" "$config_path"
|
|
|
|
if [ "$node_type" == "client" ]; then
|
|
if [ "$driver_lxc" -eq 1 ]; then
|
|
client_lxc_main_iface=$(ip route | grep default | awk '{print $5;}')
|
|
ynh_app_setting_set --app="$app" --key=client_lxc_main_iface --value="$client_lxc_main_iface"
|
|
|
|
ynh_add_config --template="dnsmasq-lxd" --destination="/etc/dnsmasq.d/lxd"
|
|
systemctl restart dnsmasq
|
|
|
|
if [ ! "${PACKAGE_CHECK_EXEC:-0}" -eq 1 ]; then
|
|
ynh_add_config --template="lxc-net" --destination="/etc/default/lxc-net"
|
|
fi
|
|
ynh_secure_remove --file="/etc/lxc/default.conf"
|
|
ynh_add_config --template="default.conf" --destination="/etc/lxc/default.conf"
|
|
systemctl enable lxc-net --quiet
|
|
ynh_systemd_action --service_name=lxc-net --action="restart" --line_match="Finished LXC network bridge setup" --log_path="systemd"
|
|
fi
|
|
fi
|
|
|
|
#=================================================
|
|
# 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"
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|
systemctl enable "$app.service" --quiet
|
|
yunohost service add "$app" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port_rpc" "$port_serf"
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
ynh_restore_file --origin_path="/var/log/$app/"
|
|
|
|
#=================================================
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Nomad agent started"
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|