diff options
author | madpilot <madpilot@FreeBSD.org> | 2017-08-27 20:35:38 +0000 |
---|---|---|
committer | madpilot <madpilot@FreeBSD.org> | 2017-08-27 20:35:38 +0000 |
commit | 4f359d813ba6ad3fa4498fd25e03eb4c70f6f2e0 (patch) | |
tree | f033469ce48d2fd996c171b04a7697aafd377aba | |
parent | 7876731a8e208224a784cfac168539658d9f9760 (diff) | |
download | FreeBSD-ports-4f359d813ba6ad3fa4498fd25e03eb4c70f6f2e0.zip FreeBSD-ports-4f359d813ba6ad3fa4498fd25e03eb4c70f6f2e0.tar.gz |
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)
-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 321cb97c..09dbf4b 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 e2d997e..54adef5 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 eb589d4..be54c50 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 e2d997e..54adef5 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' } |