def beforeInstallCmds(): # add rabbitmq to sources v = {'file': "/etc/apt/sources.list", 'txt': "deb http://www.rabbitmq.com/debian/ testing main"} _s("grep -q '%(txt)s' %(file)s || echo '%(txt)s' >> %(file)s" % v) _r("wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc") _s("apt-key add rabbitmq-signing-key-public.asc") _r("rm rabbitmq-signing-key-public.asc")
def postInstallCmds(): with _cd(conf['INSTALL_DIR']): if not _fe(conf['INSTALL_DIR']+conf['WORKER_DIR']+"/run_glass"): _w("svn checkout https://svn.physik.uzh.ch/repos/itp/glass ."+conf['WORKER_DIR']) _w("echo backend : Agg > matplotlibrc") _w("echo 'backend : Agg' > %(INSTALL_DIR)s%(WORKER_DIR)s/matplotlibrc" % conf) with _v('.'+conf['WORKER_DIR']): _s("make") _s("python setup.py build") with _cd('.'+conf['WORKER_DIR']): _s("chown -R %(SYS_USER)s:%(SYS_GROUP)s %(INSTALL_DIR)s" % conf) _s("chmod -R u+rwx %(INSTALL_DIR)s" % conf)
def testInstall(): # enable the default site and check if it answers _s("ln -s -f /etc/nginx/sites-available/default /etc/nginx/sites-enabled") _s("/etc/init.d/nginx restart") _r("wget %(PUBLIC_URL)s:%(PUBLIC_PORT)s" % conf) test = _fe("index.html") with settings(warn_only=True): resp = _r("grep 'Welcome to nginx' index.html") test = test and resp.return_code if not test: warn(yellow('nginx is not running properly')) _r("rm index.html") _s("rm /etc/nginx/sites-enabled/default") _s("/etc/init.d/nginx restart")
def mysql_install(): """ Installs MySQL """ if _mysql_is_installed(): fabric.api.warn(yellow('MySQL is already installed.')) return # Ensure mysql won't ask for a password on installation # See the following: # http://serverfault.com/questions/19367/scripted-install-of-mysql-on-ubuntu # http://www.muhuk.com/2010/05/how-to-install-mysql-with-fabric/ package_install('debconf-utils') # get the password passwd = fabric.api.env.conf['DATABASE_ROOT_PSW'] # get the correct version for installation version = '5.5' debconf_defaults = [ "mysql-server-%s mysql-server/root_password password %s" % (version,passwd), "mysql-server-%s mysql-server/root_password_again password %s" % (version,passwd), ] _s("echo '%s' | debconf-set-selections" % "\n".join(debconf_defaults)) fabric.api.warn(yellow('The password for mysql "root" user will be set to "%s"' % passwd)) common_packages = [ 'mysql-server-%s' % version, ] package_install(common_packages) #install prerequ for mysql-python _s("apt-get build-dep python-mysqldb")
def setup(): _s("mkdir -p %(INSTALL_DIR)s/run" % conf) file = _gen_start_script() _p(file, "%(INSTALL_DIR)s/run/start_guni.sh" % conf, use_sudo=True) #local _s("chown -R %(SYS_USER)s:%(SYS_GROUP)s %(INSTALL_DIR)s/*" % conf) _s("chmod 744 %(INSTALL_DIR)s/run/start_guni.sh" % conf) #file = _gen_upstart_conf() #_p(file, "/etc/init/guni-lmt.conf" % conf, use_sudo=True) #local #_s("ln -s -f /lib/init/upstart-job /etc/init.d/guni-lmt") #_s("initctl reload-configuration") file = _gen_supervisor_script() _p(file, "/etc/supervisor/conf.d/guni", use_sudo=True) _s("supervisorctl reload")
def betweenInstallCmds(): _s("easy_install -U virtualenv ")
def setup(): #rabbitmq server with settings(warn_only=True): _s("rabbitmqctl add_user %(BROKER_USER)s %(BROKER_PSW)s" % conf) _s("rabbitmqctl add_vhost %(BROKER_VHOST)s" % conf) _s('rabbitmqctl set_permissions -p %(BROKER_VHOST)s %(BROKER_USER)s ".*" ".*" ".*"' % conf) # celery deamon file = _gen_default_config() _p(file, "/etc/default/celeryd", use_sudo=True) file = _gen_init_d_script() _p(file, "/etc/init.d/celeryd", use_sudo=True) _s("chmod 777 /etc/init.d/celeryd") _s("mkdir -p /var/run/celery/") _s("chown lmt:www-lmt /var/run/celery/")
def setup(): file = _generateConfigFile() puts("--- nginx temp config file: ") print file.getvalue() _p(file, "/etc/nginx/sites-available/lmt.conf", use_sudo=True) _s("ln -f -s /etc/nginx/sites-available/lmt.conf /etc/nginx/sites-enabled") _s("/etc/init.d/nginx reload") # copy html files _s("cp -f -R %(REPRO_DIR)s/static_html %(INSTALL_DIR)s%(HTML_DIR)s" % conf) file = _generateHTMLSettings() _p(file, "%(INSTALL_DIR)s%(HTML_DIR)s/js/lmt.settings.js" % conf, use_sudo=True) #local _s("chown -R %(SYS_USER)s:%(SYS_GROUP)s %(INSTALL_DIR)s/*" % conf) _s("chmod -R 774 %(INSTALL_DIR)s%(HTML_DIR)s/*" % conf) # merge php with _cd("%(INSTALL_DIR)s%(HTML_DIR)s"%conf): _s("echo '<!DOCTYPE html>' > lmt.html") _s("echo '<html lang='en'>' >> lmt.html") _s("cat head.html >> lmt.html") _s("cat body.php >> lmt.html") _s("echo '</html>' >> lmt.html")