mirror of
https://github.com/YunoHost-Apps/netdata_ynh.git
synced 2024-09-03 19:46:33 +02:00
64 lines
2.6 KiB
Bash
64 lines
2.6 KiB
Bash
#!/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
|
|
|
|
#=================================================
|
|
# STANDARD RESTORATION STEPS
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring Netdata configuration directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$install_dir/etc/netdata"
|
|
|
|
#=================================================
|
|
# INSTALL AND RESTORE THE APP CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Reinstalling Netdata..." --weight=18
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
NETDATA_TMPDIR=$(mktemp -d)
|
|
ynh_setup_source --dest_dir="$NETDATA_TMPDIR" --full_replace=1
|
|
|
|
# create a temporary file for the log
|
|
tmplog=$(mktemp /tmp/netdata-updater-log-XXXXXX.log)
|
|
|
|
pushd "$NETDATA_TMPDIR"
|
|
# the installer.sh script will append "netdata" after the --install-prefix arg
|
|
./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel >"$tmplog" 2>"$tmplog" || ynh_die "FAILED TO COMPILE/INSTALL NETDATA"
|
|
popd
|
|
|
|
# Specific configuration
|
|
configure_netdata
|
|
|
|
#=================================================
|
|
# 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"
|
|
|
|
yunohost service add "$app" --description "Real-time performance and health monitoring" --log "$install_dir/var/log/netdata/error.log" "$install_dir/var/log/netdata/access.log" "$install_dir/var/log/netdata/debug.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD 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="$install_dir/var/log/$app/error.log"
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|