def pack_remote_list(file_list): #tell out.log('packing a bunch of remote files', 'tar') #validate files if not validate_files_list(file_list): out.log('Error: files need to be given relative to www dir.', 'tar', out.LEVEL_ERROR) engine.quit() #register tar file tar_file = engine.get_new_remote_file('tar') #register list file list_file_content = "\n".join(file_list) list_file = engine.write_remote_file(list_file_content, 'files') #assemble packing command. Always pack from www dir pack_command = 'tar cf ' + tar_file + ' -C ' + engine.NORM_WWW_DIR + ' --files-from ' + list_file #pack! run.remote(pack_command) #and return packed file, of course return tar_file
def add_key_to_server(): import run import transfer key_file = transfer.put('~/.ssh/id_rsa.pub') run.remote('mkdir -p ~/.ssh') run.remote('cat ' + key_file + ' >> ~/.ssh/authorized_keys')
def allow_write(location='local'): command = 'chmod -R a+w ./*' if location == 'local': command = 'cd ' + engine.LOCAL_WWW_DIR + ' && ' + command if location == 'local': run.local(command) if location == 'remote': run.remote(command)
def pack_remote(files): #tell out.log('packing on remote: ' + files, 'tar') #validate files if not validate_files(files): out.log('Error: files need to be given relative to www dir.', 'tar', out.LEVEL_ERROR) engine.quit() #register tar file tar_file = engine.get_new_remote_file('tar') #assemble packing command. Always pack from www dir pack_command = 'tar cf ' + tar_file + ' --exclude .tar --exclude ' + engine.NORM_TMP_DIR + ' -C ' + engine.NORM_WWW_DIR + ' ' + files #pack! run.remote(pack_command) #and return packed file, of course return tar_file
def create_remote_dump(compression=False): import php out.log('create remote database dump', 'mysql') if compression: php.start_buffer() #export db on remote sql_file = engine.get_new_remote_file('sql') run.remote(engine.REMOTE_MYSQLDUMP_CMD + ' >' + sql_file) #compress it? if compression: #compress filename = gzip.compress_remote(sql_file, True) else: #return sql file filename = sql_file php.end_buffer() #done return filename
def execute_remote_file(filename): run.remote(engine.REMOTE_MYSQL_CMD + ' <' + filename)
def test_module(): out.log("Testing remote command...", 'run') run.remote('pwd', halt_on_output = False) out.log("Remote command has run successfully", 'run')
def get_remote_www_dir_abspath(): import run out.log('getting absolute remote path of www directory', 'engine') filename = get_new_remote_file('out') run.remote('pwd >' + filename) return read_remote_file(filename).rstrip()
def clean_remote_tmp_dir(): #import transfer import run remote_tmp_dir = get_remote_tmp_dir() run.remote('rm -f ' + remote_tmp_dir + '/*')
def unpack_remote(archive): out.log('unpacking on remote: ' + archive, 'tar') unpack_command = 'tar xf ' + archive + ' --warning=no-unknown-keyword -C ' + engine.NORM_WWW_DIR run.remote(unpack_command)
def create_remote_symlink(): out.log('creating remote .htaccess link', 'htaccess') run.remote('ln -s .htaccess.live .htaccess')