Skip to content

Instantly share code, notes, and snippets.

@cachenow
Forked from kolosek/asterisk.sh
Created June 9, 2024 16:42
Show Gist options
  • Save cachenow/73e48b83c04db7a9d49ce9d7c05669fe to your computer and use it in GitHub Desktop.
Save cachenow/73e48b83c04db7a9d49ce9d7c05669fe to your computer and use it in GitHub Desktop.

Revisions

  1. @kolosek kolosek revised this gist May 28, 2024. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions asterisk.sh
    Original file line number Diff line number Diff line change
    @@ -13,11 +13,11 @@ sudo apt update && sudo apt -y install subversion
    # sudo apt policy asterisk
    #cd /usr/src/
    cd ~
    sudo curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-17-current.tar.gz
    sudo curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz

    #Extract the file
    tar xvf asterisk-17-current.tar.gz
    cd asterisk-17*/
    tar xvf asterisk-20-current.tar.gz
    cd asterisk-20*/

    #download the mp3 decoder library
    sudo contrib/scripts/get_mp3_source.sh
  2. @kolosek kolosek revised this gist May 23, 2020. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions asterisk.sh
    Original file line number Diff line number Diff line change
    @@ -131,3 +131,15 @@ same = n,Wait(1)
    same = n,Playback(hello-world)
    same = n,Hangup()


    #Troubleshooting

    Problem: # *reference: https://www.clearhat.org/2019/04/12/a-fix-for-apt-install-asterisk-on-ubuntu-18-04/
    radcli: rc_read_config: rc_read_config: can't open /etc/radiusclient-ng/radiusclient.conf: No such file or directory
    Fix:
    sed -i 's";\[radius\]"\[radius\]"g' /etc/asterisk/cdr.conf
    sed -i 's";radiuscfg => /usr/local/etc/radiusclient-ng/radiusclient.conf"radiuscfg => /etc/radcli/radiusclient.conf"g' /etc/asterisk/cdr.conf
    sed -i 's";radiuscfg => /usr/local/etc/radiusclient-ng/radiusclient.conf"radiuscfg => /etc/radcli/radiusclient.conf"g' /etc/asterisk/cel.conf
  3. @kolosek kolosek revised this gist May 23, 2020. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions asterisk.sh
    Original file line number Diff line number Diff line change
    @@ -11,12 +11,13 @@ sudo apt update && sudo apt -y install subversion

    #Download Asterisk 16 LTS tarball
    # sudo apt policy asterisk
    cd /usr/src/
    sudo curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
    #cd /usr/src/
    cd ~
    sudo curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-17-current.tar.gz

    #Extract the file
    sudo tar xvf asterisk-16-current.tar.gz
    cd asterisk-16*/
    tar xvf asterisk-17-current.tar.gz
    cd asterisk-17*/

    #download the mp3 decoder library
    sudo contrib/scripts/get_mp3_source.sh
  4. @kolosek kolosek revised this gist May 23, 2020. 1 changed file with 49 additions and 0 deletions.
    49 changes: 49 additions & 0 deletions asterisk.sh
    Original file line number Diff line number Diff line change
    @@ -81,3 +81,52 @@ sudo asterisk -rvv
    sudo ufw allow proto tcp from any to any port 5060,5061


    ### CONFIGURE SIP###

    sudo vim /etc/asterisk/pjsip.conf

    [transport-udp]
    type=transport
    protocol=udp
    bind=0.0.0.0

    [7000]
    type=endpoint
    context=from-internal
    disallow=all
    allow=ulaw
    auth=7000
    aors=7000

    [7000]
    type=auth
    auth_type=userpass
    password=password
    username=7000

    [7000]
    type=aor
    max_contacts=1

    sudo vim /etc/asterisk/sip.conf

    [general]
    context=default

    [6001]
    type=friend
    context=from-internal
    host=dynamic
    secret=unsecurepassword
    disallow=all
    allow=ulaw


    sudo vim /etc/asterisk/extensions.conf

    [from-internal]
    exten = 100,1,Answer()
    same = n,Wait(1)
    same = n,Playback(hello-world)
    same = n,Hangup()

  5. @linuxoracledev linuxoracledev revised this gist Jan 12, 2020. No changes.
  6. @linuxoracledev linuxoracledev created this gist Jan 12, 2020.
    83 changes: 83 additions & 0 deletions asterisk.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,83 @@
    #Update system & reboot
    sudo apt update && sudo apt -y upgrade
    sudo reboot

    #Install Asterisk 16 LTS dependencies
    sudo apt -y install git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev uuid-dev

    #Add universe repository and install subversio
    sudo add-apt-repository universe
    sudo apt update && sudo apt -y install subversion

    #Download Asterisk 16 LTS tarball
    # sudo apt policy asterisk
    cd /usr/src/
    sudo curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz

    #Extract the file
    sudo tar xvf asterisk-16-current.tar.gz
    cd asterisk-16*/

    #download the mp3 decoder library
    sudo contrib/scripts/get_mp3_source.sh

    #Ensure all dependencies are resolved
    sudo contrib/scripts/install_prereq install

    #Run the configure script to satisfy build dependencies
    sudo ./configure

    #Setup menu options by running the following command:
    sudo make menuselect

    #Use arrow keys to navigate, and Enter key to select. On Add-ons select chan_ooh323 and format_mp3 .
    #On Core Sound Packages, select the formats of Audio packets. Music On Hold, select 'Music onhold file package'
    # select Extra Sound Packages
    #Enable app_macro under Applications menu
    #Change other configurations as required

    #build Asterisk
    sudo make

    #Install Asterisk by running the command:
    sudo make install

    #Install documentation(Optionally)
    sudo make progdocs

    #Install configs and samples
    sudo make samples
    sudo make config

    #Create a separate user and group to run asterisk services, and assign correct permissions:
    sudo groupadd asterisk
    sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk
    sudo usermod -aG audio,dialout asterisk
    sudo chown -R asterisk.asterisk /etc/asterisk
    sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
    sudo chown -R asterisk.asterisk /usr/lib/asterisk

    #Set Asterisk default user to asterisk:
    sudo vim /etc/default/asterisk

    # AST_USER="asterisk"
    # AST_GROUP="asterisk"
    # sudo ldconfig

    sudo vim /etc/asterisk/asterisk.conf
    # runuser = asterisk ; The user to run as.
    # rungroup = asterisk ; The group to run as.

    #Restart asterisk service
    sudo systemctl restart asterisk

    #Enable asterisk service to start on system boot
    sudo systemctl enable asterisk

    #Test to see if it connect to Asterisk CLI
    sudo asterisk -rvv

    #open http ports and ports 5060,5061 in ufw firewall
    sudo ufw allow proto tcp from any to any port 5060,5061