nginx dynamic allow script
This commit is contained in:
parent
63f61de636
commit
71a29966e9
22
nginx-allow-dynamicip/nginx-allow-dynamicip.sh
Executable file
22
nginx-allow-dynamicip/nginx-allow-dynamicip.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONFIG=/etc/nginx/sites-enabled/$1
|
||||
DOMAIN=$2
|
||||
|
||||
IP=$(ping -c 1 $DOMAIN | awk '{print $3}' | head -n 1 | sed 's\(\\' | sed 's\)\\')
|
||||
IP_OLD=$(grep -A0 '#DYNAMIC' $CONFIG | awk '{print $2}' | cut -f1 -d ';')
|
||||
|
||||
if [ "$IP" != "$IP_OLD" ]
|
||||
then
|
||||
NGINX_STATUS=$(nginx -t 2>&1 | tail -n 1 | awk '{print $7}')
|
||||
if [ "$NGINX_STATUS" = "successful"]
|
||||
then
|
||||
sed -i "s/$IP_OLD/$IP/" $CONFIG
|
||||
systemctl restart nginx
|
||||
else
|
||||
echo bruh
|
||||
fi
|
||||
else
|
||||
echo bruh
|
||||
fi
|
||||
|
3
nginx-allow-dynamicip/write.mv.ip
Normal file
3
nginx-allow-dynamicip/write.mv.ip
Normal file
@ -0,0 +1,3 @@
|
||||
172.67.210.188
|
||||
172.67.210.188
|
||||
104.21.45.64
|
Loading…
x
Reference in New Issue
Block a user