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

95 lines
3.5 KiB
Text
Raw Normal View History

2022-07-20 12:04:29 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# 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-14 14:13:22 +01:00
# RESTORE THE APP MAIN DIR
2022-07-20 12:04:29 +02:00
#=================================================
2024-02-14 14:13:22 +01:00
ynh_script_progression --message="Restoring the app main directory..." --weight=1
2022-07-20 12:04:29 +02:00
2024-02-14 14:13:22 +01:00
ynh_restore_file --origin_path="$install_dir"
2022-07-20 12:04:29 +02:00
2024-02-14 14:13:22 +01:00
chown -R "$app:$app" "$install_dir"
2022-07-20 12:04:29 +02:00
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
2022-09-03 18:58:58 +02:00
ynh_script_progression --message="Restoring the data directory..." --weight=1
2022-07-20 12:04:29 +02:00
2024-02-14 14:13:22 +01:00
ynh_restore_file --origin_path="$data_dir" --not_mandatory
2022-07-23 04:57:16 +02:00
2024-02-14 14:13:22 +01:00
chown -R "$app:$app" "$data_dir"
2022-07-20 12:04:29 +02:00
#=================================================
# RESTORE VARIOUS FILES
#=================================================
2022-09-03 18:58:58 +02:00
ynh_script_progression --message="Restoring various files..." --weight=1
2022-07-20 12:04:29 +02:00
2022-07-21 08:24:29 +02:00
ynh_restore_file --origin_path="$config_path"
2024-02-14 14:13:22 +01:00
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
2022-07-21 08:24:29 +02:00
fi
2022-07-20 12:04:29 +02:00
#=================================================
2024-02-14 14:13:22 +01:00
# RESTORE SYSTEM CONFIGURATIONS
2022-07-20 12:04:29 +02:00
#=================================================
2024-02-14 14:13:22 +01:00
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
2022-07-20 12:04:29 +02:00
2024-02-14 14:13:22 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2022-07-20 12:04:29 +02:00
2024-02-14 14:13:22 +01:00
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"
2022-07-20 12:04:29 +02:00
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2024-02-14 14:13:22 +01:00
ynh_restore_file --origin_path="/var/log/$app/"
2022-07-20 12:04:29 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-09-03 18:58:58 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2022-07-20 12:04:29 +02:00
2024-02-14 14:13:22 +01:00
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Nomad agent started"
2022-07-20 12:04:29 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2022-07-21 08:24:29 +02:00
# RELOAD NGINX
2022-07-20 12:04:29 +02:00
#=================================================
2022-09-03 18:58:58 +02:00
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
2022-07-20 12:04:29 +02:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2022-09-03 18:58:58 +02:00
ynh_script_progression --message="Restoration completed for $app" --last