Saturday, April 21, 2012

Installing DynDns (inadyn) as service on Linux (Ubuntu)

Installing DynDns (inadyn) as service on Linux (Ubuntu)

To use DynDns on linux, we firs need the client.

In this artice I'll use INADYN.

To install inadyn execute:
sudo apt-get install inadyn

than we have to create inadyn configuration file:
sudo vim /etc/inadyn.conf
# Basic configuration file for inadyn
#
# /etc/inadyn.conf
update_period_sec 600 # Check for a new IP every 600 seconds
username <yourusername>
password <yourpassword>
dyndns_system dyndns@dyndns.org
alias <yourdomainname>
background

now we are going to create the service by creating:
sudo vim /etc/init.d/inadyn
#!/bin/bash
case "$1" in
    start)
    if [ -f /tmp/inadyn.pid ]; then
        PID=$(cat /tmp/inadyn.pid)
        kill -0 ${PID} &>/dev/null
        if [ $? = 0 ]; then
            echo "Inadyn is already running."
        else
            /usr/sbin/inadyn
            pidof inadyn > /tmp/inadyn.pid
            PID=$(cat /tmp/inadyn.pid)
            kill -0 ${PID} &>/dev/null
            if [ $? = 0 ]; then
                echo "Inadyn started succesfully."
            else
                echo "Error starting Inadyn"
            fi
        fi
    else
        /usr/sbin/inadyn
        pidof inadyn > /tmp/inadyn.pid
        PID=$(cat /tmp/inadyn.pid)
        kill -0 ${PID} &>/dev/null
        if [ $? = 0 ]; then
            echo "Inadyn started succesfully."
        else
            echo "Error starting Inadyn"
        fi
        fi
        ;;
    stop)
    if [ -f /tmp/inadyn.pid ];then
        PID=$(cat /tmp/inadyn.pid)
        kill -0 ${PID} &>/dev/null
        if [ $? = 0 ]; then
            /bin/kill ${PID}
            kill -0 ${PID} &>/dev/null
            if [ $? = 1 ]; then
                echo "Inadyn stopped succesfully."
            else
                echo "Error stopping Inadyn"
            fi
        else
            echo "Inadyn is already stopped."
        fi
    else
        echo "Inadyn is already stopped."
    fi
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
esac
exit 0

let's change the file permission so can be executed:
sudo chmod 0755 /etc/init.d/inadyn

Then we configure inadyn for autostart:
sudo update-rc.d inadyn defaults

Starting the inadyn service:
sudo service inadyn start

And that's it.

Thank you...

References:
http://www.inatech.eu/inadyn/
http://www.linuxquestions.org/questions/linux-software-2/how-do-i-execute-inadyn-automatically-during-boot-541367/#post4518378

4 comments:

  1. one thousand time thank you
    i was not able to do it mysel and there's no guide on http://dyn.com/dns/ site
    you're guide is clear and correct
    WoW :)

    ReplyDelete
  2. Hell thank you very much. Just one question: I got this message after executing this command: sudo update-rc.d inadyn defaults =>
    update-rc.d: warning: /etc/init.d/inadyn missing LSB information
    update-rc.d: see

    ¿What can it be?

    ReplyDelete
    Replies
    1. Add an LSB header to the top of your /etc/init.d/inadyn file:

      ### BEGIN INIT INFO
      # Provides: inadyn
      # Required-Start: $local_fs $network
      # Required-Stop: $local_fs
      # Default-Start: 2 3 4 5
      # Default-Stop: 0 1 6
      # Short-Description: inadyn
      # Description: inadyn dynamic dns update
      ### END INIT INFO

      Delete