diff options
author | Guido Falsi <madpilot@FreeBSD.org> | 2017-08-27 20:35:38 +0000 |
---|---|---|
committer | Guido Falsi <madpilot@FreeBSD.org> | 2017-08-27 20:35:38 +0000 |
commit | 1d35c8f2e70f153e01aa1025bd997155fc2e3872 (patch) | |
tree | f033469ce48d2fd996c171b04a7697aafd377aba | |
parent | 36bfacdf54af8b9ba991b6106e4744fefc4c748a (diff) | |
download | ports-1d35c8f2e70f153e01aa1025bd997155fc2e3872.tar.gz ports-1d35c8f2e70f153e01aa1025bd997155fc2e3872.zip |
MFH: r448520
Make the provided rc script more robust.
Also add an asterisk_stopsleep knob (disabled by default) to allow
users to work around a possible race condition when asterisk is sent
a stop command just after launching, but before it's startup is
actually completed.
PR: 221271
Submitted by: O. Hartmann <ohartmann@walstatt.org>
Approved by: ports-secteam (delphij)
Notes
Notes:
svn path=/branches/2017Q3/; revision=448842
-rw-r--r-- | net/asterisk11/Makefile | 2 | ||||
-rw-r--r-- | net/asterisk11/files/asterisk.in | 20 | ||||
-rw-r--r-- | net/asterisk13/Makefile | 1 | ||||
-rw-r--r-- | net/asterisk13/files/asterisk.in | 20 |
4 files changed, 38 insertions, 5 deletions
diff --git a/net/asterisk11/Makefile b/net/asterisk11/Makefile index 321cb97cff46..09dbf4bdb5d0 100644 --- a/net/asterisk11/Makefile +++ b/net/asterisk11/Makefile @@ -2,7 +2,7 @@ PORTNAME= asterisk PORTVERSION= 11.25.1 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= net MASTER_SITES= http://downloads.asterisk.org/pub/telephony/%SUBDIR%/:DEFAULT,g729 MASTER_SITE_SUBDIR= asterisk/ \ diff --git a/net/asterisk11/files/asterisk.in b/net/asterisk11/files/asterisk.in index e2d997ecc201..54adef50c7e6 100644 --- a/net/asterisk11/files/asterisk.in +++ b/net/asterisk11/files/asterisk.in @@ -17,6 +17,8 @@ # Default is "-n" # asterisk_pidfile (string): Location of the asterisk pid file # Default is /var/run/asterisk/asterisk.pid +# asterisk_stopsleep (int): Number of seconds to sleep before sending stop command +# Default is 0, which disables it # . /etc/rc.subr @@ -31,6 +33,7 @@ load_rc_config $name : ${asterisk_user:=%%ASTERISK_USER%%} : ${asterisk_args=-n} : ${asterisk_pidfile:=/var/run/asterisk/asterisk.pid} +: ${asterisk_stopsleep:=0} extra_commands=reload @@ -52,13 +55,26 @@ asterisk_precmd() asterisk_stop() { - echo 'Stopping asterisk' + if [ -z "$rc_pid" ]; then + [ -n "$rc_fast" ] && return 0 + _run_rc_notrunning + return 1 + fi + echo 'Stopping asterisk.' + if [ ${asterisk_stopsleep} > 0 ]; then + sleep ${asterisk_stopsleep} + fi $command -nqrx 'core stop now' + wait_for_pids $rc_pid } asterisk_reload() { - echo 'Reloading asterisk' + if [ -z "$rc_pid" ]; then + _run_rc_notrunning + return 1 + fi + echo 'Reloading asterisk.' $command -nqrx 'reload' } diff --git a/net/asterisk13/Makefile b/net/asterisk13/Makefile index eb589d4f7539..be54c50003b3 100644 --- a/net/asterisk13/Makefile +++ b/net/asterisk13/Makefile @@ -2,6 +2,7 @@ PORTNAME= asterisk PORTVERSION= 13.16.0 +PORTREVISION= 1 CATEGORIES= net MASTER_SITES= http://downloads.asterisk.org/pub/telephony/%SUBDIR%/:DEFAULT,g729 MASTER_SITE_SUBDIR= asterisk/ \ diff --git a/net/asterisk13/files/asterisk.in b/net/asterisk13/files/asterisk.in index e2d997ecc201..54adef50c7e6 100644 --- a/net/asterisk13/files/asterisk.in +++ b/net/asterisk13/files/asterisk.in @@ -17,6 +17,8 @@ # Default is "-n" # asterisk_pidfile (string): Location of the asterisk pid file # Default is /var/run/asterisk/asterisk.pid +# asterisk_stopsleep (int): Number of seconds to sleep before sending stop command +# Default is 0, which disables it # . /etc/rc.subr @@ -31,6 +33,7 @@ load_rc_config $name : ${asterisk_user:=%%ASTERISK_USER%%} : ${asterisk_args=-n} : ${asterisk_pidfile:=/var/run/asterisk/asterisk.pid} +: ${asterisk_stopsleep:=0} extra_commands=reload @@ -52,13 +55,26 @@ asterisk_precmd() asterisk_stop() { - echo 'Stopping asterisk' + if [ -z "$rc_pid" ]; then + [ -n "$rc_fast" ] && return 0 + _run_rc_notrunning + return 1 + fi + echo 'Stopping asterisk.' + if [ ${asterisk_stopsleep} > 0 ]; then + sleep ${asterisk_stopsleep} + fi $command -nqrx 'core stop now' + wait_for_pids $rc_pid } asterisk_reload() { - echo 'Reloading asterisk' + if [ -z "$rc_pid" ]; then + _run_rc_notrunning + return 1 + fi + echo 'Reloading asterisk.' $command -nqrx 'reload' } |