def install_pergola(node, branch):
    cm_libcloud.fabric_setup(node)

    # Need to preseed some options for postfix
    fabric.run("echo 'postfix postfix/main_mailer_type select Internet Site' | debconf-set-selections", pty=True)
    fabric.run("echo 'postfix postfix/mailname string $HOSTNAME' | debconf-set-selections", pty=True)
    fabric.run("echo 'postfix postfix/destinations string localhost.localdomain, localhost' | debconf-set-selections", pty=True)
    
    fabric.run("wget --no-check-certificate https://github.com/computerminds/pergola/raw/%s/tools/install.sh -qO - | sh" % (branch), pty=True)
def install_pergola(node, branch):
    cm_libcloud.fabric_setup(node)

    fabric.run("apt-get update", pty=True)
    
    print '===> Installing git'
    fabric.run("apt-get install git-core -y", pty=True)

    print '===> Installing Pergola'
    fabric.run("apt-get install git-core -y", pty=True)
    fabric.run("git clone git://github.com/computerminds/pergola.git -b %s /opt/pergola" % (branch), pty=True)

    # Need to preseed some options for postfix
    fabric.run("echo 'postfix postfix/main_mailer_type select Internet Site' | debconf-set-selections", pty=True)
    fabric.run("echo 'postfix postfix/mailname string $HOSTNAME' | debconf-set-selections", pty=True)
    fabric.run("echo 'postfix postfix/destinations string localhost.localdomain, localhost' | debconf-set-selections", pty=True)


    with fabric.cd('/opt/pergola'):
        fabric.run("python setup.py", pty=True)
def install_mercury(node):
    cm_libcloud.fabric_setup(node)

    print "Installing git"
    fabric.run("apt-get install git-core -y", pty=True)

    print "Installing Mercury"
    fabric.run("apt-get install git-core -y", pty=True)
    fabric.run("git clone git://github.com/pantheon-systems/mercury.git -b master /opt/pantheon", pty=True)

    # Need to preseed some options for postfix
    fabric.run("echo 'postfix postfix/main_mailer_type select Internet Site' | debconf-set-selections", pty=True)
    fabric.run("echo 'postfix postfix/mailname string $HOSTNAME' | debconf-set-selections", pty=True)
    fabric.run(
        "echo 'postfix postfix/destinations string localhost.localdomain, localhost' | debconf-set-selections", pty=True
    )

    with fabric.cd("/opt/pantheon"):
        fabric.run("python setup.py", pty=True)

    fabric.run("apt-get update", pty=True)
    fabric.run("bcfg2 -vqed", pty=True)
def _disable_upstart(node, scripts):
    cm_libcloud.fabric_setup(node)
    for script in scripts:
        with fabric.cd('/etc/init'):
            fabric.run("mv " + script + ".conf " + script + ".conf.disabled", pty=True)
def _disable_initd(node, scripts):
    cm_libcloud.fabric_setup(node)
    for script in scripts:
        fabric.run("update-rc.d " + script + " disable", pty=True)