fix: recover TTS bridge secret bind mounts #21
1 changed files with 14 additions and 8 deletions
22
app.py
22
app.py
|
|
@ -1905,14 +1905,20 @@ async def tts_bridge_deploy(req: TTSBridgeDeployRequest, _=Depends(_verify)):
|
||||||
"/app-config/tts-bridge/butler-token": BUTLER_TOKEN,
|
"/app-config/tts-bridge/butler-token": BUTLER_TOKEN,
|
||||||
"/app-config/tts-bridge/client-token": client_token,
|
"/app-config/tts-bridge/client-token": client_token,
|
||||||
}
|
}
|
||||||
encoded = base64.b64encode(json.dumps(files).encode()).decode()
|
installer = """import json, os, pathlib
|
||||||
script = (
|
files = json.loads({files_json!r})
|
||||||
"import base64,json,os,pathlib;"
|
base = pathlib.Path('/app-config/tts-bridge')
|
||||||
f"files=json.loads(base64.b64decode('{encoded}'));"
|
base.mkdir(parents=True, exist_ok=True)
|
||||||
"pathlib.Path('/app-config/tts-bridge').mkdir(parents=True,exist_ok=True);"
|
for filename, value in files.items():
|
||||||
"[(pathlib.Path(p).write_text(v),os.chmod(p,0o600)) for p,v in files.items()]"
|
path = pathlib.Path(filename)
|
||||||
)
|
if path.is_dir():
|
||||||
rc, _out, err = _ssh("sascha@10.5.85.5", f"sudo python3 -c {__import__('shlex').quote(script)}", timeout=30)
|
path.rmdir()
|
||||||
|
path.write_text(value)
|
||||||
|
os.chmod(path, 0o600)
|
||||||
|
""".format(files_json=json.dumps(files))
|
||||||
|
encoded = base64.b64encode(installer.encode()).decode()
|
||||||
|
command = f"sudo python3 -c {__import__('shlex').quote(f'import base64;exec(base64.b64decode({encoded!r}))')}"
|
||||||
|
rc, _out, err = _ssh("sascha@10.5.85.5", command, timeout=30)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
_audit("/tts/bridge/deploy", "POST", 500, "secret installation failed")
|
_audit("/tts/bridge/deploy", "POST", 500, "secret installation failed")
|
||||||
raise HTTPException(status_code=500, detail="Could not install bridge secrets")
|
raise HTTPException(status_code=500, detail="Could not install bridge secrets")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue