From fac295f9d45feee9fc004f69a431b53525c20b0c Mon Sep 17 00:00:00 2001 From: Andrius Kairiukstis Date: Fri, 16 Aug 2019 12:56:20 +0200 Subject: [PATCH] more asterisks --- .../Dockerfile | 3 +- .../docker-entrypoint.sh | 0 .../Dockerfile | 17 +++ .../build-asterisk.sh | 130 ++++++++++++++++++ .../docker-entrypoint.sh | 25 ++++ debian-jessie-slim-1.6.2.24/Dockerfile | 17 +++ debian-jessie-slim-1.6.2.24/build-asterisk.sh | 125 +++++++++++++++++ .../docker-entrypoint.sh | 25 ++++ debian-jessie-slim-1.8.32.3/Dockerfile | 16 +++ debian-jessie-slim-1.8.32.3/build-asterisk.sh | 119 ++++++++++++++++ .../docker-entrypoint.sh | 25 ++++ .../Dockerfile | 17 +++ .../build-asterisk.sh | 128 +++++++++++++++++ .../docker-entrypoint.sh | 25 ++++ 14 files changed, 671 insertions(+), 1 deletion(-) rename {alpine-3.9-15.x/alpine-3.8-15.x => alpine-3.10-16.x}/Dockerfile (92%) rename {alpine-3.9-15.x/alpine-3.8-15.x => alpine-3.10-16.x}/docker-entrypoint.sh (100%) create mode 100644 debian-buster-certified-13.21-cert4/Dockerfile create mode 100755 debian-buster-certified-13.21-cert4/build-asterisk.sh create mode 100755 debian-buster-certified-13.21-cert4/docker-entrypoint.sh create mode 100644 debian-jessie-slim-1.6.2.24/Dockerfile create mode 100755 debian-jessie-slim-1.6.2.24/build-asterisk.sh create mode 100755 debian-jessie-slim-1.6.2.24/docker-entrypoint.sh create mode 100644 debian-jessie-slim-1.8.32.3/Dockerfile create mode 100755 debian-jessie-slim-1.8.32.3/build-asterisk.sh create mode 100755 debian-jessie-slim-1.8.32.3/docker-entrypoint.sh create mode 100644 debian-stretch-certified-13.21-cert4/Dockerfile create mode 100755 debian-stretch-certified-13.21-cert4/build-asterisk.sh create mode 100755 debian-stretch-certified-13.21-cert4/docker-entrypoint.sh diff --git a/alpine-3.9-15.x/alpine-3.8-15.x/Dockerfile b/alpine-3.10-16.x/Dockerfile similarity index 92% rename from alpine-3.9-15.x/alpine-3.8-15.x/Dockerfile rename to alpine-3.10-16.x/Dockerfile index b7360ba..1a09e34 100644 --- a/alpine-3.9-15.x/alpine-3.8-15.x/Dockerfile +++ b/alpine-3.10-16.x/Dockerfile @@ -1,11 +1,12 @@ # vim:set ft=dockerfile: -FROM alpine:3.8 +FROM alpine:3.10 MAINTAINER Andrius Kairiukstis RUN apk add --update \ asterisk \ asterisk-sample-config \ +&& rm -rf /usr/lib/asterisk/modules/*pjsip* \ && asterisk -U asterisk \ && sleep 5 \ && pkill -9 asterisk \ diff --git a/alpine-3.9-15.x/alpine-3.8-15.x/docker-entrypoint.sh b/alpine-3.10-16.x/docker-entrypoint.sh similarity index 100% rename from alpine-3.9-15.x/alpine-3.8-15.x/docker-entrypoint.sh rename to alpine-3.10-16.x/docker-entrypoint.sh diff --git a/debian-buster-certified-13.21-cert4/Dockerfile b/debian-buster-certified-13.21-cert4/Dockerfile new file mode 100644 index 0000000..ee57471 --- /dev/null +++ b/debian-buster-certified-13.21-cert4/Dockerfile @@ -0,0 +1,17 @@ +# vim:set ft=dockerfile: +FROM debian:buster-slim + +LABEL maintainer="Andrius Kairiukstis " + +ENV ASTERISK_VERSION asterisk-certified-13.21-cert4 +ENV OPUS_CODEC asterisk-13.0/x86-64/codec_opus-13.0_current-x86_64 + +COPY build-asterisk.sh / +RUN /build-asterisk.sh + +EXPOSE 5060/udp 5060/tcp +VOLUME /var/lib/asterisk/sounds /var/lib/asterisk/keys /var/lib/asterisk/phoneprov /var/spool/asterisk /var/log/asterisk + +COPY docker-entrypoint.sh / +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/usr/sbin/asterisk", "-vvvdddf", "-T", "-W", "-U", "asterisk", "-p"] diff --git a/debian-buster-certified-13.21-cert4/build-asterisk.sh b/debian-buster-certified-13.21-cert4/build-asterisk.sh new file mode 100755 index 0000000..e4a789f --- /dev/null +++ b/debian-buster-certified-13.21-cert4/build-asterisk.sh @@ -0,0 +1,130 @@ +#!/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 \ + libjansson4 \ + libjansson-dev \ + libogg-dev \ + libpopt-dev \ + libresample1-dev \ + libspandsp-dev \ + libspeex-dev \ + libspeexdsp-dev \ + libsqlite3-dev \ + libsrtp2-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/certified-asterisk/releases/${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 +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 diff --git a/debian-buster-certified-13.21-cert4/docker-entrypoint.sh b/debian-buster-certified-13.21-cert4/docker-entrypoint.sh new file mode 100755 index 0000000..f1f82f4 --- /dev/null +++ b/debian-buster-certified-13.21-cert4/docker-entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# run as user asterisk by default +ASTERISK_USER=${ASTERISK_USER:-asterisk} + +if [ "$1" = "" ]; then + COMMAND="/usr/sbin/asterisk -T -W -U ${ASTERISK_USER} -p -vvvdddf" +else + COMMAND="$@" +fi + +if [ "${ASTERISK_UID}" != "" ] && [ "${ASTERISK_GID}" != "" ]; then + # recreate user and group for asterisk + # if they've sent as env variables (i.e. to macth with host user to fix permissions for mounted folders + + deluser asterisk && \ + adduser --gecos "" --no-create-home --uid ${ASTERISK_UID} --disabled-password ${ASTERISK_USER} \ + || exit +fi + +chown -R ${ASTERISK_USER}: /var/log/asterisk \ + /var/lib/asterisk \ + /var/run/asterisk \ + /var/spool/asterisk; \ +exec ${COMMAND} diff --git a/debian-jessie-slim-1.6.2.24/Dockerfile b/debian-jessie-slim-1.6.2.24/Dockerfile new file mode 100644 index 0000000..9fe00b7 --- /dev/null +++ b/debian-jessie-slim-1.6.2.24/Dockerfile @@ -0,0 +1,17 @@ +# vim:set ft=dockerfile: +FROM debian:jessie-slim + +LABEL maintainer="Andrius Kairiukstis " + +ENV ASTERISK_VERSION 1.6.2.24 +ENV ASTERISK_ADDONS_VERSION 1.6.2.4 + +COPY build-asterisk.sh / +RUN /build-asterisk.sh + +EXPOSE 5060/udp 5060/tcp +VOLUME /var/lib/asterisk/sounds /var/lib/asterisk/keys /var/lib/asterisk/phoneprov /var/spool/asterisk /var/log/asterisk + +COPY docker-entrypoint.sh / +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/usr/sbin/asterisk", "-vvvdddf", "-T", "-W", "-U", "asterisk", "-p"] diff --git a/debian-jessie-slim-1.6.2.24/build-asterisk.sh b/debian-jessie-slim-1.6.2.24/build-asterisk.sh new file mode 100755 index 0000000..cfa6e58 --- /dev/null +++ b/debian-jessie-slim-1.6.2.24/build-asterisk.sh @@ -0,0 +1,125 @@ +#!/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 \ + libjansson-dev \ + libogg-dev \ + libpopt-dev \ + libresample1-dev \ + libspandsp-dev \ + libspeex-dev \ + libspeexdsp-dev \ + libsqlite3-dev \ + libssl-dev \ + libvorbis-dev \ + libxml2-dev \ + libxslt1-dev \ + 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 \ + /usr/src/asterisk/addons + +cd /usr/src/asterisk/addons +curl -vsL http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-addons-${ASTERISK_ADDONS_VERSION}.tar.gz | tar --strip-components 1 -xz + +cd /usr/src/asterisk +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 ))} + +mkdir -p /etc/asterisk/ \ + /var/spool/asterisk/fax + +./configure --libdir=/usr/lib64 +make menuselect/menuselect menuselect-tree menuselect.makeopts + +# we don't need any sounds in docker, they will be mounted as volume +menuselect/menuselect --disable-category MENUSELECT_CORE_SOUNDS menuselect.makeopts +menuselect/menuselect --disable-category MENUSELECT_MOH menuselect.makeopts +menuselect/menuselect --disable-category MENUSELECT_EXTRA_SOUNDS menuselect.makeopts + +make -j ${JOBS} all +make install + +# copy default configs +# cp /usr/src/asterisk/configs/basic-pbx/*.conf /etc/asterisk/ +make samples +make dist-clean + +# set runuser and rungroup +sed -i -E 's/^;(run)(user|group)/\1\2/' /etc/asterisk/asterisk.conf +sed -i -e 's/# MAXFILES=/MAXFILES=/' /usr/sbin/safe_asterisk + +cd /usr/src/asterisk/addons + +./configure --libdir=/usr/lib64 +make menuselect/menuselect menuselect-tree menuselect.makeopts + +# disable saycountpl +menuselect/menuselect --disable app_saycountpl + +# enable ooh323 +menuselect/menuselect --enable chan_ooh323 menuselect.makeopts + +make -j ${JOBS} all +make install +make samples + +chown -R asterisk:asterisk /etc/asterisk \ + /var/*/asterisk \ + /usr/*/asterisk \ + /usr/lib64/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 diff --git a/debian-jessie-slim-1.6.2.24/docker-entrypoint.sh b/debian-jessie-slim-1.6.2.24/docker-entrypoint.sh new file mode 100755 index 0000000..f1f82f4 --- /dev/null +++ b/debian-jessie-slim-1.6.2.24/docker-entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# run as user asterisk by default +ASTERISK_USER=${ASTERISK_USER:-asterisk} + +if [ "$1" = "" ]; then + COMMAND="/usr/sbin/asterisk -T -W -U ${ASTERISK_USER} -p -vvvdddf" +else + COMMAND="$@" +fi + +if [ "${ASTERISK_UID}" != "" ] && [ "${ASTERISK_GID}" != "" ]; then + # recreate user and group for asterisk + # if they've sent as env variables (i.e. to macth with host user to fix permissions for mounted folders + + deluser asterisk && \ + adduser --gecos "" --no-create-home --uid ${ASTERISK_UID} --disabled-password ${ASTERISK_USER} \ + || exit +fi + +chown -R ${ASTERISK_USER}: /var/log/asterisk \ + /var/lib/asterisk \ + /var/run/asterisk \ + /var/spool/asterisk; \ +exec ${COMMAND} diff --git a/debian-jessie-slim-1.8.32.3/Dockerfile b/debian-jessie-slim-1.8.32.3/Dockerfile new file mode 100644 index 0000000..9e7fc72 --- /dev/null +++ b/debian-jessie-slim-1.8.32.3/Dockerfile @@ -0,0 +1,16 @@ +# vim:set ft=dockerfile: +FROM debian:jessie-slim + +LABEL maintainer="Andrius Kairiukstis " + +ENV ASTERISK_VERSION 1.8.32.3 + +COPY build-asterisk.sh / +RUN /build-asterisk.sh + +EXPOSE 5060/udp 5060/tcp +VOLUME /var/lib/asterisk/sounds /var/lib/asterisk/keys /var/lib/asterisk/phoneprov /var/spool/asterisk /var/log/asterisk + +COPY docker-entrypoint.sh / +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/usr/sbin/asterisk", "-vvvdddf", "-T", "-W", "-U", "asterisk", "-p"] diff --git a/debian-jessie-slim-1.8.32.3/build-asterisk.sh b/debian-jessie-slim-1.8.32.3/build-asterisk.sh new file mode 100755 index 0000000..289c3da --- /dev/null +++ b/debian-jessie-slim-1.8.32.3/build-asterisk.sh @@ -0,0 +1,119 @@ +#!/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 \ + libjansson-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 \ + 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 +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 + +# # 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 + +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 diff --git a/debian-jessie-slim-1.8.32.3/docker-entrypoint.sh b/debian-jessie-slim-1.8.32.3/docker-entrypoint.sh new file mode 100755 index 0000000..f1f82f4 --- /dev/null +++ b/debian-jessie-slim-1.8.32.3/docker-entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# run as user asterisk by default +ASTERISK_USER=${ASTERISK_USER:-asterisk} + +if [ "$1" = "" ]; then + COMMAND="/usr/sbin/asterisk -T -W -U ${ASTERISK_USER} -p -vvvdddf" +else + COMMAND="$@" +fi + +if [ "${ASTERISK_UID}" != "" ] && [ "${ASTERISK_GID}" != "" ]; then + # recreate user and group for asterisk + # if they've sent as env variables (i.e. to macth with host user to fix permissions for mounted folders + + deluser asterisk && \ + adduser --gecos "" --no-create-home --uid ${ASTERISK_UID} --disabled-password ${ASTERISK_USER} \ + || exit +fi + +chown -R ${ASTERISK_USER}: /var/log/asterisk \ + /var/lib/asterisk \ + /var/run/asterisk \ + /var/spool/asterisk; \ +exec ${COMMAND} diff --git a/debian-stretch-certified-13.21-cert4/Dockerfile b/debian-stretch-certified-13.21-cert4/Dockerfile new file mode 100644 index 0000000..5189c33 --- /dev/null +++ b/debian-stretch-certified-13.21-cert4/Dockerfile @@ -0,0 +1,17 @@ +# vim:set ft=dockerfile: +FROM debian:stretch-slim + +LABEL maintainer="Andrius Kairiukstis " + +ENV ASTERISK_VERSION asterisk-certified-13.21-cert4 +ENV OPUS_CODEC asterisk-13.0/x86-64/codec_opus-13.0_current-x86_64 + +COPY build-asterisk.sh / +RUN /build-asterisk.sh + +EXPOSE 5060/udp 5060/tcp +VOLUME /var/lib/asterisk/sounds /var/lib/asterisk/keys /var/lib/asterisk/phoneprov /var/spool/asterisk /var/log/asterisk + +COPY docker-entrypoint.sh / +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/usr/sbin/asterisk", "-vvvdddf", "-T", "-W", "-U", "asterisk", "-p"] diff --git a/debian-stretch-certified-13.21-cert4/build-asterisk.sh b/debian-stretch-certified-13.21-cert4/build-asterisk.sh new file mode 100755 index 0000000..cb389de --- /dev/null +++ b/debian-stretch-certified-13.21-cert4/build-asterisk.sh @@ -0,0 +1,128 @@ +#!/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 \ + libjansson-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 \ + 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/certified-asterisk/releases/${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 +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 diff --git a/debian-stretch-certified-13.21-cert4/docker-entrypoint.sh b/debian-stretch-certified-13.21-cert4/docker-entrypoint.sh new file mode 100755 index 0000000..f1f82f4 --- /dev/null +++ b/debian-stretch-certified-13.21-cert4/docker-entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# run as user asterisk by default +ASTERISK_USER=${ASTERISK_USER:-asterisk} + +if [ "$1" = "" ]; then + COMMAND="/usr/sbin/asterisk -T -W -U ${ASTERISK_USER} -p -vvvdddf" +else + COMMAND="$@" +fi + +if [ "${ASTERISK_UID}" != "" ] && [ "${ASTERISK_GID}" != "" ]; then + # recreate user and group for asterisk + # if they've sent as env variables (i.e. to macth with host user to fix permissions for mounted folders + + deluser asterisk && \ + adduser --gecos "" --no-create-home --uid ${ASTERISK_UID} --disabled-password ${ASTERISK_USER} \ + || exit +fi + +chown -R ${ASTERISK_USER}: /var/log/asterisk \ + /var/lib/asterisk \ + /var/run/asterisk \ + /var/spool/asterisk; \ +exec ${COMMAND}