Merge pull request #27 from jabaz/master-ubuntu

Prevent service to start multiple times

Added messages if trying to start/stop already started/stopped service.
Added daemon install instructions for ubuntu.
This commit is contained in:
wimpunk 2015-09-30 17:37:54 +02:00
commit 32e6b9bc19
2 changed files with 22 additions and 7 deletions

View file

@ -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.

View file

@ -20,15 +20,19 @@ 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
@ -36,6 +40,8 @@ case "$1" in
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)