Skip to content

Instantly share code, notes, and snippets.

@yumminova
Created January 7, 2020 17:47
Show Gist options
  • Save yumminova/6c9f8928df1fd597e94a59528b9d1cc4 to your computer and use it in GitHub Desktop.
Save yumminova/6c9f8928df1fd597e94a59528b9d1cc4 to your computer and use it in GitHub Desktop.
Install a working Kazoo Installation
#!/bin/bash
# Change the following Parametrs for your setup
#Common Params
export IP="xxx.xxx.xxx.xxx"
export HOST="somehost"
export DOMAIN="somedomain.com"
export FQDN="$HOST.$DOMAIN"
export MASTER_ACCOUNT="CompanyName"
export M_ACCOUNT_USER="User"
export M_ACCOUNT_PASS="changeme"
if [ -z "$IP" ]
then
echo "Guessing our external IP address (if guess is wrong please export IP variable, this is important)..."
echo ""
IP=$(curl -s ipinfo.io/ip)
echo "External IP address: $IP"
echo ""
read -rsn1 -p"Press any key to continue";echo
fi
echo ""
echo "--------------- Settings -----------------"
echo "IP : $IP"
echo "HOST : $HOST"
echo "DOMAIN : $DOMAIN"
echo "FQDN : $FQDN"
echo ""
echo "MASTER_ACCOUNT : $MASTER_ACCOUNT"
echo "M_ACCOUNT_USER : $M_ACCOUNT_USER"
echo "M_ACCOUNT_PASS : $M_ACCOUNT_PASS"
echo ""
read -rsn1 -p"Press any key to start installation";echo
echo ""
echo "Updating ..."
yum -y -q update
echo "Installing basic tools ..."
yum install -y install wget gdb yum-utils epel-release nano net-tools wget nano
#hostname and hostname -f should return a fqdn
hostnamectl set-hostname $FQDN
hostname $FQDN
> /etc/hosts
echo "::1 localhost.local $FQDN localhost "
echo "::1 localhost6.local $FQDN6 localhost6 "
echo "::1 $FQDN $HOST"
echo "127.0.0.1 $FQDN $HOST" >> /etc/hosts
echo "$IP $FQDN $HOST" >> /etc/hosts
echo "$FQDN" > /etc/hostname
chattr +i /etc/hostname
echo "Temporarily disabling iptables ... "
#Disable Selinus
sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config
systemctl disable firewalld
systemctl disable iptables
systemctl stop firewalld
systemctl stop iptables
echo "Installing NTP client ..."
#Install NTP client
yum -y -q install ntp
systemctl enable ntpd
systemctl restart ntpd
timedatectl set-timezone UTC
#This is the source i used, change as needed.
cd /usr/src
wget --no-check-certificate https://packages.2600hz.com/centos/7/stable/2600hz-release/4.0/2600hz-release-4.0-3.el7.centos.noarch.rpm
rpm -Uvh 2600hz-release-4.0-3.el7.centos.noarch.rpm
#The rpm creates a few repos
#I had some problems with the latest kamailio and kazoo.
#Deleting the kamailio repo forces yum to download the 2600hz version of kamailio
rm -f /etc/yum.repos.d/kamailio.repo
echo "Installing kazoo-bigcouch ..."
yum -y -q install kazoo-bigcouch
systemctl enable kazoo-bigcouch
systemctl restart kazoo-bigcouch
systemctl status kazoo-bigcouch
echo "Installing kazoo-haproxy ..."
yum -y -q install kazoo-haproxy
systemctl enable kazoo-haproxy
systemctl restart kazoo-haproxy
systemctl status kazoo-haproxy
echo "Installing kazoo-freeswitch ..."
yum -y -q install kazoo-freeswitch
systemctl enable kazoo-freeswitch
systemctl restart kazoo-freeswitch
systemctl status kazoo-freeswitch
echo "Installing kazoo-kamailio ..."
yum -y -q install kazoo-kamailio
cp /etc/kazoo/kamailio/local.cfg /etc/kazoo/kamailio/local.cfg.orig
sed -i "s/127\.0\.0\.1/$IP/g" /etc/kazoo/kamailio/local.cfg
echo ":1:sip\:$IP\:11000:0:0::aio-fs" >> /etc/kazoo/kamailio/dbtext/dispatcher
sed -i "s/kamailio\.2600hz\.com/$FQDN/g" /etc/kazoo/kamailio/local.cfg
systemctl enable kazoo-kamailio
systemctl restart kazoo-kamailio
systemctl status kazoo-kamailio
#You must disable regular kamailio from starting.
/usr/sbin/chkconfig kamailio off
echo "Waiting for kamailio to spin up ..."
sleep 5
kamctl fifo ds_reload
echo "Installing kazoo-rabbitmq ..."
yum -y -q install kazoo-rabbitmq
systemctl enable kazoo-rabbitmq
systemctl restart kazoo-rabbitmq
systemctl status kazoo-rabbitmq
kazoo-rabbitmq status
echo "Installing kazoo-applications ..."
yum -y -q install kazoo-applications
yum -y -q kazoo-application-*
systemctl enable kazoo-applications
systemctl restart kazoo-applications
echo ""
#Wait until at least 21 tables created. might take a while. exit with ctrl-c when ready
echo "Creating couchdb documents ..."
TMP="$(curl localhost:15984/_all_dbs | python -mjson.tool | wc -l)"
echo "Tables so far $TMP of 23 ..."
while [[ $TMP -lt 23 ]]
do
TMP="$(curl localhost:15984/_all_dbs | python -mjson.tool | wc -l)"
echo "Waiting for kazoo-applications to finish creating documents on BigCouch...(should take 5 to 10 min)"
echo "Tables so far $TMP of 23 ..."
sleep 5
done
echo "Importing promtps ..."
yum -y -q install kazoo-sounds-*
sup kazoo_media_maintenance import_prompts /opt/kazoo/sounds/en/us/
echo "Creating Master Account ..."
sup crossbar_maintenance create_account $MASTER_ACCOUNT $FQDN $M_ACCOUNT_USER $M_ACCOUNT_PASS
echo "Configuring call manager ..."
sup kapps_controller start_app ecallmgr
sup ecallmgr_maintenance add_fs_node freeswitch@$FQDN
sup ecallmgr_maintenance allow_sbc kamailio $IP
kazoo-applications status
systemctl enable kazoo-ecallmgr
systemctl restart kazoo-ecallmgr
systemctl status kazoo-ecallmgr
echo "Installing Monster UI ..."
yum -y -q install monster-ui* httpd
systemctl enable httpd
sed -i "s/localhost/$IP/" /var/www/html/monster-ui/js/config.js
sup crossbar_maintenance init_apps /var/www/html/monster-ui/apps http://$IP:8000/v2
echo "<VirtualHost *:80>" > /etc/httpd/conf.d/monster-ui.conf
echo " ServerName $FQDN" >> /etc/httpd/conf.d/monster-ui.conf
echo " DocumentRoot \"/var/www/html/monster-ui\" " >> /etc/httpd/conf.d/monster-ui.conf
echo "</VirtualHost>" >> /etc/httpd/conf.d/monster-ui.conf
systemctl restart httpd
systemctl status httpd
echo "Aaving documentation to /usr/doc/sup_commands ..."
/opt/kazoo/lib/sup*/priv/build-autocomplete.escript /etc/bash_completion.d/sup.bash /opt/kazoo > /usr/doc/sup_commands
echo "Downloading Sipify ..."
curl -o /usr/bin/sipify.sh \
https://raw.githubusercontent.com/2600hz/community-scripts/master/FreeSWITCH/sipify.sh
chmod 755 /usr/bin/sipify.sh
echo "Installing SNGREP ..."
> /etc/yum.repos.d/irontec.repo
echo "[irontec]" >> /etc/yum.repos.d/irontec.repo
echo "name=Irontec RPMs repository" >> /etc/yum.repos.d/irontec.repo
echo "baseurl=http://packages.irontec.com/centos/\$releasever/\$basearch/" >> /etc/yum.repos.d/irontec.repo
rpm --import http://packages.irontec.com/public.key
yum -y -q install sngrep
echo "Configuring iptables ..."
yum -y -q install iptables-services
> /etc/sysconfig/iptables
echo "*filter" >> /etc/sysconfig/iptables
echo ":INPUT ACCEPT [0:0]" >> /etc/sysconfig/iptables
echo ":FORWARD ACCEPT [0:0]" >> /etc/sysconfig/iptables
echo ":OUTPUT ACCEPT [0:0]" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -p icmp -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -i lo -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 5060 -j ACCEPT" >> /etc/sysconfig/iptables
echo "#voip" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp -s 127.0.0.1 --dport 11000 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp -s 127.0.0.1 --dport 5672 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -p udp -m udp -s 127.0.0.1 --dport 11000 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -p udp -m udp --dport 5060 -j ACCEPT" >> /etc/sysconfig/iptables
echo "#RTP " >> /etc/sysconfig/iptables
echo "-A INPUT -p udp -m udp --dport 10000:35000 -j ACCEPT" >> /etc/sysconfig/iptables
echo "#Reject" >> /etc/sysconfig/iptables
echo "-A INPUT -j REJECT --reject-with icmp-host-prohibited" >> /etc/sysconfig/iptables
echo "-A FORWARD -j REJECT --reject-with icmp-host-prohibited" >> /etc/sysconfig/iptables
echo "COMMIT" >> /etc/sysconfig/iptables
systemctl enable iptables
systemctl restart iptables
echo "Installation complete, press any key to run basic tests ..."
read -rsn1 -p"Press any key to continue";echo
clear
echo ""
echo "Big Couch"
curl localhost:5984
curl localhost:5986
echo ""
read -rsn1 -p"Press any key to continue";echo
echo ""
echo "Ha Proxy"
curl localhost:15984
curl localhost:15986
echo ""
read -rsn1 -p"Press any key to continue";echo
echo ""
echo "Kazoo Rabbit"
curl -i -u guest:guest http://localhost:15672/api/aliveness-test/%2F
curl -u guest:guest http://localhost:15672/api/overview | python -m json.tool
echo ""
read -rsn1 -p"Press any key to continue";echo
echo ""
echo "Kazoo FreeSWITCH"
fs_cli -x status
fs_cli -x 'erlang status'
echo ""
read -rsn1 -p"Press any key to continue";echo
echo ""
echo "Kazoo Applications "
kazoo-applications status
echo ""
read -rsn1 -p"Press any key to continue";echo
echo ""
echo "Kazoo API"
curl http://$IP:8000/v2
echo ""
echo ""
echo "Welcome to Kazoo!"
echo " Point your browser to http://$FQDN "
echo ""
echo "might be a good idea to reboot..."
echo ""
echo "All Done "
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment