summaryrefslogtreecommitdiff
path: root/hosts/vidhar/borg/copy.py
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/vidhar/borg/copy.py')
-rwxr-xr-xhosts/vidhar/borg/copy.py16
1 files changed, 1 insertions, 15 deletions
diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py
index 91c65e1e..f685a490 100755
--- a/hosts/vidhar/borg/copy.py
+++ b/hosts/vidhar/borg/copy.py
@@ -115,15 +115,13 @@ def copy_archive(src_repo_path, dst_repo_path, entry):
115 for path in [chroot,upper,work]: 115 for path in [chroot,upper,work]:
116 path.mkdir() 116 path.mkdir()
117 subprocess.run(['mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir=/,upperdir={upper},workdir={work}', chroot], check=True) 117 subprocess.run(['mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir=/,upperdir={upper},workdir={work}', chroot], check=True)
118 bindMounts = ['nix', 'run', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')] 118 bindMounts = ['nix', 'run', 'run/secrets.d', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')]
119 if os.environ.get('BORG_BASE_DIR'): 119 if os.environ.get('BORG_BASE_DIR'):
120 bindMounts.append(pathlib.Path(os.environ['BORG_BASE_DIR']).relative_to('/')) 120 bindMounts.append(pathlib.Path(os.environ['BORG_BASE_DIR']).relative_to('/'))
121 if not ":" in src_repo_path: 121 if not ":" in src_repo_path:
122 bindMounts.append(pathlib.Path(src_repo_path).relative_to('/')) 122 bindMounts.append(pathlib.Path(src_repo_path).relative_to('/'))
123 if 'SSH_AUTH_SOCK' in os.environ: 123 if 'SSH_AUTH_SOCK' in os.environ:
124 bindMounts.append(pathlib.Path(os.environ['SSH_AUTH_SOCK']).parent.relative_to('/')) 124 bindMounts.append(pathlib.Path(os.environ['SSH_AUTH_SOCK']).parent.relative_to('/'))
125 if 'CREDENTIALS_DIRECTORY' in os.environ:
126 bindMounts.append(pathlib.Path(os.environ['CREDENTIALS_DIRECTORY']).parent.relative_to('/'))
127 for bindMount in bindMounts: 125 for bindMount in bindMounts:
128 (chroot / bindMount).mkdir(parents=True,exist_ok=True) 126 (chroot / bindMount).mkdir(parents=True,exist_ok=True)
129 # print(*['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], file=stderr) 127 # print(*['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], file=stderr)
@@ -241,18 +239,6 @@ def sigterm(signum, frame):
241 239
242def main(): 240def main():
243 signal.signal(signal.SIGTERM, sigterm) 241 signal.signal(signal.SIGTERM, sigterm)
244
245 if 'CREDENTIALS_DIRECTORY' in os.environ:
246 def do_chown(path):
247 os.chown(path, borg_pwd.pw_uid, borg_pwd.pw_gid)
248 do_chown(os.environ['CREDENTIALS_DIRECTORY'])
249
250 for root, dirs, files in os.walk(os.environ['CREDENTIALS_DIRECTORY']):
251 root_path = pathlib.Path(root)
252 for dir in dirs:
253 do_chown(root_path / pathlib.Path(dir))
254 for file in files:
255 do_chown(root_path / pathlib.Path(file))
256 242
257 if "::" in args.source: 243 if "::" in args.source:
258 (src_repo_path, _, src_archive) = args.source.partition("::") 244 (src_repo_path, _, src_archive) = args.source.partition("::")