Commit 56895d5e authored by Nicolas Wavrant's avatar Nicolas Wavrant

resilient: add script to be used as a backup_identity_file

It can exclude directories from the hash computation, which may
be handy for more than one software release.
Its first application will be to exclude logrotated logs from the signature
file, and the zodb backup, as they integrate their own integrity mechanisme
parent c97ea9e7
......@@ -113,6 +113,7 @@ setup(name=name,
'rdiffbackup.genstatrss = slapos.resilient.rdiffBackupStat2RSS:main',
'runner-exporter = slapos.resilient.runner_exporter:runExport',
'runner-importer-post-notification-run = slapos.resilient.runner_importer:postNotificationRun',
'backup-identity-script-excluding-path = slapos.resilient.identity_script_excluding_path:calculateSignature',
'securedelete = slapos.securedelete:main',
'slapos-kill = slapos.systool:kill',
'slaprunnertest = slapos.runner.runnertest:main',
......
from __future__ import print_function
import argparse
import os
import subprocess
import re
from .runner_utils import *
def parseArgumentList():
parser = argparse.ArgumentParser()
parser.add_argument('--exclude-path', action='append', required=True)
return parser.parse_args()
def calculateSignature():
args = parseArgumentList()
file_list = sys.stdin.read()
file_list = file_list.split('\0')
if not len(file_list):
return 0
result = re.match('^\.\/runner\/instance\/slappart(\d)', file_list[0])
base_relative_path = result.group()
excluded_path_list = tuple(['./' + os.path.relpath(os.path.join(base_relative_path, path)) for path in args.exclude_path])
filtered_file_list = [
x for x in file_list
if not x.startswith(excluded_path_list)
]
print('\n'.join(getSha256Sum(filtered_file_list)))
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment