Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 861435 Details for
Bug 903775
>=net-misc/asterisk-1.6.26 - init script wrapper requires bash
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
jkroon proposed diff
posixly_wrapper.diff (text/plain), 6.81 KB, created by
Jaco Kroon
on 2023-05-10 15:22:00 UTC
(
hide
)
Description:
jkroon proposed diff
Filename:
MIME Type:
Creator:
Jaco Kroon
Created:
2023-05-10 15:22:00 UTC
Size:
6.81 KB
patch
obsolete
>--- asterisk_wrapper-16.26.1-18.12.1 2022-12-08 07:42:13.752561410 +0200 >+++ /usr/sbin/asterisk_wrapper 2023-05-10 17:19:24.155602590 +0200 >@@ -1,4 +1,4 @@ >-#! /bin/bash >+#! /bin/sh > # Copyright 1999-2022 Gentoo Authors > # Distributed under the terms of the GNU General Public License v2 > >@@ -7,6 +7,9 @@ > T="$(getopt -o "h" --long "help,corecompress:,corerename:,crashemail:,dumpcore:,instance:,maxfd:,nicelevel:,restartdelay:,rundir:,syslog,tty:" -n "$progname" -- "$@")" > eval set -- "${T}" > >+# bash builtins are special ... >+echo_e="$([ "${SHELL}" = "/bin/bash" ] && echo "echo -e" || echo echo)" >+ > rundir=/run/asterisk > restartdelay=5 > nicelevel=0 >@@ -14,7 +17,7 @@ > dumpcore=0 > unset tty instance syslog corecompress corerename crashemail > >-function usage() { >+usage() { > cat <<USAGE > USAGE: $progname [options] -- asterisk options" > OPTIONS: >@@ -60,14 +63,20 @@ > USAGE > } > >+matchreg() { >+ local v=$1 >+ shift >+ echo "$v" | grep -q "$@" >+} >+ > while [ "$1" != "--" ]; do > case "$1" in > --corecompress|--corerename|--crashemail|--dumpcore|--instance|--maxfd|--nicelevel|--restartdelay|--rundir|--tty) >- eval "${1:2}=\"\${2}\"" >+ eval "${1#--}=\"\${2}\"" > shift 2 > ;; > --syslog) >- eval "${1:2}=1" >+ eval "${1#--}=1" > shift > ;; > --help|-h) >@@ -83,32 +92,52 @@ > done > shift # -- > >-ast_opts=("$@") >- >-if ! [[ "${restartdelay}" =~ ^[1-9][0-9]*$ ]]; then >+if ! matchreg "${restartdelay}" "^[1-9][0-9]*$"; then > echo "Invalid --restartdelay value ${restartdelay}, resetting to 5." >&2 > restartdelay=5 > fi > >-if [[ -n "${corecompress}" && ! -x "${corecompress}" ]]; then >+if ! matchreg "${restartdelay}" "^[1-9][0-9]*$"; then >+ echo "Invalid --maxfd value, resetting to 4096." >&2 >+ maxfd=4096 >+fi >+ >+if [ $maxfd -lt 1024 ]; then >+ echo "maxfd is guaranteed too low, bumping to at least 1024" >&2 >+ maxfd=1024 >+fi >+ >+if [ -n "${nicelevel}" ] && ! matchreg "${nicelevel}" -E "^-?[0-9]+$"; then >+ echo "Invalid --nicelevel which much be a valid integer (values from -20 to 20 makes sense)." >+ exit 1 >+fi >+ >+if [ -n "${corecompress}" -a ! -x "${corecompress}" ]; then > corecompress=$(which "${corecompress}" 2>/dev/null) >- [[ -z "${corecompress}" ]] && echo "Error locating core compression tool, disabling core compression." >&2 >+ [ -z "${corecompress}" ] && echo "Error locating core compression tool, disabling core compression." >&2 > fi > > # Before here will still be output (potentially munged, to the terminal). >-if [[ -n "${syslog}" ]]; then >- exec 1> >(logger -t "asterisk_wrapper${instance:+:}${instance}" &>/dev/null) >+if [ -n "${syslog}" ]; then >+ tdir="$(mktemp -d)" >+ tfifo="${tdir}/asterisk_wrapper.logger.fifo" >+ mkfifo "${tfifo}" >+ logger -t "asterisk_wrapper${instance:+:}${instance}" --id=$$ >/dev/null 2>&1 <"${tfifo}" & >+ exec 1>"${tfifo}" > exec 2>&1 >+ >+ rm "${tfifo}" >+ rmdir "${tdir}" > fi > > echo "Initializing ${progname}" > >-function cleanup(){ >+cleanup(){ > # There is a tiny race here, if this gets replaced inbetween the read and the rm. > # To fix this is quite complex in that we need to keep an fd, compare inode numbers > # and manage flock's. >- [[ -r "${rundir}/${progname}.pid" ]] && \ >- [[ "$(<"${rundir}/${progname}.pid")" = $$ ]] && \ >+ [ -r "${rundir}/${progname}.pid" ] && \ >+ [ "$(cat "${rundir}/${progname}.pid")" = $$ ] && \ > rm "${rundir}/${progname}.pid" > } > trap cleanup EXIT >@@ -117,37 +146,36 @@ > # it's next iteration. Towards this end, if asterisk.pid exists, attempt to find it's > # config file and request a core stop when convenient so that we can take over. > echo $$ > "${rundir}/${progname}.pid" >-if [[ -r "${rundir}/asterisk.pid" ]]; then >- ast_pid="$(<"${rundir}/asterisk.pid")" >- [[ -r "/proc/${ast_pid}/cmdline" ]] && ast_conf="$(tr '\0' '\n' < "/proc/${ast_pid}/cmdline" | grep -A1 '^-C$' | tail -n1)" && /usr/sbin/asterisk -C "${ast_conf:-/etc/asterisk/asterisk.conf}" -rx "core stop when convenient" >+if [ -r "${rundir}/asterisk.pid" ]; then >+ ast_pid="$(cat "${rundir}/asterisk.pid")" >+ [ -r "/proc/${ast_pid}/cmdline" ] && ast_conf="$(tr '\0' '\n' < "/proc/${ast_pid}/cmdline" | grep -A1 '^-C$' | tail -n1)" && /usr/sbin/asterisk -C "${ast_conf:-/etc/asterisk/asterisk.conf}" -rx "core stop when convenient" > # We may hit a few (depending on how busy the server is a great many number) loop failures still ... > fi > >-ulimit -c "${dumpcore}" >-ulimit -n "${maxfd}" >+prlimit --core=${dumpcore} >+prlimit --nofile=${maxfd} > >-ast_cmd=() >+ast_cmd=/usr/sbin/asterisk > if [ -n "${nicelevel}" ]; then >- ast_cmd+=(nice -n "${nicelevel}") >+ ast_cmd="nice -n ${nicelevel} ${ast_cmd}" > fi >-ast_cmd+=(/usr/sbin/asterisk "${ast_opts[@]}") > >-while [[ -r "${rundir}/${progname}.pid" ]]; do >+while [ -r "${rundir}/${progname}.pid" ]; do > # Another instance is looking to replace us, so terminate. >- if [[ "$(<"${rundir}/${progname}.pid")" != $$ ]]; then >+ if [ "$(cat "${rundir}/${progname}.pid")" != $$ ]; then > break > fi > >- echo "Starting asterisk with ${ast_opts[*]}" >+ echo "Starting asterisk with ${ast_cmd} $*" > if [ -n "${tty+yes}" ]; then > /bin/stty -F "${tty}" sane >- "${ast_cmd[@]}" >"${tty}" 2>&1 <"${tty}" >+ ${ast_cmd} "$@" >"${tty}" 2>&1 <"${tty}" > result=$? > else > # Purposefully leave stderr alone, this will under certain odd cases (like exceptions, > # and other odd cases logged from glibc) result in those logs at least being captured > # in syslog. >- "${ast_cmd[@]}" </dev/null >/dev/null >+ ${ast_cmd} "$@" </dev/null >/dev/null > result=$? > fi > >@@ -163,21 +191,18 @@ > > # TODO: figure out how to use /proc/sys/kernel/core_pattern here, but if someone is using > # that, chances are they're already dealing with what we want here. >- if [[ -r core ]]; then >- if [[ -n "${corerename+yes}" ]]; then >- core_target="${core_pattern}" >- core_target="${core_target//%h/"$(hostname)"}" >- core_target="${core_target//%D/"$(date +%Y%m%d)"}" >- core_target="${core_target//%T/"$(date +%H%M%S)"}" >+ if [ -r core ]; then >+ if [ -n "${corerename+yes}" ]; then >+ core_target="$(echo "${core_pattern}" | sed -e "s/%h/$(hostname)/" \ >+ -e "s/%D/$(date +%Y%m%d)/" -e "s/%T/$(date +%H%M%S)/")" > mv core "${core_target}" > core_target=$(readlink -f "${core_target}") > else > core_target=$(readlink -f core) > fi > >- if [[ -n "${corecompress}" && -x "${corecompress}" ]]; then >+ if [ -n "${corecompress}" && -x "${corecompress}" ]; then > "${corecompress}" "${core_target}" >- # TODO: Figure out a way to tag the extension onto core_target. > fi > > MSG="${MSG}\r\nCore dumped: ${core_target}" >@@ -190,8 +215,8 @@ > && echo "${MSG}" >"${tty}" \ > || echo "${MSG}" > >- if [[ -n "${crashemail+yes}" && -x /usr/sbin/sendmail ]]; then >- echo -e -n "Subject: Asterisk crashed\r\n${MSG}\r\n" |\ >+ if [ -n "${crashemail+yes}" && -x /usr/sbin/sendmail ]; then >+ $echo_e -n "Subject: Asterisk crashed\r\n${MSG}\r\n" |\ > /usr/sbin/sendmail "${crashemail}" > fi > echo "Restarting asterisk after ${restartdelay}s ..."
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 903775
:
859524
| 861435 |
861436