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:
Janne Hannila 2015-09-02 18:51:30 +03:00
parent c497ed04c7
commit 14e8539eaf
2 changed files with 22 additions and 7 deletions

View file

@ -72,6 +72,15 @@ INSTALLATION:
apk add perl apk add perl
## start the first time by hand ## start the first time by hand
rc-service ddclient start 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 ## If you are not using daemon-mode, configure cron and dhcp or ppp
## as described below. ## as described below.

View file

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