From c3757839e2b02d58e4125fe9627313da37aacbc5 Mon Sep 17 00:00:00 2001 From: Loren Moore Date: Fri, 12 Aug 2022 01:47:49 -0400 Subject: [PATCH] Initial Commit --- README.md | 14 ++++++++++++++ musiconholdstream.sh | 16 ++++++++++++++++ userwizard.sh | 22 ++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 README.md create mode 100644 musiconholdstream.sh create mode 100644 userwizard.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..870bc47 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Asterisk Bash Scripts + +A collection of shell scripts to use with Asterisk. + + +## About + +This is a small collection of scripts I've written for vario + +- userwizard.sh: Write a new user to pjsip.conf from ID, password, and context +- mohstream.sh: Contains both the icecast/mplayer and ogg123/sox varients. + +- userwizard.sh needs to be run as root. +- mohstream.sh is called as custom application from musiconhold.conf diff --git a/musiconholdstream.sh b/musiconholdstream.sh new file mode 100644 index 0000000..1e7357f --- /dev/null +++ b/musiconholdstream.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +### USE THIS SECTION FOR THE PREFERRED METHOD WITH ICECAST/ICES ### + +PIPE="/tmp/asterisk-pipe.$$" +mknod $PIPE p +mplayer -playlist http://host:port/mount.ogg.m3u -really-quiet -quiet -ao pcm:file=$PIPE -af resample=8000,pan=1:0.5:0.5,channels=1,format=mulaw 2>/dev/null | cat $PIPE 2>/dev/null +rm $PIPE + + +### THIS IS THE MORE INTENSIVE OGG123/SOX VERSION ### + +#ogg123 -qZ -d pulse -o sink:moh1 -d au -f - -@ /etc/asterisk/list.m3u 2>/dev/null | sox -r 16000 -t au - -r 8000 -c 1 -t raw - 2>/dev/null + +# I really can't stress how much this version isn't that great. It's CPU intensive and requires pulseaudio and a bunch of other junk. +# Seriously; this uses a stupid amount of processor to get the job done. \ No newline at end of file diff --git a/userwizard.sh b/userwizard.sh new file mode 100644 index 0000000..bbff87e --- /dev/null +++ b/userwizard.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ "$EUID" -ne 0 ] + then echo "Please run as root" + exit +fi + +pjsip() { +printf "\n\n[$ID]\ntype=endpoint\ncontext=$CONTEXT\ndisallow=all\nallow=ulaw\nallow=alaw\nallow=g722\nauth=$ID\naors=$ID\n\n" +printf "[$ID]\ntype=auth\nauth_type=userpass\npassword=$PASSWORD\nusername=$ID\n\n[$ID]\ntype=aor\nmax_contacts=3" +} >> /etc/asterisk/pjsip.conf + +printf "Asterisk PJSIP User Wizard - Quick-N-Dirty (Like your mom!)\n\n" +printf "Enter User ID: " +read ID +printf "Enter default context: " +read CONTEXT +printf "Auth Password: " +read PASSWORD + + +pjsip; \ No newline at end of file