View previous topic :: View next topic |
Author |
Message |
xanthax Tux's lil' helper


Joined: 16 Apr 2004 Posts: 91 Location: Bi Nary State
|
Posted: Sun Mar 19, 2006 10:21 am Post subject: [dyndns|statdns|custom] Without external program... |
|
|
I had a problem: Updating my dyndns without installing a bunch of strange software.....
I came up with a solution: Write a script that wont use a any extra programs that already i dont have.
EDIT: after som complains from a friend i rewrote the script to fit into "gentoo standard" better..
So here is the new script
Code: |
#!/bin/sh
# $1 file containing the following information
################################################
# Username Password Eth Dns Wildcard System #
################################################
# Eth #[eth*] Ethernet device to use
# LIP #[NOT ENTERED BY USER] Last IP
# CIP #[NOT ENTERED BY USER] Current IP
# Dns #[myhost.dyndns.org] Dynamic address
# Username #[Username] Dyndns username
# Password #[Password] Dyndns password
# Wildcard #[ON|OFF|NOCHG] Enable *.mydomain.dyndns.org
# MXHost #[mailexchanger|NOCHG] MX server
# MXBackup #[YES|NO|NOCHG] Backup MX server
# System #[dyndns|statdns|custom] DNS provider
TmpRcode="/tmp/dyndns_rcode"
TmpConf="/tmp/dyndns_config"
IPLog="/tmp/dyndns_ip"
if ! [ -e $1 ] ; then
echo "Specified config file does not exist."
exit 1
fi
source $1
if [ -z $MXHost ] ;then
MXHost="NOCHG"
fi
if [ -z $MXBackup ] ;then
MXBackup="NOCHG"
fi
if [ -z $Wildcard ] ;then
Wildcard="NOCHG"
fi
if [ -z $System ] ; then
echo "system missing..."
exit 1
fi
if [ -z $Eth ] ; then
echo "eth missing..."
exit 1
fi
if [ -z $Dns ] ; then
echo "dns missing..."
exit 1
fi
if [ -z $Username ] ; then
echo "username missing..."
exit 1
fi
if [ -z $Password ] ; then
echo "password missing..."
exit 1
fi
if ! [ -e $IPLog ] ; then
touch $IPLog
fi
LIP=`cat $IPLog | grep $Dns= | cut -d "=" -f 2`
CIP=`/sbin/ifconfig $Eth | grep "inet addr" | cut -d ":" -f 2 | cut -d " " -f 1`
if [ "$CIP" != "$LIP" ] ; then
wget -q --no-check-certificate -O $TmpRcode "https://$Username:$Password@members.dyndns.org/nic/update?system=$System&hostname=$Dns&myip=$CIP&wildcard=$Wildcard&mx=$MXHost&backmx=$MXBackup&offline=NO"
RCODE=`cat $TmpRcode | grep " " | cut -d " " -f 1`
if [ "$RCODE" = "badsys" ] ; then
echo "################################################################################"
echo "#Invalid service provider specified #"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "!donator" ] ; then
echo "################################################################################"
echo "#PAY YOUR BILLS !!!!!!!! #"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "nochg" ] ; then
echo "################################################################################"
echo "#WARNING, Unneeded update of IP, repeting this might lead to a canceled account#"
echo "################################################################################"
fi
if [ "$RCODE" = "badauth" ] ; then
echo "################################################################################"
echo "#Password or username is incorret #"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "notfqdn" ] ; then
echo "################################################################################"
echo "#Not a qualified hostname #"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "nohost" ] ; then
echo "################################################################################"
echo "#No such hostname exists#"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "!yours" ] ; then
echo "################################################################################"
echo "#No such host in YOUR account #"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "numhost" ] ; then
echo "################################################################################"
echo "#To many or to few hosts specified #"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "abuse" ] ; then
echo "################################################################################"
echo "#Your account is blocked because of update abuse #"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "dnserr" ] ; then
echo "################################################################################"
echo "#DNS error #"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "911" ] ; then
echo "################################################################################"
echo "#Server problems, check your DNS providers homepage #"
echo "################################################################################"
exit 1
fi
if [ "$RCODE" = "" ] ; then
echo "################################################################################"
echo "#No respons from server #"
echo "################################################################################"
exit 1
fi
if [ -z $LIP ] ; then
echo "$Dns=0.0.0.0" >> $IPLog
fi
cat $IPLog > $TmpConf
sed -e s/^$Dns=.*/$Dns=$CIP/g $TmpConf > $IPLog
fi
|
Here is the new config file
Code: |
Dns=test.ath.cx
Eth=eth1
Username=test
Password=test
System=dyndns
Wildcard=ON
|
You execute by using:
Code: |
Bash# /PATH/SCRIPT /PATH/CONF
|
TIP:
And a little tip is to put these files somwhere safe and link to them from your dhcpcd execute script "<ConfigDir>/dhcpcd.exe".
Then you have created a permanently automatical update wich does not get your account blocked
EDIT:
********************************************************
Example of singel host: /etc/dhcpc/dhcpcd.exe
Code: |
/var/updatedns/updatedns /var/updatedns/test.ath.cx
|
If you have multiple dyndnses just create a con file for each and execute, like this.
Example of multiple hosts: /etc/dhcpc/dhcpcd.exe
Code: |
/var/updatedns/updatedns /var/updatedns/test.ath.cx
/var/updatedns/updatedns /var/updatedns/test.dyndns.org
|
******************************************************** _________________ God is only an imaginary friend for adults...
Last edited by xanthax on Sun Mar 19, 2006 1:42 pm; edited 3 times in total |
|
Back to top |
|
 |
pyxel n00b


Joined: 04 Nov 2005 Posts: 44 Location: Bratislava/brussels
|
Posted: Sun Mar 19, 2006 10:29 am Post subject: |
|
|
nice script |
|
Back to top |
|
 |
xanthax Tux's lil' helper


Joined: 16 Apr 2004 Posts: 91 Location: Bi Nary State
|
Posted: Sun Mar 19, 2006 1:44 pm Post subject: |
|
|
Thanks, im will fix output logging instead of printing on error too.
but not right now..... _________________ God is only an imaginary friend for adults... |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|