simple freepbx installation script

N

niv

Guest
here is this simple small script I wrote to install freepbx, it follows the defaults according to the installation instructions:

Code:
#!/bin/bash
#install freepbx from source
set -e

install_zaptel() {
    wget http://downloads.asterisk.org/pub/telephony/zaptel/zaptel-1.4.12.1.tar.gz
    tar xf zaptel-1.4.12.1.tar.gz
    cd /usr/src/zaptel-1.4.12.1
    ./configure
    make
    make install 
    mv /etc/default/zaptel /etc/default/zaptel.original
}

install_dahdi() {
    pushd /usr/src
    wget http://192.168.0.1/netinstall/dahdi-linux-complete-current.tar.gz
    if ! [ -f dahdi-linux-complete-current.tar.gz ] ; then
    wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
    fi
    tar xf dahdi-linux-complete-current.tar.gz
    cd dahdi-linux-complete*
    make
    make install
    make config
    popd
}
install_libpri() {
    pushd /usr/src
    wget http://192.168.0.1/netinstall/libpri-current.tar.gz
    if ! [ -f libpri-current.tar.gz ] ; then
    wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4.11.1.tar.gz
    fi
    tar xf libpri*
    cd /usr/src/libpri*
    make
    make install
    popd
}
install_asterisk() {
    pushd /usr/src
    groupadd asterisk 
    useradd -c "asterisk PBX" -d /var/lib/asterisk -g asterisk asterisk 
    mkdir /var/run/asterisk 
    chown asterisk:asterisk /var/run/asterisk
    wget http://192.168.0.1/netinstall/asterisk-current.tar.gz
    if ! [ -f asterisk-current.tar.gz ] ; then
        wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-current.tar.gz
    fi
    tar xf asterisk-*
    cd /usr/src/asterisk*
    ./configure
    make
    make install
    popd
}
install_asterisk_addons() {
    pushd /usr/src
    wget http://192.168.0.1/netinstall/asterisk-addons-current.tar.gz
    if ! [ -f asterisk-addons-current.gz ] ; then 
    wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-addons-current.tar.gz
    fi
    tar xf asterisk-addons-*
    cd /usr/src/asterisk-addons*
    perl -p -i.bak -e 's/CFLAGS.*D_GNU_SOURCE/CFLAGS+=-D_GNU_SOURCE\nCFLAGS+=-DMYSQL_LOGUNIQUEID/' Makefile
    ./configure
    make clean 
    make
    make install
    popd
}
install_asterisk_sounds() {
    cd /usr/src/asterisk-1.*/sounds
    make install
}
install_freepbx(){
    pushd /usr/src
    wget http://192.168.0.1/netinstall/freepbx-2.6.0.tar.gz
    if ! [ -f freepbx-2.6.0.tar.gz ] ; then
    wget http://mirror.freepbx.org/freepbx-2.6.0.tar.gz
    fi
    tar xf freepbx-*
    /bin/rm freepbx-*
    pgrep mysql 2>&1 || service mysqld start
    mysqladmin -u root password 'passw0rd'
    mysqladmin create asteriskcdrdb -ppassw0rd
    mysql --user=root --password=passw0rd asteriskcdrdb < /usr/src/freepbx-2.6.0/SQL/cdr_mysql_table.sql
    mysqladmin create asterisk -ppassw0rd
    mysql --user=root --password=passw0rd asterisk < /usr/src/freepbx-2.6.0/SQL/newinstall.sql
        mysql --user=root --password=passw0rd -e"GRANT ALL PRIVILEGES ON asterisk.* TO 'asteriskuser'@'localhost' IDENTIFIED BY 'amp109'"
        mysql --user=root --password=passw0rd -e"GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO 'asteriskuser'@'localhost' IDENTIFIED BY 'amp109'"
    mysql --user=root --password=passw0rd -e"flush privileges"
    cd freepbx*
    asterisk -c &
    #./install_amp --dbhost localhost --dbname asterisk --username asteriskuser --password passw0rd --fopwebroot /var/www/html/panel --webroot /var/www/html --cgibin /var/www/cgi-bin --bin /var/lib/asterisk/bin --sbin /usr/local/sbin --asteriskuser admin --asteriskpass amp111 --engine asterisk
    /bin/cp freepbx-*/amportal.conf /etc
    sed -i 's/^User.*/User asterisk/' /etc/httpd/conf/httpd.conf
    sed -i 's/^Group.*/Group asterisk/' /etc/httpd/conf/httpd.conf
    chown asterisk /var/lib/php/session
    pkill -9 asterisk
    popd
}

#main

echo "installation script"
cd /usr/src
install_dahdi
install_libpri
install_asterisk
install_asterisk_addons
install_asterisk_sounds
install_freepbx
chkconfig httpd on
chkconfig mysqld on
service httpd restart
amportal start

the idea is to download the packages to the server at 192.168.0.1 and run the install from there.

Niv
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!