#!/bin/bash

# File to which lines will be added
FILE_PATH="health_alarm_notify.conf"
MY_TEMPLATE="myshares/shared/etc/netdata/$FILE_PATH"
UPDATE_OCCURED="NO"

# Enter the config dir
cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata

sudo rsync -avP -e "ssh -o StrictHostKeyChecking=no" dbi@ket.inxs.me:"$MY_TEMPLATE" .
UPDATE_OCCURED="YES"

# Check if the variable value is 'yes'
if [[ "$UPDATE_OCCURED" == "YES" ]]; then
    sudo systemctl restart netdata
    # # Test notification 
    # sudo su -s /bin/bash netdata
    # export NETDATA_ALARM_NOTIFY_DEBUG=1
    # # send test alarms to any role
    # /usr/libexec/netdata/plugins.d/alarm-notify.sh test "ROLE"
    # exit
fi