create symlink ~/box.cfg
+ improve logging in repo_sync.py
This commit is contained in:
1 parent
23dea60cc6
commit
526b8983b9
2 files changed
+11
-2
No files matched your search
@@ -750,6 +750,14 @@ def handle_config():
|
||||
print('replace host name %r by %r' % (box.hostname, newhostname))
|
||||
show.dirty = True
|
||||
config = box.read_config()
|
||||
cfgpath = Path(box.cfgfile)
|
||||
cfglink = Path.home() / 'box.cfg'
|
||||
if not cfglink.exists() or cfglink.resolve() != cfgpath:
|
||||
print(f'ln -s {cfgpath} {cfglink}')
|
||||
if doit:
|
||||
cfglink.symlink_to(cfgpath)
|
||||
else:
|
||||
print(f'ln -s {cfgpath} {cfglink}')
|
||||
box.hostname = newhostname
|
||||
update_host_key(newhostname)
|
||||
if cfgfile is None:
|
||||
|
||||
+3
-2
@@ -39,7 +39,7 @@ def get_dirs():
|
||||
|
||||
|
||||
def ssh(remote_cmd: str) -> subprocess.CompletedProcess:
|
||||
print(remote_cmd)
|
||||
log(f'> {remote_cmd}')
|
||||
return subprocess.run(
|
||||
SSH_OPTS.split() + [CENTRAL, remote_cmd],
|
||||
capture_output=True, text=True,
|
||||
@@ -71,6 +71,7 @@ def cmd_restore():
|
||||
dorestore = f"{REMOTE_DIR}/do.restore"
|
||||
if ssh(f"ls {dorestore}").returncode == 0:
|
||||
if restore():
|
||||
log("restore done")
|
||||
ssh(f"rm {dorestore}")
|
||||
return True
|
||||
else:
|
||||
@@ -106,7 +107,7 @@ def cmd_backup() -> None:
|
||||
sys.exit("inotifywait exited, letting systemd restart us")
|
||||
changed.clear()
|
||||
if backup():
|
||||
last_backup = time.monotonic()
|
||||
log('backup done')
|
||||
ssh(f'touch {REMOTE_DIR}/backup.done')
|
||||
changed.wait()
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user