#!/bin/bash
# check root permissions
if [[ $UID != 0 ]]; then
    echo "Please start the script as root or sudo!"
    exit 1
fi

set -e

ASTERISKVERSION="16.0.0"

apt-get update
apt-get -y install autoconf build-essential libncurses5-dev libxml2-dev libsqlite3-dev libssl-dev libnewt-dev uuid-dev libjansson-dev pkg-config libedit-dev php-cli

BUILDDIR="/funbers/build/"

rm -rf $BUILDDIR
mkdir -p $BUILDDIR
cd $BUILDDIR
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-${ASTERISKVERSION}.tar.gz
tar -zxf asterisk-${ASTERISKVERSION}.tar.gz

cd asterisk-${ASTERISKVERSION}

./bootstrap.sh
./configure
make menuselect.makeopts
menuselect/menuselect --enable CORE-SOUNDS-EN-SLN16 menuselect.makeopts
menuselect/menuselect --enable codec_opus menuselect.makeopts
make -s
make install

copy_conf.sh

