From 4e7fcccbef3d70967c3a10a0cbe60c00c03068a8 Mon Sep 17 00:00:00 2001 From: Jon Bonilla Date: Thu, 19 Jul 2012 19:58:06 +0000 Subject: [PATCH] You can be lsb compliant and kind to asterisk Somehow looks like asterisk does not like a start when it'sa already started. I never had any issues but read about it. It's safe to check status before running start. Still need to work in asterisk restart upon upgrades. And how to deal with monit for that. --- debian/asterisk.init | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/debian/asterisk.init b/debian/asterisk.init index 78bc038..c9046ee 100755 --- a/debian/asterisk.init +++ b/debian/asterisk.init @@ -64,8 +64,17 @@ fi # Use the LSB standar functions for services management . /lib/lsb/init-functions + +status() { + status_of_proc "$DAEMON" "$NAME" && return 0 || return $? +} + case "$1" in start) + if status > /dev/null; then + echo "$DESC is already running. Use restart." + exit 0 + fi log_begin_msg "Starting $DESC: $NAME" if [ $AST_USER ] ; then ASTARGS="-U $AST_USER" @@ -95,7 +104,8 @@ case "$1" in # "restart|force-reload" starts Asterisk and returns 0 even if Asterisk was stopped (as LSB expects). ;; status) - status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + status + exit $? ;; *) N=/etc/init.d/$NAME