133 lines
3.6 KiB
Bash
Executable File
133 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
PROGNAME=$(basename $0)
|
|
|
|
if test -z ${ASTERISK_VERSION}; then
|
|
echo "${PROGNAME}: ASTERISK_VERSION required" >&2
|
|
exit 1
|
|
fi
|
|
|
|
set -ex
|
|
|
|
useradd --system asterisk
|
|
|
|
apt-get update -qq
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests \
|
|
autoconf \
|
|
binutils-dev \
|
|
build-essential \
|
|
ca-certificates \
|
|
curl \
|
|
file \
|
|
libcurl4-openssl-dev \
|
|
libedit-dev \
|
|
libgsm1-dev \
|
|
libogg-dev \
|
|
libpopt-dev \
|
|
libresample1-dev \
|
|
libspandsp-dev \
|
|
libspeex-dev \
|
|
libspeexdsp-dev \
|
|
libsqlite3-dev \
|
|
libsrtp0-dev \
|
|
libssl-dev \
|
|
libvorbis-dev \
|
|
libxml2-dev \
|
|
libxslt1-dev \
|
|
procps \
|
|
portaudio19-dev \
|
|
unixodbc \
|
|
unixodbc-bin \
|
|
unixodbc-dev \
|
|
odbcinst \
|
|
uuid \
|
|
uuid-dev \
|
|
xmlstarlet
|
|
|
|
apt-get purge -y --auto-remove
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
mkdir -p /usr/src/asterisk
|
|
cd /usr/src/asterisk
|
|
|
|
curl -vsL http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-${ASTERISK_VERSION}.tar.gz | tar --strip-components 1 -xz || \
|
|
curl -vsL http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-${ASTERISK_VERSION}.tar.gz | tar --strip-components 1 -xz || \
|
|
curl -vsL http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-${ASTERISK_VERSION}.tar.gz | tar --strip-components 1 -xz
|
|
|
|
# 1.5 jobs per core works out okay
|
|
: ${JOBS:=$(( $(nproc) + $(nproc) / 2 ))}
|
|
|
|
./configure --with-resample \
|
|
--with-pjproject-bundled \
|
|
--with-jansson-bundled
|
|
make menuselect/menuselect menuselect-tree menuselect.makeopts
|
|
|
|
# disable BUILD_NATIVE to avoid platform issues
|
|
menuselect/menuselect --disable BUILD_NATIVE menuselect.makeopts
|
|
|
|
# enable good things
|
|
menuselect/menuselect --enable BETTER_BACKTRACES menuselect.makeopts
|
|
|
|
# codecs
|
|
# menuselect/menuselect --enable codec_opus menuselect.makeopts
|
|
# menuselect/menuselect --enable codec_silk menuselect.makeopts
|
|
|
|
# # download more sounds
|
|
# for i in CORE-SOUNDS-EN MOH-OPSOUND EXTRA-SOUNDS-EN; do
|
|
# for j in ULAW ALAW G722 GSM SLN16; do
|
|
# menuselect/menuselect --enable $i-$j menuselect.makeopts
|
|
# done
|
|
# done
|
|
|
|
# we don't need any sounds in docker, they will be mounted as volume
|
|
menuselect/menuselect --disable-category MENUSELECT_CORE_SOUNDS
|
|
menuselect/menuselect --disable-category MENUSELECT_MOH
|
|
menuselect/menuselect --disable-category MENUSELECT_EXTRA_SOUNDS
|
|
|
|
make -j ${JOBS} all
|
|
make install
|
|
|
|
# copy default configs
|
|
# cp /usr/src/asterisk/configs/basic-pbx/*.conf /etc/asterisk/
|
|
make samples
|
|
|
|
# set runuser and rungroup
|
|
sed -i -E 's/^;(run)(user|group)/\1\2/' /etc/asterisk/asterisk.conf
|
|
|
|
# Install opus, for some reason menuselect option above does not working
|
|
mkdir -p /usr/src/codecs/opus \
|
|
&& cd /usr/src/codecs/opus \
|
|
&& curl -vsL http://downloads.digium.com/pub/telephony/codec_opus/${OPUS_CODEC}.tar.gz | tar --strip-components 1 -xz \
|
|
&& cp *.so /usr/lib/asterisk/modules/ \
|
|
&& cp codec_opus_config-en_US.xml /var/lib/asterisk/documentation/
|
|
|
|
mkdir -p /etc/asterisk/ \
|
|
/var/spool/asterisk/fax
|
|
|
|
chown -R asterisk:asterisk /etc/asterisk \
|
|
/var/*/asterisk \
|
|
/usr/*/asterisk
|
|
chmod -R 750 /var/spool/asterisk
|
|
|
|
cd /
|
|
rm -rf /usr/src/asterisk \
|
|
/usr/src/codecs
|
|
|
|
# remove *-dev packages
|
|
devpackages=`dpkg -l|grep '\-dev'|awk '{print $2}'|xargs`
|
|
DEBIAN_FRONTEND=noninteractive apt-get --yes purge \
|
|
autoconf \
|
|
build-essential \
|
|
bzip2 \
|
|
cpp \
|
|
m4 \
|
|
make \
|
|
patch \
|
|
perl \
|
|
perl-modules \
|
|
pkg-config \
|
|
xz-utils \
|
|
${devpackages}
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
exec rm -f /build-asterisk.sh
|