#!/bin/bash


export log_file=/etc/keepalived/report.log

if [[ $( ip addr | grep -c "192.168.148.131") -eq 1 ]]; then

    echo "当前主机为 主loadbalancer节点！ 当前时间为 $(date) " >> ${log_file}

    echo "start to sync nginx conf to another loadbalancer" >> ${log_file}
    rclone sync /etc/nginx/ loadbalancer:/etc/nginx/ >> ${log_file}

    echo "start to reload the other loadbalancer nginx" >> ${log_file}
    ssh loadbalancer "systemctl restart nginx"

    echo "" >> ${log_file}
    echo "----------------------------" >> ${log_file}
fi


