def make_rescue_file(data_tar_path, rescue_file_destination_path, encrypted_key=None, public_key=None): # find the recovery recovery_script_path = os.path.join(config.get_python_script_dir(), "recovery.sh") temp_key_path = None temp_key_name_path = None try: tar = tarfile.open(rescue_file_destination_path, "w:gz") if encrypted_key is not None: temp_key_path = _write_temp_file(encrypted_key) tar.add(temp_key_path, arcname='key') if public_key is not None: temp_key_name_path = _write_temp_file(public_key.encode()) tar.add(temp_key_name_path, arcname='public_key') tar.add(data_tar_path, arcname='data.enc') tar.add(recovery_script_path, arcname='recovery.sh') tar.close() finally: if temp_key_path is not None: os.remove(temp_key_path) if temp_key_name_path is not None: os.remove(temp_key_name_path) os.remove(data_tar_path)
def copy_scripts(conf_d): (h, dest_dir) = conf_d["storage"]["script_dir"] src_script_dir = os.path.join( config.get_python_script_dir(), 'common-linux') for s in glob.glob("%s/*" % os.path.abspath(src_script_dir)): if os.path.isfile(s): d = os.path.basename(s) shutil.copy(s, os.path.join(dest_dir, d))