#!/bin/bash
#
#install add-apt-repository & adding repos
apt-get install python-software-properties
add-apt-repository ppa:freeswitch-drivers/freeswitch-nightly-drivers 
add-apt-repository ppa:brianmercer/php
add-apt-repository ppa:nginx/development/ubuntu
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
#
#Update system
apt-get update && apt-get upgrade
#
#Installing tools
apt-get install subversion
#
#install Freeswitch .deb pkgs
apt-get install freeswitch-codec-passthru-amr freeswitch-codec-passthru-g729 freeswitch-codec-passthru-g7231 \

  freeswitch-lang-en freeswitch-lang-ru freeswitch-spidermonkey freeswitch-sounds-en-us-callie-omega \

  freeswitch-sounds-music-omega freeswitch freeswitch-lua freeswitch-perl freeswitch-python \

  freeswitch monit sox
# this command left a trailing semicolon following www-data. you need to remove...
#sed -i 's|daemon:x:1|daemon:x:1:www-data|g' /etc/group
adduser www-data daemon
#
sed -i 's|FREESWITCH_ENABLED="false"|FREESWITCH_ENABLED="true"|g' /etc/default/freeswitch
#
#service start freeswitch
#this is ubuntu
/etc/init.d/freeswitch restart
#
#install webserver and needed libs
apt-get install nginx php5-cli php5-sqlite php5-fpm sqlite3
#
svn checkout http://fusionpbx.googlecode.com/svn/trunk/fusionpbx /var/www/fusionpbx
#
wget http://dl.dropbox.com/u/152504/nginx-default
cp nginx-default /etc/nginx/sites-enabled/default
#
chown -R www-data:www-data /var/www/fusionpbx
chmod -R ug+rwx /var/www/fusionpbx /opt/freeswitch
adduser freeswitch www-data
adduser www-data daemon
#is worldread and worldwrite really a good idea? Doesn't the daemon/www-data group need x permissions on directories?
#find /opt/freeswitch -type d -exec chmod u=rwx,g=srwx,o= {} \;
# NOTE: chmod -R 766 /opt/freeswitch does not work.
# x permissions are required for group.
# even though su - www-data can read and create files in /opt/freeswitch (after using above find command), but not before
# install.php fails when trying to copy the default dialplan.
#
#
#restart nginx & php5-fpm
#service nginx restart
#service php5-fpm restart
#for ubuntu
/etc/init.d/nginx restart
/etc/init.d/php5-fpm restart
#
#Removing dhclient and setting ip
apt-get purge dhcpcd
#
#network config
echo -e "\nEnter Server Ip"
read serverip
echo -e "\nEnter  Server Netmask"
read netmask
echo -e "\nEnter Router Ip"
read routerip
#
/sbin/ifdown --force eth0
/sbin/ifconfig eth0 up
/sbin/ifconfig eth0 $serverip 
/sbin/ifconfig eth0 netmask $netmask
/sbin/route add default gw $routerip
#
mv /etc/init.d/fusion-install /root
#
exit 0

Add a code snippet to your website: www.paste.org