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 _dependencies(self): with ctx.cd(self.folders["releases.current"]): if file.exists("package.json"): self._dependencies_package_json() if file.exists("Gemfile"): self._dependencies_gemfile() if file.exists("setup.py"): self._dependencies_setup_py() if file.exists("requirements.txt"): self._dependencies_requirements_txt()
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 _store_root_cnf(password): cnf_config = """# Config generated by revolver [client] host = localhost user = root password = %s """ % password cnf_dir = "/etc/mysql/" cnf_file = cnf_dir + "root.cnf" if file.exists(cnf_file): return with ctx.sudo(): file.write(cnf_file, cnf_config) file.link(cnf_file, "/root/.my.cnf")
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 _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)