Add Opus codec, show management info after Asterisk startup

- Install Digium precompiled codec_opus.so in Docker image since Ubuntu
  24.04's asterisk-modules package doesn't include it (bug #2044135).
  Opus is the best codec for mobile VoIP (adaptive bitrate, packet loss
  resilience).
- Rework entrypoint to print the management info banner AFTER Asterisk
  finishes loading, so the CLI command isn't buried in startup log noise.
  The management command is now highlighted in yellow.
- Remove explicit load directive for codec_opus.so from modules.conf;
  autoload=yes handles it when the .so exists, and silently skips when
  it doesn't (no more error log noise on systems without Opus).

https://claude.ai/code/session_01Vm6NLaQuzM4VosAotqS1q8
This commit is contained in:
Claude
2026-02-24 17:05:22 +00:00
parent 06c75371d0
commit 8405238fa1
2 changed files with 32 additions and 3 deletions
+15
View File
@@ -24,6 +24,7 @@ RUN echo "exit 101" > /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d &&
asterisk-modules \
openssl \
curl \
wget \
tcpdump \
sngrep \
python3 \
@@ -38,6 +39,20 @@ RUN echo "exit 101" > /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d &&
&& ldconfig \
&& update-ca-certificates 2>/dev/null || true
# Install Opus codec (not included in Ubuntu 24.04 asterisk-modules, bug #2044135)
# Download Digium's precompiled codec_opus for Asterisk 20 (Ubuntu 24.04 ships Asterisk 20)
RUN MODULES_DIR=$(find /usr/lib -type d -name modules -path "*/asterisk/*" | head -1) && \
if [ -z "$MODULES_DIR" ]; then MODULES_DIR="/usr/lib/x86_64-linux-gnu/asterisk/modules"; fi && \
mkdir -p "$MODULES_DIR" /var/lib/asterisk/documentation/thirdparty && \
cd /tmp && \
wget -q "http://downloads.digium.com/pub/telephony/codec_opus/asterisk-20.0/x86-64/codec_opus-20.0_1.3.0-x86_64.tar.gz" -O codec_opus.tar.gz && \
tar -xzf codec_opus.tar.gz && \
find /tmp -name "codec_opus.so" -exec cp {} "$MODULES_DIR/" \; && \
find /tmp -name "format_ogg_opus.so" -exec cp {} "$MODULES_DIR/" \; && \
find /tmp -name "codec_opus_config-en_US.xml" -exec cp {} /var/lib/asterisk/documentation/thirdparty/ \; && \
rm -rf /tmp/codec_opus* && \
echo "Opus codec installed to $MODULES_DIR"
# Create required directories
RUN mkdir -p \
/etc/easy-asterisk \
+17 -3
View File
@@ -308,7 +308,6 @@ load => chan_pjsip.so
load => codec_ulaw.so
load => codec_alaw.so
load => codec_g722.so
load => codec_opus.so
load => res_rtp_asterisk.so
load => app_dial.so
load => app_page.so
@@ -339,6 +338,20 @@ trap cleanup SIGTERM SIGINT
# ── 12. Start Asterisk ───────────────────────────────────────
log_info "Starting Asterisk PBX..."
echo ""
# Start Asterisk in the background, then print management info once ready
asterisk -f -U asterisk -G asterisk &
ASTERISK_PID=$!
# Wait for Asterisk to be ready (up to 60 seconds)
for i in $(seq 1 60); do
if asterisk -rx "core show version" >/dev/null 2>&1; then
break
fi
sleep 1
done
echo ""
echo -e "${CYAN}══════════════════════════════════════════════════════════════${NC}"
echo -e "${CYAN} Easy Asterisk (Docker)${NC}"
@@ -352,9 +365,10 @@ echo -e "${CYAN}─────────────────────
echo -e " SIP clients connect to: ${GREEN}${DOMAIN_NAME:-$local_ip}:5061${NC} (TLS)"
echo -e " Web Admin: ${GREEN}http://${local_ip}:${WEB_ADMIN_PORT:-8080}/clients${NC}"
echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}"
echo -e " Management: docker exec -it easy-asterisk easy-asterisk"
echo -e " Management: ${YELLOW}docker exec -it easy-asterisk easy-asterisk${NC}"
echo -e " Diagnostics: docker exec -it easy-asterisk vpn-diagnostics"
echo -e "${CYAN}══════════════════════════════════════════════════════════════${NC}"
echo ""
exec asterisk -f -U asterisk -G asterisk
# Wait for Asterisk process (keeps container running)
wait $ASTERISK_PID