#!/bin/bash
### BEGIN INIT INFO
# Provides: noip2
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of noip2
# Description: No-IP DUC (DNS Update Client) start stop service script
### END INIT INFO
#
# copy to /etc/init.d
# run "update-rc.d noip2 defaults" to install
# run "update-rc.d noip2 remove" to remove
#
# Version 1 by Craig Lorentzen
# Version 2 - Added LSB INIT INFO
# Version 3 - Improved error handling and readability
# Version 4 - Added status (to check if the service is running and with what PID
NAME=noip2
PATH=/usr/local/bin
DAEMON=$PATH/$NAME
PID=$(/bin/pidof -s $DAEMON)
do_start()
{
echo "Starting $NAME."
echo
if [ $PID ]; then
echo " WARNING: $NAME is already running."
echo
PID=
else
$($DAEMON)
fi
}
do_stop()
{
echo "Stopping $NAME."
echo
if [ $PID ]; then
kill $PID
PID=
else
echo " WARNING: $NAME is not running."
echo
fi
}
do_status()
{
if [ $PID ]; then
echo "$NAME is running as $PID"
else
echo "$NAME is not running"
echo
fi
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart)
echo "Restarting $NAME."
do_stop
do_start
;;
status)
do_status
;;
*)
echo " Usage: $NAME (start|stop|restart|status)"
echo
exit 1
;;
esac
exit 0
If you have a No-IP Dynamic DNS account, free at no-ip.com Then you likely want to use the DUC (Dynamic Update Client) to automate the process of keeping it up-to-date. No-IP provides a client for Windows, Mac, and Linux. I have an Linux host running 24x7 at my house, so I decided to try the Linux version.
http://www.no-ip.com/downloads.php?page=linux
This tool used to be in the Ubuntu repositories but has been removed, so No-IP provides the source to be compiled, however, they don't provide a good start script and do not use the upstart method to install the automatic starter. So I decided to create a proper script to follow the upstart method. I understand that this script is not following all LSB standards, however, it should do what people need after following the process that No-IP Provides to compile and install.
1 comment:
This is really more of a sysV style startup script, not upstart.
Post a Comment