mirror of
https://github.com/aipeach/cloudflare-api-v4-ddns.git
synced 2025-01-18 22:09:28 +08:00
Changed file names to have prefix .cf, added record name to file name to support multiple domains.
This commit is contained in:
parent
8b5fd9ea4b
commit
53c8935edc
@ -83,8 +83,9 @@ fi
|
|||||||
|
|
||||||
# Get current and old WAN ip
|
# Get current and old WAN ip
|
||||||
WAN_IP=`curl -s ${WANIPSITE}`
|
WAN_IP=`curl -s ${WANIPSITE}`
|
||||||
if [ -f $HOME/.wan_ip-cf.txt ]; then
|
WAN_IP_FILE=$HOME/.cf-wan_ip_$CFRECORD_NAME.txt
|
||||||
OLD_WAN_IP=`cat $HOME/.wan_ip-cf.txt`
|
if [ -f $WAN_IP_FILE ]; then
|
||||||
|
OLD_WAN_IP=`cat $WAN_IP_FILE`
|
||||||
else
|
else
|
||||||
echo "No file, need IP"
|
echo "No file, need IP"
|
||||||
OLD_WAN_IP=""
|
OLD_WAN_IP=""
|
||||||
@ -97,7 +98,7 @@ if [ "$WAN_IP" = "$OLD_WAN_IP" ] && [ "$FORCE" = false ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get zone_identifier & record_identifier
|
# Get zone_identifier & record_identifier
|
||||||
ID_FILE=$HOME/.id-cf.txt
|
ID_FILE=$HOME/.cf-id_$CFRECORD_NAME.txt
|
||||||
if [ -f $ID_FILE ] && [ $(wc -l $ID_FILE | cut -d " " -f 1) == 4 ] \
|
if [ -f $ID_FILE ] && [ $(wc -l $ID_FILE | cut -d " " -f 1) == 4 ] \
|
||||||
&& [ "$(sed -n '3,1p' "$ID_FILE")" == "$CFZONE_NAME" ] \
|
&& [ "$(sed -n '3,1p' "$ID_FILE")" == "$CFZONE_NAME" ] \
|
||||||
&& [ "$(sed -n '4,1p' "$ID_FILE")" == "$CFRECORD_NAME" ]; then
|
&& [ "$(sed -n '4,1p' "$ID_FILE")" == "$CFRECORD_NAME" ]; then
|
||||||
@ -124,7 +125,7 @@ RESPONSE=$(curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/$CFZONE_ID
|
|||||||
|
|
||||||
if [ "$RESPONSE" != "${RESPONSE%success*}" ] && [ $(echo $RESPONSE | grep "\"success\":true") != "" ]; then
|
if [ "$RESPONSE" != "${RESPONSE%success*}" ] && [ $(echo $RESPONSE | grep "\"success\":true") != "" ]; then
|
||||||
echo "Updated succesfuly!"
|
echo "Updated succesfuly!"
|
||||||
echo $WAN_IP > $HOME/.wan_ip-cf.txt
|
echo $WAN_IP > $WAN_IP_FILE
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
echo 'Something went wrong :('
|
echo 'Something went wrong :('
|
||||||
|
Loading…
x
Reference in New Issue
Block a user