Files
zeaslity 437acbeb63 add
2024-10-30 16:30:51 +08:00

33 lines
682 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
if [[ $( ip addr | grep -c "192.168.148.131") -eq 1 ]]; then
echo "当前主机为 主loadbalancer节点 当前时间为 $(date) "
chown -R nginx:nginx /etc/nginx/
cd /etc/nginx/ && nginx -t
cd /etc/nginx/conf.d/ && nginx -t
if [[ $? -ne 0 ]]; then
echo "nginx conf is wrong ! please check !"
return 23
fi
echo "start to sync nginx conf to another nginx node"
rclone sync /etc/nginx/ loadbalancer:/etc/nginx/
echo "start to restart this-self and another nginx conf"
systemctl restart nginx
ssh loadbalancer "systemctl restart nginx"
else
echo "can't modify nginx conf in this host !"
fi