Home | Script


[SHELL] - Mise à jour Dyndns chez OVH

Script permettant de mettre à jour le serveur Dyndns de OVH. Pour plus d'informations : README

>> Télécharger le script.

dyndns.sh

#!/bin/bash
 
# Liste des domaines séparés par des virgules.
DOMAINES=("www.votredomaine.com" )
 
#Compte
ACCOUNT="xxxxx"
 
#Mot de passe
PWD="xxxxx"
 
# On recupere notre IP et on la stocke dans ip.new.
 
lynx --source http://www.monip.org | sed -nre 's/^.* (([0-9]{1,3}\.){3}[0-9]{1,3}).*$/\1/p' > /etc/dyndns/ip.new
 
MONIP_OLD=$(cat /etc/dyndns/ip.old) 
MONIP_NEW=$(cat /etc/dyndns/ip.new)
 
# On calcule le nombre de domaines.
NB_DOMAINES=$[${#DOMAINES[*]}-1]
 
if [ "${MONIP_OLD}" = "${MONIP_NEW}" ]
then
	# Aucun chamgement.
	echo "IP Identiques >> Aucuns changements"
else
	# Sinon on UPDATE les domaines.
	for((i=0;i<=${NB_DOMAINES};i++))
	do
		echo ${DOMAINES[$i]}	
		lynx -source -auth=${ACCOUNT}':'${PWD} 'http://www.ovh.com/nic/update?myip='${MONIP_NEW}'&hostname='${DOMAINES[$i]}'&system=dyndns'
		echo ""	
	done
 
	# On copie la nouvelle IP dans ip.old
	mv /etc/dyndns/ip.new /etc/dyndns/ip.old
fi