def nginx_ensure(name, template): with mode_sudo(): package_ensure('nginx') run("cp %s /etc/nginx/sites-available/%s" % (template, name)) file_update('/etc/nginx/sites-available/%s' % name, lambda x: text_template(x,env)) if not file_exists("/etc/nginx/sites-enabled/%s" % name): run("ln -s -t /etc/nginx/sites-enabled /etc/nginx/sites-available/%s " % ( env.project_name)) file_unlink('/etc/nginx/sites-enabled/default') run("service nginx restart")
def uninstall(): if fabric.contrib.console.confirm( "!!! ACHTUNG !!!\nthis will delete all data!\nContinue?", default=False): run('service apache2 stop') if user_check(project_name): user_remove(project_name) run('rm -rf /home/%s' % project_name) file_unlink('/etc/apache2/sites-enabled/' + project_name) run('rm -rf /etc/apache2/sites-available/' + project_name) run('service apache2 start')
def nginx_ensure(project_path, name, template, key_env): with mode_sudo(), cd(project_path): package_ensure('nginx') run("cp %s /etc/nginx/sites-available/%s" % (template, name)) file_update('/etc/nginx/sites-available/%s' % name, lambda x: text_template(x,key_env)) if not file_exists("/etc/nginx/sites-enabled/%s" % name): run("ln -s -t /etc/nginx/sites-enabled /etc/nginx/sites-available/%s " % ( name)) file_unlink('/etc/nginx/sites-enabled/default') run("service nginx restart")
def save(self): puts("Writing to %s's crontab..." % (self.user or env.user)) cuisine.file_unlink('/tmp/new-crontab') cuisine.file_write('/tmp/new-crontab', '\n'.join(self.lines) + '\n') cmd = sudo if self.user else run try: cmd('crontab %s < /tmp/new-crontab' % ( ('-u ' + self.user) if self.user else '' )) finally: cuisine.file_unlink('/tmp/new-crontab') return self
def check_directory(self, root, files, remote_rootpath): ''' Examine the given directory, check for a fck_delete.txt file in the directory, and if it exists delete all remote files named in it. :type root: string :param root: local directory possibly containing fck_delete.txt :type files: list of strings :param files: list of the files in the local root directory :type remote_rootpath: string :param remote_rootpath: path on remote server to delete files from ''' if self.tagfile in files: for line in open(os.path.join(root, self.tagfile)): delfile = os.path.join(remote_rootpath, line.strip()) cuisine.file_unlink(delfile)
def restore(local_path): put(local_path, "/tmp/db", mode='600') run("chown postgres:postgres /tmp/db") sudo("psql </tmp/db", user='******') file_unlink("/tmp/db")
def attribs(self): cuisine.file_write("/tmp/cuisine.attribs.text") cuisine.file_attribs("/tmp/cuisine.attribs.text", "777") cuisine.file_unlink("/tmp/cuisine.attribs.text")
def attribs( self ): cuisine.file_write("/tmp/cuisine.attribs.text") cuisine.file_attribs("/tmp/cuisine.attribs.text", "777") cuisine.file_unlink("/tmp/cuisine.attribs.text")