18.13 for 3.16
This commit is contained in:
commit
f8bf26632e
|
@ -0,0 +1,14 @@
|
|||
fix for compiling with musl
|
||||
|
||||
diff -ru asterisk-12.4.0.orig/include/asterisk/lock.h asterisk-12.4.0/include/asterisk/lock.h
|
||||
--- asterisk-12.4.0.orig/include/asterisk/lock.h 2013-11-02 06:05:24.000000000 -0200
|
||||
+++ asterisk-12.4.0/include/asterisk/lock.h 2014-08-04 16:00:29.811967599 -0300
|
||||
@@ -66,7 +66,7 @@
|
||||
#define AST_PTHREADT_NULL (pthread_t) -1
|
||||
#define AST_PTHREADT_STOP (pthread_t) -2
|
||||
|
||||
-#if (defined(SOLARIS) || defined(BSD))
|
||||
+#if (defined(SOLARIS) || defined(BSD) || !defined(HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP))
|
||||
#define AST_MUTEX_INIT_W_CONSTRUCTORS
|
||||
#endif /* SOLARIS || BSD */
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
Add include file needed when compiling with musl
|
||||
|
||||
diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h
|
||||
index 8547283..476dc2a 100644
|
||||
--- a/include/asterisk/compat.h
|
||||
+++ b/include/asterisk/compat.h
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
+#include <pthread.h>
|
||||
|
||||
#ifdef HAVE_STDDEF_H
|
||||
#include <stddef.h>
|
|
@ -0,0 +1,35 @@
|
|||
Use mariadb instead of mysql
|
||||
|
||||
diff --git a/addons/cdr_mysql.c b/addons/cdr_mysql.c
|
||||
index 00c75dd..bc405bb 100644
|
||||
--- a/addons/cdr_mysql.c
|
||||
+++ b/addons/cdr_mysql.c
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "asterisk.h"
|
||||
|
||||
#include <mysql/mysql.h>
|
||||
+#include <mysql/mariadb_version.h>
|
||||
#include <mysql/errmsg.h>
|
||||
|
||||
#include "asterisk/config.h"
|
||||
@@ -648,7 +649,7 @@ static int my_load_module(int reload)
|
||||
res |= my_load_config_string(cfg, "global", "ssl_cert", &ssl_cert, "");
|
||||
res |= my_load_config_string(cfg, "global", "ssl_key", &ssl_key, "");
|
||||
|
||||
- res |= my_load_config_number(cfg, "global", "port", &dbport, MYSQL_PORT);
|
||||
+ res |= my_load_config_number(cfg, "global", "port", &dbport, MARIADB_PORT);
|
||||
res |= my_load_config_number(cfg, "global", "timeout", &timeout, 0);
|
||||
res |= my_load_config_string(cfg, "global", "compat", &compat, "no");
|
||||
res |= my_load_config_string(cfg, "global", "cdrzone", &cdrzone, "");
|
||||
diff --git a/addons/res_config_mysql.c b/addons/res_config_mysql.c
|
||||
index ae43485..94d3b35 100644
|
||||
--- a/addons/res_config_mysql.c
|
||||
+++ b/addons/res_config_mysql.c
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <mysql/mysql.h>
|
||||
+#include <mysql/mariadb_version.h>
|
||||
#include <mysql/errmsg.h>
|
||||
|
||||
#include "asterisk/channel.h"
|
|
@ -0,0 +1,22 @@
|
|||
include depreciated cdefs.h as needed for compilation with alpine
|
||||
|
||||
--- a/main/ast_expr2.c
|
||||
+++ b/main/ast_expr2.c
|
||||
@@ -95,6 +95,7 @@
|
||||
#include "asterisk.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
+#include <sys/cdefs.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(STANDALONE) || defined(STANDALONE2)
|
||||
--- a/utils/db1-ast/include/db.h
|
||||
+++ b/utils/db1-ast/include/db.h
|
||||
@@ -37,6 +37,7 @@
|
||||
#define _DB_H 1
|
||||
|
||||
#include <sys/types.h>
|
||||
+#include <sys/cdefs.h>
|
||||
|
||||
#include <limits.h>
|
||||
|
|
@ -0,0 +1,256 @@
|
|||
# Contributor: Duncan Bellamy <dunk@denkimushi.com>
|
||||
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
|
||||
# Contributor: Timo Teras <timo.teras@iki.fi>
|
||||
# Maintainer: Timo Teras <timo.teras@iki.fi>
|
||||
pkgname=asterisk
|
||||
pkgver=18.13.0
|
||||
pkgrel=0
|
||||
pkgdesc="Modular Open Source PBX System"
|
||||
pkgusers="asterisk"
|
||||
pkggroups="asterisk"
|
||||
url="https://www.asterisk.org/"
|
||||
arch="all"
|
||||
license="GPL-2.0-only WITH OpenSSL-Exception"
|
||||
options="!check" # Test suite is separate, and require separate build
|
||||
makedepends="
|
||||
alsa-lib-dev
|
||||
bluez-dev
|
||||
bsd-compat-headers
|
||||
curl-dev
|
||||
dahdi-tools-dev
|
||||
findutils
|
||||
freetds-dev
|
||||
imap-dev
|
||||
jansson-dev
|
||||
libcap-dev
|
||||
libedit-dev
|
||||
libogg-dev
|
||||
libpri-dev
|
||||
libresample
|
||||
libsrtp-dev
|
||||
libtool
|
||||
libxml2-dev
|
||||
lua-dev
|
||||
mariadb-connector-c-dev
|
||||
ncurses-dev
|
||||
newt-dev
|
||||
openssl1.1-compat-dev
|
||||
opus-dev
|
||||
opusfile-dev
|
||||
pjproject-dev
|
||||
popt-dev
|
||||
libpq-dev
|
||||
spandsp-dev
|
||||
speexdsp-dev
|
||||
speex-dev
|
||||
sqlite-dev
|
||||
tar
|
||||
tiff-dev
|
||||
unbound-dev
|
||||
unixodbc-dev
|
||||
util-linux-dev
|
||||
zlib-dev
|
||||
"
|
||||
install="$pkgname.pre-install $pkgname.pre-upgrade"
|
||||
subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-pgsql $pkgname-odbc
|
||||
$pkgname-tds $pkgname-fax $pkgname-sample-config:config:noarch
|
||||
$pkgname-sounds-moh:sound_moh:noarch $pkgname-sounds-en:sound_en:noarch
|
||||
$pkgname-mobile $pkgname-curl:_curl $pkgname-srtp $pkgname-dahdi
|
||||
$pkgname-speex $pkgname-opus $pkgname-alsa $pkgname-cdr-mysql:cdr_mysql
|
||||
$pkgname-openrc"
|
||||
|
||||
# Using commit from https://github.com/traud/asterisk-opus/commits/asterisk-13.7
|
||||
_opus_commit=90e8780faccc79e68c07775c6ab2fe1ffaccfa08
|
||||
_download="https://downloads.asterisk.org/pub/telephony/asterisk/releases"
|
||||
source="$_download/asterisk-$pkgver.tar.gz
|
||||
https://dev.alpinelinux.org/~tteras/asterisk-addon-mp3-r201.patch.gz
|
||||
asterisk-13.7-$_opus_commit.tar.gz::https://github.com/traud/asterisk-opus/archive/$_opus_commit.tar.gz
|
||||
10-musl-mutex-init.patch
|
||||
20-musl-astmm-fix.patch
|
||||
30-asterisk-mariadb.patch
|
||||
40-asterisk-cdefs.patch
|
||||
asterisk.initd
|
||||
asterisk.confd
|
||||
asterisk.logrotate
|
||||
"
|
||||
|
||||
# secfixes:
|
||||
# 18.11.2-r0:
|
||||
# - CVE-2022-26498
|
||||
# - CVE-2022-26499
|
||||
# - CVE-2022-26651
|
||||
# 18.2.2-r2:
|
||||
# - CVE-2021-32558
|
||||
# 18.2.1-r0:
|
||||
# - CVE-2021-26712
|
||||
# - CVE-2021-26713
|
||||
# - CVE-2021-26717
|
||||
# - CVE-2021-26906
|
||||
# 18.1.1-r0:
|
||||
# - CVE-2020-35652
|
||||
# - CVE-2020-35776
|
||||
# 18.0.1-r0:
|
||||
# - CVE-2020-28327
|
||||
# 16.6.2-r0:
|
||||
# - CVE-2019-18610
|
||||
# - CVE-2019-18790
|
||||
# 16.5.1-r0:
|
||||
# - CVE-2019-15297
|
||||
# - CVE-2019-15639
|
||||
# 16.4.1-r0:
|
||||
# - CVE-2019-12827
|
||||
# 16.3.0-r0:
|
||||
# - CVE-2019-7251
|
||||
# 15.7.1-r0:
|
||||
# - CVE-2018-19278
|
||||
|
||||
prepare() {
|
||||
default_prepare
|
||||
update_config_guess
|
||||
|
||||
# asteriskssl does not have direct references to libssl, but looks up
|
||||
# symbols from it using dlsym(RTLD_NEXT), so use --no-as-needed for it.
|
||||
sed -i -e 's/ASTSSL_LIBS:=$(OPENSSL_LIB)/ASTSSL_LIBS:=-Wl,--no-as-needed $(OPENSSL_LIB) -Wl,--as-needed/g' main/Makefile
|
||||
|
||||
# copy codec_opus_open_source files
|
||||
# res/* and include/asterisk/* are not needed as asterisk is new enough
|
||||
cp --verbose ../asterisk-opus*/codecs/* codecs
|
||||
}
|
||||
|
||||
build() {
|
||||
SHA1SUM="$PWD"/build_tools/sha1sum-sh ./configure \
|
||||
--build=$CBUILD \
|
||||
--host=$CHOST \
|
||||
--prefix=/usr \
|
||||
--sysconfdir=/etc \
|
||||
--mandir=/usr/share/man \
|
||||
--infodir=/usr/share/info \
|
||||
--libdir=/usr/lib \
|
||||
--localstatedir=/var \
|
||||
--disable-xmldoc \
|
||||
--enable-permanent-dlopen \
|
||||
--with-gsm=internal \
|
||||
--with-popt \
|
||||
--with-z \
|
||||
--with-newt \
|
||||
--with-unixodbc \
|
||||
--with-postgres \
|
||||
--with-tds \
|
||||
--with-dahdi \
|
||||
--with-pri \
|
||||
--with-tonezone \
|
||||
--with-resample \
|
||||
--with-sqlite3 \
|
||||
--with-speex \
|
||||
--with-asound \
|
||||
--without-x11 \
|
||||
--without-pjproject-bundled \
|
||||
--with-spandsp \
|
||||
--with-bluetooth \
|
||||
--with-libcurl \
|
||||
--with-libedit \
|
||||
--with-srtp \
|
||||
--with-imap=system \
|
||||
--with-opus \
|
||||
--with-opusfile \
|
||||
CFLAGS="$CFLAGS -DENABLE_SRTP_AES_256"
|
||||
|
||||
# get default modules to build
|
||||
rm -f menuselect.makeopts
|
||||
make menuselect.makeopts
|
||||
|
||||
# and add the non-default modules we need
|
||||
./menuselect/menuselect \
|
||||
--enable chan_mobile \
|
||||
--enable app_meetme \
|
||||
--enable cdr_mysql \
|
||||
--disable BUILD_NATIVE \
|
||||
--enable codec_opus_open_source \
|
||||
--enable app_macro \
|
||||
--enable CORE-SOUNDS-RU-ULAW \
|
||||
--enable CORE-SOUNDS-RU-ALAW \
|
||||
menuselect.makeopts
|
||||
|
||||
# build
|
||||
make LDCONFIG=
|
||||
}
|
||||
|
||||
package() {
|
||||
make DESTDIR="$pkgdir" LDCONFIG_FLAGS="-n" install
|
||||
make DESTDIR="$pkgdir" install-headers
|
||||
|
||||
install -d "$pkgdir"/var/run/asterisk
|
||||
install -d "$pkgdir"/var/lib/asterisk
|
||||
|
||||
install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
|
||||
install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
|
||||
install -m644 -D "$srcdir"/$pkgname.logrotate \
|
||||
"$pkgdir"/etc/logrotate.d/$pkgname
|
||||
|
||||
chown -R asterisk:asterisk "$pkgdir"/var/*/asterisk
|
||||
chown -R asterisk:asterisk "$pkgdir"/etc/asterisk
|
||||
chmod -R u=rwX,g=rX,o= "$pkgdir"/etc/asterisk
|
||||
|
||||
# let alpine-baselayout set permissions of /tmp
|
||||
rm -r "$pkgdir"/tmp
|
||||
}
|
||||
|
||||
dev() {
|
||||
default_dev
|
||||
depends="asterisk"
|
||||
|
||||
# move back the /usr/lib/libasteriskssl.so symlink, asterisk needs it
|
||||
# see http://bugs.alpinelinux.org/issues/6393
|
||||
mv "$subpkgdir"/usr/lib/libasteriskssl.so "$pkgdir"/usr/lib/libasteriskssl.so
|
||||
}
|
||||
|
||||
pgsql() { amove usr/lib/asterisk/modules/*_pgsql*; }
|
||||
odbc() { amove usr/lib/asterisk/modules/*_odbc*; }
|
||||
tds() { amove usr/lib/asterisk/modules/*_tds*; }
|
||||
fax() { amove usr/lib/asterisk/modules/*_fax*; }
|
||||
mobile() { amove usr/lib/asterisk/modules/*_mobile*; }
|
||||
_curl() { amove usr/lib/asterisk/modules/*_curl*; }
|
||||
cdr_mysql() { amove usr/lib/asterisk/modules/*cdr_mysql*; }
|
||||
srtp() { amove usr/lib/asterisk/modules/*_srtp*; }
|
||||
dahdi() { amove usr/lib/asterisk/modules/*_dahdi*; }
|
||||
speex() { amove usr/lib/asterisk/modules/*_speex*; }
|
||||
opus() { amove usr/lib/asterisk/modules/codec_opus_open_source.so; }
|
||||
alsa() { amove usr/lib/asterisk/modules/*_alsa*; }
|
||||
|
||||
config() {
|
||||
pkgdesc="Sample configuration files for asterisk"
|
||||
cd "$builddir"
|
||||
mkdir -p "$subpkgdir"/var/lib/asterisk/phoneprov
|
||||
make -j1 samples DESTDIR="$subpkgdir"
|
||||
|
||||
chown -R asterisk:asterisk "$subpkgdir"/var/*/asterisk
|
||||
chown -R asterisk:asterisk "$subpkgdir"/etc/asterisk
|
||||
chmod -R u=rwX,g=rX,o= "$subpkgdir"/etc/asterisk
|
||||
}
|
||||
|
||||
sound_moh() {
|
||||
pkgdesc="Default on-hold music files for asterisk"
|
||||
depends=
|
||||
amove var/lib/asterisk/moh
|
||||
chown -R asterisk:asterisk "$subpkgdir"/var/*/asterisk
|
||||
}
|
||||
|
||||
sound_en() {
|
||||
pkgdesc="English sound files for asterisk"
|
||||
depends=
|
||||
amove var/lib/asterisk/sounds/en
|
||||
chown -R asterisk:asterisk "$subpkgdir"/var/*/asterisk
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
085dfcf15f99d7d96b49a720156678c4de5a88b55375257a9a1234f9dd83f21eed1685d4177dae5978272608e690582367c6c34fdef91bbad54299594d0ce9df asterisk-18.13.0.tar.gz
|
||||
aacef3f4796fb1abd33266998b53909cb4b36e7cc5ad2f7bac68bdc43e9a9072d9a4e2e7e681bddfa31f3d04575eb248afe6ea95da780c67e4829c1e22adfe1b asterisk-addon-mp3-r201.patch.gz
|
||||
69d82b878728f99b7bf7e862025cbc01aa5b6b9332a5372059ea89a788c66fd351f1103989b3573a7a4ba9ff533f3ee2ff5d88de938440e05d6246e41a882306 asterisk-13.7-90e8780faccc79e68c07775c6ab2fe1ffaccfa08.tar.gz
|
||||
771237ba6d42ab62d914f2702234b23fd0bc8c22f2aa33b0e745c9170163c8046f6d48ecb299faab3d6fb397f1aa046421083c3cc88510c9779861c522f357dd 10-musl-mutex-init.patch
|
||||
0fae11b42894ab3d405bc50e9275b9084712b482fbf9b4259ea938667fc5cbe413655f3ff83da0f607151bb2b6e49c2f741b5ada6944dbb478f076ef8d86380a 20-musl-astmm-fix.patch
|
||||
616de74bdd3c4a6e899128c73e31f5ff219095d2afe321f85a51f518ec2e9dac9b63396eed8e2568c295f1beb90f9a506c72d28211a973b35185bfffd24af37e 30-asterisk-mariadb.patch
|
||||
ba33f11169284f190b7dabab1da7d2751cb65d7976408db635a892fa17d7552e1660350017e7aada3464ecc7d9d6e99d6ad76d66c0036de062a386cffbc948e6 40-asterisk-cdefs.patch
|
||||
0044c5db468ec8f2385d18d476f89976f6d036448583a4ef8017ce7a6f8f72105337e6b20037ffe47f561d2877fc9c86720aef23ab037df89b36dc140a5924c4 asterisk.initd
|
||||
ab6b6f08ff43268cbb1abb7ed7d678949991ba495682a644bbaeb017d6adbff0a43297905fd73ae8db1786a28d5b5904f1bc253209a0e388c8a27f26c6ce14ed asterisk.confd
|
||||
449b5808d90c813c23432274fba47e53227e3a924a55719d2f9e5a90fd2dfb33660a5c85c7e8f11fbb1cd93387e5c68329ed5583f7a64c2451fadad62a9f87dd asterisk.logrotate
|
||||
"
|
|
@ -0,0 +1,3 @@
|
|||
# Asterisk for Alpine
|
||||
|
||||
Сборка пакетов Asterisk 18.13 для Alpine 3.16 с поддержкой макросов и русскоязычных звуковых файлов.
|
|
@ -0,0 +1,91 @@
|
|||
#
|
||||
# Additional options for asterisk
|
||||
#
|
||||
# see "asterisk -h" for a list of options
|
||||
#
|
||||
ASTERISK_OPTS=""
|
||||
|
||||
#
|
||||
# User and group to run asterisk as
|
||||
#
|
||||
# Value: double-colon separated list of user and group, or empty to run as root:
|
||||
#
|
||||
#
|
||||
# "asterisk:asterisk" to run as user "asterisk" and group "asterisk"
|
||||
# "asterisk" to run as user "asterisk" and all groups that user "asterisk" is a member of
|
||||
# ":asterisk" to run as user "root" and group "asterisk"
|
||||
# "" to run as user "root" and group "root"
|
||||
#
|
||||
ASTERISK_USER="asterisk"
|
||||
|
||||
#
|
||||
# Nicelevel
|
||||
#
|
||||
# Set the priority of the asterisk process
|
||||
#
|
||||
# Value: (highest) -20..19 (lowest)
|
||||
#
|
||||
#ASTERISK_NICE="19"
|
||||
|
||||
#
|
||||
# Wrapper script
|
||||
#
|
||||
# Value: yes or no/empty
|
||||
#
|
||||
ASTERISK_WRAPPER="no"
|
||||
|
||||
############# Wrapper script settings #############
|
||||
|
||||
#
|
||||
# Send crash notifications emails to this address
|
||||
# (needs a working mail service and /usr/sbin/sendmail to do so (e.g. ssmtp))
|
||||
#
|
||||
# Value: Email address or empty to disable
|
||||
#
|
||||
#ASTERISK_NOTIFY_EMAIL="root"
|
||||
|
||||
#
|
||||
# Send asterisk's output to this terminal
|
||||
#
|
||||
# Value: Full path to device node or a number
|
||||
#
|
||||
#ASTERISK_TTY="/dev/tty9"
|
||||
|
||||
#
|
||||
# Start an asterisk console on the terminal specified by ASTERISK_TTY
|
||||
#
|
||||
# Warning! Use only for debugging, this is a potential security issue!
|
||||
#
|
||||
# Value: yes or no/empty
|
||||
#
|
||||
ASTERISK_CONSOLE="no"
|
||||
|
||||
#
|
||||
# Maximum size of core files.
|
||||
#
|
||||
# Value: Size in bytes, unlimited for no limit or empty to disable.
|
||||
#
|
||||
#ASTERISK_CORE_SIZE="unlimited"
|
||||
|
||||
#
|
||||
# ASTERISK_CORE_DIR
|
||||
#
|
||||
# Value: Directory (will be created if non-existant), default is /tmp
|
||||
#
|
||||
ASTERISK_CORE_DIR="/var/lib/asterisk/coredump"
|
||||
|
||||
#
|
||||
# Max number of filedescriptors
|
||||
#
|
||||
# Value: Number of descriptors
|
||||
#
|
||||
#ASTERISK_MAX_FD="1024"
|
||||
|
||||
#
|
||||
# Kill these tasks after asterisk crashed (ASTERISK_WRAPPER=yes only!)
|
||||
#
|
||||
# Warning! This will kill _ALL_ tasks with the specified names!
|
||||
#
|
||||
# Value: Space separated list of names in double quotes (e.g. "mpg123 mad")
|
||||
#
|
||||
#ASTERISK_CLEANUP_ON_CRASH="mpg123 asterisk-mpg123 mad"
|
|
@ -0,0 +1,252 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
extra_started_commands="forcestop reload"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
after firewall
|
||||
use nscd dns zaptel mysql postgresql slapd capi
|
||||
}
|
||||
|
||||
is_running() {
|
||||
if [ -z "$(pidof asterisk)" ]; then
|
||||
return 1
|
||||
else
|
||||
PID="$(cat /var/run/asterisk/asterisk.pid 2>/dev/null)"
|
||||
for x in $(pidof asterisk); do
|
||||
if [ "${x}" = "${PID}" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
asterisk_run_loop() {
|
||||
local OPTS ARGS MSG NICE=""
|
||||
local result=0 signal=0
|
||||
|
||||
# default options
|
||||
OPTS="-f" # don't fork / detach breaks wrapper script...
|
||||
|
||||
# filter (redundant) arguments
|
||||
ARGS="$(echo "${@}" | sed -e "s:-c\|-f::g")"
|
||||
|
||||
# mangle yes/no options
|
||||
ASTERISK_CONSOLE="$(echo ${ASTERISK_CONSOLE} | tr '[:lower:]' '[:upper:]')"
|
||||
|
||||
if [ -n "${ASTERISK_CORE_SIZE}" ] &&
|
||||
[ "${ASTERISK_CORE_SIZE}" != "0" ]; then
|
||||
ulimit -c ${ASTERISK_CORE_SIZE}
|
||||
|
||||
if [ -n "${ASTERISK_CORE_DIR}" ] && \
|
||||
[ ! -d "${ASTERISK_CORE_DIR}" ]
|
||||
then
|
||||
mkdir -m750 -p "${ASTERISK_CORE_DIR}"
|
||||
|
||||
if [ -n "${ASTERISK_USER}" ]; then
|
||||
chown -R "${ASTERISK_USER}" "${ASTERISK_CORE_DIR}"
|
||||
fi
|
||||
fi
|
||||
ASTERISK_CORE_DIR="${ASTERISK_CORE_DIR:-/tmp}"
|
||||
|
||||
cd "${ASTERISK_CORE_DIR}"
|
||||
echo " Core dump size : ${ASTERISK_CORE_SIZE}"
|
||||
echo " Core dump location : ${ASTERISK_CORE_DIR}"
|
||||
OPTS="${OPTS} -g"
|
||||
fi
|
||||
|
||||
if [ -n "${ASTERISK_MAX_FD}" ]; then
|
||||
ulimit -n ${ASTERISK_MAX_FD}
|
||||
echo " Max open filedescriptors : ${ASTERISK_MAX_FD}"
|
||||
fi
|
||||
|
||||
if [ -n "${ASTERISK_NICE}" ]; then
|
||||
echo " Nice level : ${ASTERISK_NICE}"
|
||||
NICE="nice -n ${ASTERISK_NICE} --"
|
||||
fi
|
||||
|
||||
if [ -n "${ASTERISK_NOTIFY_EMAIL}" ]; then
|
||||
if [ -x /usr/sbin/sendmail ]; then
|
||||
echo " Email notifications go to : ${ASTERISK_NOTIFY_EMAIL}"
|
||||
else
|
||||
echo " Notifications disabled, /usr/sbin/sendmail doesn't exist or is not executable!"
|
||||
unset ASTERISK_NOTIFY_EMAIL
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${ASTERISK_TTY}" ]; then
|
||||
for x in ${ASTERISK_TTY} \
|
||||
/dev/tty${ASTERISK_TTY} \
|
||||
/dev/vc/${ASTERISK_TTY}
|
||||
do
|
||||
if [ -c "${x}" ]; then
|
||||
TTY="${x}"
|
||||
fi
|
||||
done
|
||||
[ -n "${TTY}" ] && \
|
||||
echo " Messages are sent to : ${TTY}"
|
||||
fi
|
||||
|
||||
if [ "${ASTERISK_CONSOLE}" = "YES" ] && [ -n "${TTY}" ]; then
|
||||
echo " Starting Asterisk console : ${ASTERISK_CONSOLE}"
|
||||
OPTS="${OPTS} -c"
|
||||
fi
|
||||
|
||||
OPTS="${OPTS} ${ARGS}"
|
||||
|
||||
while :; do
|
||||
|
||||
if [ -n "${TTY}" ]; then
|
||||
/usr/bin/stty -F ${TTY} sane
|
||||
${NICE} /usr/sbin/asterisk ${OPTS} >${TTY} 2>&1 <${TTY}
|
||||
result=$?
|
||||
else
|
||||
${NICE} /usr/sbin/asterisk ${OPTS} &>/dev/null
|
||||
result=$?
|
||||
fi
|
||||
|
||||
if [ $result -eq 0 ]; then
|
||||
echo "Asterisk terminated normally"
|
||||
break
|
||||
else
|
||||
if [ $result -gt 128 ]; then
|
||||
signal=$((result - 128))
|
||||
MSG="Asterisk terminated with Signal: $signal"
|
||||
|
||||
CORE_TARGET="core-$(date "+%Y%m%d-%h%M%s")"
|
||||
|
||||
local CORE_DUMPED=0
|
||||
if [ -f "${ASTERISK_CORE_DIR}/core" ]; then
|
||||
mv "${ASTERISK_CORE_DIR}/core" \
|
||||
"${ASTERISK_CORE_DIR}/${CORE_TARGET}"
|
||||
CORE_DUMPED=1
|
||||
|
||||
elif [ -f "${ASTERISK_CORE_DIR}/core.${PID}" ]; then
|
||||
mv "${ASTERISK_CORE_DIR}/core.${PID}" \
|
||||
"${ASTERISK_CORE_DIR}/${CORE_TARGET}"
|
||||
CORE_DUMPED=1
|
||||
|
||||
fi
|
||||
|
||||
[ $CORE_DUMPED -eq 1 ] && \
|
||||
MSG="${MSG}\n\rCore dumped: ${ASTERISK_CORE_DIR}/${CORE_TARGET}"
|
||||
else
|
||||
MSG="Asterisk terminated with return code: $result"
|
||||
fi
|
||||
|
||||
# kill left-over tasks
|
||||
for X in ${ASTERISK_CLEANUP_ON_CRASH}; do
|
||||
kill -9 $(pidof ${X});
|
||||
done
|
||||
fi
|
||||
|
||||
[ -n "${TTY}" ] \
|
||||
&& echo "${MSG}" >${TTY} \
|
||||
|| echo "${MSG}"
|
||||
|
||||
|
||||
if [ -n "${ASTERISK_NOTIFY_EMAIL}" ] && \
|
||||
[ -x /usr/sbin/sendmail ]; then
|
||||
echo -e -n "Subject: Asterisk crashed\n\r${MSG}\n\r" |\
|
||||
/usr/sbin/sendmail "${ASTERISK_NOTIFY_EMAIL}"
|
||||
fi
|
||||
sleep 5
|
||||
echo "Restarting Asterisk..."
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
start() {
|
||||
local OPTS USER GROUP PID
|
||||
local tmp x
|
||||
|
||||
if [ -n "${ASTERISK_NICE}" ]; then
|
||||
if [ ${ASTERISK_NICE} -ge -20 ] && \
|
||||
[ ${ASTERISK_NICE} -le 19 ]; then
|
||||
OPTS="--nicelevel ${ASTERISK_NICE}"
|
||||
else
|
||||
eerror "Nice value must be between -20 and 19"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${ASTERISK_USER}" ]; then
|
||||
USER=$(echo $ASTERISK_USER | sed 's/:.*//')
|
||||
GROUP=$(echo $ASTERISK_USER | awk -F: '/.*:.*/ { print $2 }')
|
||||
if [ -n "${USER}" ]; then
|
||||
ASTERISK_OPTS="${ASTERISK_OPTS} -U ${USER}"
|
||||
fi
|
||||
if [ -n "${GROUP}" ]; then
|
||||
ASTERISK_OPTS="${ASTERISK_OPTS} -G ${GROUP}"
|
||||
GROUP=":${GROUP}" # make it look nice...
|
||||
fi
|
||||
ebegin "Starting asterisk PBX (as ${USER}${GROUP})"
|
||||
else
|
||||
ebegin "Starting asterisk PBX (as root)"
|
||||
fi
|
||||
|
||||
if [ "$(echo ${ASTERISK_WRAPPER} | tr '[:upper:]' '[:lower:]')" != "yes" ]; then
|
||||
start-stop-daemon --start --exec /usr/sbin/asterisk \
|
||||
${OPTS} -- ${ASTERISK_OPTS}
|
||||
result=$?
|
||||
else
|
||||
asterisk_run_loop ${ASTERISK_OPTS} 2>/dev/null &
|
||||
result=$?
|
||||
fi
|
||||
|
||||
if [ $result -eq 0 ]; then
|
||||
# 2 seconds should be enough for asterisk to start
|
||||
sleep 2
|
||||
is_running
|
||||
result=$?
|
||||
fi
|
||||
|
||||
eend $result
|
||||
}
|
||||
|
||||
forcestop() {
|
||||
ebegin "Stopping asterisk PBX"
|
||||
start-stop-daemon --stop --pidfile /var/run/asterisk/asterisk.pid
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
if ! is_running; then
|
||||
eerror "Asterisk is not running!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
ebegin "Stopping asterisk PBX now"
|
||||
/usr/sbin/asterisk -r -x "core stop now" &>/dev/null
|
||||
# Now we have to wait until asterisk has _really_ stopped.
|
||||
sleep 1
|
||||
if is_running; then
|
||||
einfon "Waiting for asterisk to shutdown ."
|
||||
local cnt=0
|
||||
while is_running; do
|
||||
cnt=`expr $cnt + 1`
|
||||
if [ $cnt -gt 60 ] ; then
|
||||
# Waited 120 seconds now. Fail.
|
||||
echo
|
||||
eend 1 "Failed."
|
||||
return
|
||||
fi
|
||||
sleep 2
|
||||
echo -n "."
|
||||
done
|
||||
echo
|
||||
fi
|
||||
eend 0
|
||||
}
|
||||
|
||||
reload() {
|
||||
if is_running; then
|
||||
ebegin "Reloading asterisk configuration"
|
||||
/usr/sbin/asterisk -r -x "core reload" &>/dev/null
|
||||
eend $?
|
||||
else
|
||||
eerror "Asterisk is not running!"
|
||||
fi
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/var/log/asterisk/messages /var/log/asterisk/*log {
|
||||
missingok
|
||||
rotate 5
|
||||
weekly
|
||||
create 0644 asterisk asterisk
|
||||
postrotate
|
||||
/usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
|
||||
endscript
|
||||
}
|
||||
|
||||
/var/log/asterisk/cdr-csv/*csv {
|
||||
missingok
|
||||
rotate 5
|
||||
monthly
|
||||
create 0640 asterisk asterisk
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
addgroup -S asterisk 2>/dev/null
|
||||
adduser -S -D -h /var/lib/asterisk -s /sbin/nologin -G asterisk -g asterisk asterisk 2>/dev/null
|
||||
addgroup -S dialout 2>/dev/null
|
||||
addgroup asterisk dialout 2>/dev/null
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
addgroup -S asterisk 2>/dev/null
|
||||
adduser -S -D -h /var/lib/asterisk -s /sbin/nologin -G asterisk -g asterisk asterisk 2>/dev/null
|
||||
addgroup -S dialout 2>/dev/null
|
||||
addgroup asterisk dialout 2>/dev/null
|
||||
|
||||
exit 0
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue