#!/bin/sh
#
# chkconfig: - 99 80
# description: Starts and stops the no-ip.com Dynamic dns client daemon
#
# pidfile: /var/run/noip.pid
#
# Written by serge@vanginderachter.be and tested on Redhat 8
# ... and debugged by Uwe Dippel
# 29-03-2003
#
# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 0
fi

DAEMON=noip

# Avoid using root's TMPDIR
unset TMPDIR

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

RETVAL=0

start() {
	if [ -f /var/lock/subsys/noip ] ; then
		echo "no-ip client daemon already started" && exit 0
	fi
	echo -n $"Starting no-ip client daemon: "
	daemon /usr/bin/$DAEMON -c /etc/no-ip2.conf
	echo
	RETVAL=$?
        touch /var/lock/subsys/noip
        return $RETVAL
}	

stop() {
	if [ -f /var/lock/subsys/noip ] ; then
		echo -n $"Stopping no-ip client daemon: "
		killproc $DAEMON -TERM
		echo
		RETVAL=$?
		rm -f /var/lock/subsys/noip
	else
		echo "no-ip client daemon is not running" && exit 0
	fi
	return $RETVAL
}	

restart() {
	stop
	start
}	

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
  	restart
	;;
  condrestart)
        [ -f /var/lock/subsys/noip ] && restart || :
        ;;
  reload)
        echo -n $"Reloading $prog: "
        killproc $DAEMON -HUP
        RETVAL=$?
        echo
        ;;
  status)
        status $DAEMON
        RETVAL=$?
        ;;
  *)
	echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
	exit 1
esac

exit $?
