Skip to content

Commit

Permalink
Merge pull request ddclient#27 from jabaz/master-ubuntu
Browse files Browse the repository at this point in the history
Prevent service to start multiple times

Added messages if trying to start/stop already started/stopped service.
Added daemon install instructions for ubuntu.
  • Loading branch information
wimpunk committed Sep 30, 2015
2 parents e7290d8 + 14e8539 commit 32e6b9b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ INSTALLATION:
apk add perl
## start the first time by hand
rc-service ddclient start

## For those using Ubuntu style rc files and using daemon-mode:
cp sample-etc_rc.d_init.d_ddclient.ubuntu /etc/init.d/ddclient
## enable automatic startup when booting
update-rc.d ddclient defaults
## make sure you have perl installed
apt-get install perl
## start the first time by hand
service ddclient start

## If you are not using daemon-mode, configure cron and dhcp or ppp
## as described below.
Expand Down
20 changes: 13 additions & 7 deletions sample-etc_rc.d_init.d_ddclient.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,28 @@ test -f $CONF || exit 0

case "$1" in
start)
log_begin_msg "Starting ddclient..."
DELAY=`grep -v '^\s*#' $CONF | grep -i -m 1 "daemon" | awk -F '=' '{print $2}'`
if [ -z "$DELAY" ] ; then
DELAY="-daemon 300"
if [ ! -f $PIDFILE ]; then
log_begin_msg "Starting ddclient..."
DELAY=`grep -v '^\s*#' $CONF | grep -i -m 1 "daemon" | awk -F '=' '{print $2}'`
if [ -z "$DELAY" ] ; then
DELAY="-daemon 300"
else
DELAY=''
fi
start-stop-daemon -S -q -p $PIDFILE -x $DDCLIENT -- $DELAY
log_end_msg $?
else
DELAY=''
log_warning_msg "Service ddclient already running..."
fi
start-stop-daemon -S -q -p $PIDFILE -x $DDCLIENT -- $DELAY
log_end_msg $?
;;
stop)
if [ -f $PIDFILE ] ; then
log_begin_msg "Stopping ddclient..."
start-stop-daemon -K -q -p $PIDFILE
log_end_msg $?
rm -f $PIDFILE
else
log_warning_msg "No ddclient running..."
fi
;;
restart|reload|force-reload)
Expand Down

0 comments on commit 32e6b9b

Please sign in to comment.