def install(fpm=False): server_version = server.version() apache_was_installed = package.is_installed('apache2.2-bin') packages = [ 'php5-suhosin', 'php5-mysql', 'php5-memcache', 'php5-memcached', 'php5-mcrypt', 'php5-json', 'php5-cli', 'php-apc', 'php5-dev', 'php5-curl', 'php-pear', 'php5-gd' ] if fpm: packages.append('php5-fpm') # Add the ppa for old ubuntu versions if fpm and server_version == '10.04': package.install_ppa('brianmercer/php') package.install(packages) # Some old php packages requires apache2 which we cannot remove # but we can stop it and remove it from to boot process if server_version != '11.10' and not apache_was_installed: sudo('update-rc.d -f apache2 remove') service.stop('apache2') if fpm: sudo('sudo update-rc.d -f php5-fpm defaults') service.restart('php5-fpm')
def install(): nodejs.ensure() tmpdir = dir.temp() try: with ctx.cd(tmpdir): sudo("curl http://npmjs.org/install.sh | sh") finally: dir.remove(tmpdir, recursive=True)
def install_ppa(name): ensure("python-software-properties") with ctx.cd("/etc/apt/sources.list.d"): name_normalizes = name.replace("/", "-") source_list = "%s-%s.list" % (name_normalizes, server.codename()) if not file.exists(source_list): sudo("add-apt-repository ppa:%s" % name) update()
def install_ppa(name): ensure("python-software-properties") with ctx.cd("/etc/apt/sources.list.d"): name_normalizes = name.replace("/", "-") source_list = "%s-%s.list" % (name_normalizes, server.codename()) if not file.exists(source_list): core.sudo("add-apt-repository ppa:%s" % name) update()
def install(): package.ensure(['git-core', 'curl', 'build-essential']) tmpdir = dir.temp() try: with ctx.cd(tmpdir): repo = 'git://github.com/sstephenson/ruby-build.git' run('git clone %s ./ --depth 1' % repo) sudo('./install.sh') finally: dir.remove(tmpdir, recursive=True)
def _preseed_server(root_password): seed_config = """# Mysql preseed generated by revolver mysql-server mysql-server/root_password password %(root_password)s mysql-server mysql-server/root_password_again password %(root_password)s """ % {"root_password": root_password} seed_dir = "/var/cache/local/preseeding/" seed_file = seed_dir + "mysql-server.seed" with ctx.sudo(): dir.create(seed_dir, recursive=True) file.write(seed_file, seed_config) sudo("debconf-set-selections %s" % seed_file)
def install(version=_VERSION, options=_OPTIONS): package.ensure(["git-core", "build-essential"]) tmpdir = dir.temp() try: with ctx.cd(tmpdir): run("git clone git://github.com/antirez/redis.git ./ --depth 1") run("git checkout %s" % version) run("make %s > /dev/null" % options) sudo("make install") finally: dir.remove(tmpdir, recursive=True)
def command(name, command): initd_file = "/etc/init.d/%s" % name upstart_file = "/etc/init/%s.conf" % name if file.exists(upstart_file): cmd = "%s %s" % (command, name) elif file.exists(initd_file): cmd = "%s %s" % (initd_file, command) else: cmd = "false" core.sudo(cmd)
def install(version=_VERSION, options=_OPTIONS): package.ensure(['git-core', 'build-essential']) tmpdir = dir.temp() try: with ctx.cd(tmpdir): run('git clone git://github.com/antirez/redis.git ./ --depth 1') run('git checkout %s' % version) run('make %s > /dev/null' % options) sudo('make install') finally: dir.remove(tmpdir, recursive=True)
def install(version=_VERSION, options=_OPTIONS): package.ensure(['git-core', 'libssl-dev', 'curl', 'build-essential']) tmpdir = dir.temp() try: with ctx.cd(tmpdir): repo = 'git://github.com/joyent/node.git' run('git clone %s ./ --depth 1' % repo) run('git checkout %s' % version) run('./configure %s' % options) run('make > /dev/null') sudo('make install') finally: dir.remove(tmpdir, recursive=True)
def _preseed_server(root_password): seed_config = """# Mysql preseed generated by revolver mysql-server mysql-server/root_password password %(root_password)s mysql-server mysql-server/root_password_again password %(root_password)s mysql-server mysql-server/start_on_boot boolean true """ % { "root_password": root_password } seed_dir = "/var/cache/local/preseeding/" seed_file = seed_dir + "mysql-server.seed" if file.exists(seed_file): return with ctx.sudo(): dir.create(seed_dir, recursive=True) file.write(seed_file, seed_config) sudo("debconf-set-selections %s" % seed_file)
def install(version=_VERSION): target = '/usr/local/ruby-%s' % version priority = _convert_version_to_string(version) placeholder = {'target': target, 'priority': priority} ruby_build.ensure() sudo('ruby-build %s %s' % (version, target)) update_alternatives_cmd = """sudo update-alternatives \ --install /usr/bin/ruby ruby %(target)s/bin/ruby %(priority)s \ --slave /usr/bin/erb erb %(target)s/bin/erb \ --slave /usr/bin/gem gem %(target)s/bin/gem \ --slave /usr/bin/irb irb %(target)s/bin/irb \ --slave /usr/bin/rake rake %(target)s/bin/rake \ --slave /usr/bin/rdoc rdoc %(target)s/bin/rdoc \ --slave /usr/bin/ri ri %(target)s/bin/ri \ --slave /usr/bin/testrb testrb %(target)s/bin/testrb \ --slave /usr/share/man/man1/erb.1 erb.1 %(target)s/share/man/man1/erb.1 \ --slave /usr/share/man/man1/irb.1 irb.1 %(target)s/share/man/man1/irb.1 \ --slave /usr/share/man/man1/rake.1 rake.1 %(target)s/share/man/man1/rake.1 \ --slave /usr/share/man/man1/ri.1 ri.1 %(target)s/share/man/man1/ri.1 \ --slave /usr/share/man/man1/ruby.1 ruby.1 %(target)s/share/man/man1/ruby.1 """ sudo(update_alternatives_cmd % placeholder) sudo('update-alternatives --set ruby %(target)s/bin/ruby' % placeholder)
def is_running(name): with ctx.settings(warn_only=True): res = core.sudo("/etc/init.d/%s status" % name) return res.succeeded
def command(name, command): sudo( '/etc/init.d/%(name)s %(command)s' % {'name': name, 'command': command} )
def install(): package.ensure(["curl", "git-core"]) url = "https://raw.github.com" \ + "/nvie/gitflow/develop/contrib/gitflow-installer.sh" sudo("curl -s %s | bash" % url)
def _execute_mysql(sql): sudo("mysql --defaults-file=/etc/mysql/root.cnf -e '%s'" % sql)
def install(): package.ensure(["curl", "git-core"]) url = "https://raw.github.com/michaelcontento/git-chiefs/master/install" sudo("curl -s %s | bash" % url)
def test_inject_user_for_sudo_via_env(_sudo): _sudo.expects_call().with_args("foo", user="******") core.env.sudo_user = "******" core.sudo("foo") core.env.sudo_user = None
def ensure_pecl(package, channel=None, version=None, state=None): package = _generate_pear_or_pecl_name(package, channel, version, state) # TODO Check if already installed sudo("pecl install %s; true" % package)
def _clear_old_releases(directory, keep): with ctx.cd(directory): sudo( 'ls -1 | sort -V | head -n-%s | xargs -l1 rm -rf' % keep )
def install(): package.ensure(["curl", "git-core", "make"]) url = "https://raw.github.com/visionmedia/git-extras/master/bin/git-extras" sudo("curl -s %s | INSTALL=y sh" % url)