feat: init
All checks were successful
perso/docker-dynhost/pipeline/head This commit looks good

This commit is contained in:
Julien Cabillot
2021-10-06 19:45:44 -04:00
parent c25e9dcd89
commit 9daff71fb3
3 changed files with 73 additions and 0 deletions

27
entrypoint.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env sh
# Account configuration
#HOST=
#LOGIN=
#PASSWORD=
# Get current IPv4 and corresponding configured
HOST_IP=$(dig +short $HOST A)
CURRENT_IP=$(curl -m 5 -4 ifconfig.co 2>/dev/null)
if [ -z $CURRENT_IP ]
then
CURRENT_IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
fi
CURRENT_DATETIME=$(date -R)
# Update dynamic IPv4, if needed
if [ -z $CURRENT_IP ] || [ -z $HOST_IP ]
then
echo "[$CURRENT_DATETIME]: No IP retrieved"
else
if [ "$HOST_IP" != "$CURRENT_IP" ]
then
RES=$(curl --silent --show-error -m 5 -L --location-trusted --user "$LOGIN:$PASSWORD" "https://www.ovh.com/nic/update?system=dyndns&hostname=$HOST&myip=$CURRENT_IP")
echo "[$CURRENT_DATETIME]: IPv4 has changed - request to OVH DynHost: $RES"
fi
fi