diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-18 12:08:01 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-18 12:08:01 +0100 |
commit | 5d80ed9d80b551327d75f8738f77363cb94e2b9f (patch) | |
tree | 3f93f3bd6a66c30785c3312fc9f73c9f4c20d522 /hosts/vidhar/borg/copy.py | |
parent | ba063fb1e705997143191cf2aa97ed8cb8a86078 (diff) | |
download | nixos-5d80ed9d80b551327d75f8738f77363cb94e2b9f.tar nixos-5d80ed9d80b551327d75f8738f77363cb94e2b9f.tar.gz nixos-5d80ed9d80b551327d75f8738f77363cb94e2b9f.tar.bz2 nixos-5d80ed9d80b551327d75f8738f77363cb94e2b9f.tar.xz nixos-5d80ed9d80b551327d75f8738f77363cb94e2b9f.zip |
vidhar: ...
Diffstat (limited to 'hosts/vidhar/borg/copy.py')
-rwxr-xr-x | hosts/vidhar/borg/copy.py | 16 |
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 | ||
242 | def main(): | 240 | def 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("::") |