Last active
August 2, 2017 14:56
-
-
Save ibrmora/cdaa8e9cd4db661b00ff311c2dd023d7 to your computer and use it in GitHub Desktop.
Fabric file to install OpenVBX on Ubuntu 14.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Use debian 7.11 x64 | |
openVBX | |
http://www.openvbx.org/install/ | |
''' | |
from fabric.api import * | |
env.hosts = ['server ip'] | |
env.user = 'root' | |
env.key_filename = ['/path/to/key file'] | |
base_user = 'root' | |
base_user_pass = 'password' | |
db_name = 'OpenVBX' | |
db_user = 'OpenVBXdbuser' | |
db_user_pass = 'password' | |
region = 'your region' # example 'Asia/Riyadh' | |
@task | |
def deploy(): | |
check_for_updates() | |
firewall() | |
time_zone() | |
install_db() | |
create_db() | |
install_necessary_software() | |
install_optional_software() | |
download_Openvbx() | |
config() | |
restart_apache() | |
@task | |
def check_for_updates(): | |
run('apt-get update ') | |
run('apt-get upgrade -y ') | |
@task | |
def firewall(): | |
run('apt-get install -y ufw') | |
run('ufw allow www') | |
run('ufw allow 22') | |
run('yes | ufw enable') | |
run('ufw status verbose') | |
@task | |
def time_zone(): | |
# Set the Server Timezone to your region | |
run('echo "{}" > /etc/timezone'.format(region)) | |
run('dpkg-reconfigure -f noninteractive tzdata') | |
@task | |
def install_db(): | |
run("debconf-set-selections <<< 'mysql-server mysql-server/root_password password {}'".format(base_user_pass)) | |
run("debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password {}'".format(base_user_pass)) | |
run('apt-get install -y mysql-server') | |
#mysql Ver 14.14 Distrib 5.5.50, for debian-linux-gnu (x86_64) using readline 6.3 | |
run('mysql --version') | |
run('echo -e "{0}\nn\n\n\n\n\n " | mysql_secure_installation'.format(base_user_pass)) | |
@task | |
def create_db(): | |
x = "CREATE DATABASE {0}; GRANT ALL PRIVILEGES ON {0}.* TO {1}@localhost IDENTIFIED BY '{2}'; FLUSH PRIVILEGES".format(db_name,db_user,db_user_pass) | |
run('echo "{0}"| mysql -u {1} -p{2}'.format(x,base_user,base_user_pass)) | |
@task | |
def install_necessary_software(): | |
run("apt-get install -y apache2") | |
run("apt-get install -y php5") | |
run('apt-get install -y libapache2-mod-php5') | |
run("apt-get install -y php5-mysql") | |
run("apt-get install -y libapache2-mod-auth-mysql") | |
run('apt-get install -y php5-curl') | |
run('apt-get install -y git') | |
run('apt-get install -y sendmail sendmail-bin') | |
@task | |
def install_optional_software(): | |
run("apt-get install -y php5-memcache") | |
run("apt-get install -y memcached") | |
run('apt-get install -y php-apc') | |
@task | |
def download_Openvbx(): | |
run('wget -O openvbx.tgz https://github.com/twilio/OpenVBX/tarball/1.2.20') | |
run('tar xf openvbx.tgz') | |
run('rm /var/www/index.html') | |
run('cp -r twilio-OpenVBX-a1d6147/* /var/www/') | |
run('rm openvbx.tgz') | |
run('rm -rf twilio-OpenVBX-a1d6147/') | |
@task | |
def config(): | |
run('chmod 777 -Rf /var/www/OpenVBX/config') | |
run('chmod 777 -Rf /var/www/audio-uploads') | |
@task | |
def restart_apache(): | |
run('service apache2 restart') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment