33 lines
682 B
Bash
33 lines
682 B
Bash
#!/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
|
||
|