feat(mars): expose luna over the OpenAI-compatible API server
API_SERVER_ENABLED/HOST/PORT in the env template, bound 0.0.0.0 for the
same reason the dashboard is: the container is --network=host and nothing
opens 8642 in the firewall, so it is reachable over tailscale0 only.
API_SERVER_KEY has to go through .env like the ElevenLabs key did
(461d6cc). Confirmed the same way: with the key set only in the container
env the server came up — so API_SERVER_ENABLED/HOST *did* pass through —
but answered every bearer token with "Invalid gateway API key". The s6
passthrough list carries the plain API_SERVER_* vars and drops the secret
one. The .env write is now a write_env_key helper so both keys share it.
restartUnits gains prepare-dirs, which is what writes the .env line; the
container then has to come back up to read it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+22
-11
@@ -272,17 +272,28 @@ in
|
||||
# setpriv because root must not write into hermesHome — luna could plant a
|
||||
# symlink there. The key arrives on an fd opened while still root, so it
|
||||
# never lands in argv or the journal and her uid needs no /run/secrets access.
|
||||
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||
${pkgs.runtimeShell} -c '
|
||||
set -eu
|
||||
envf=$1
|
||||
umask 077
|
||||
key=$(cat)
|
||||
[ -e "$envf" ] || : > "$envf"
|
||||
{ grep -v "^ELEVENLABS_API_KEY=" "$envf" || true
|
||||
printf "ELEVENLABS_API_KEY=%s\n" "$key"; } > "$envf.new"
|
||||
mv -f "$envf.new" "$envf"
|
||||
' _ ${hermesHome}/.env < ${config.sops.secrets.elevenlabs_api_key.path}
|
||||
#
|
||||
# API_SERVER_KEY is in the same boat, confirmed the same way: with it set
|
||||
# only in the container env the server came up (so API_SERVER_ENABLED/HOST
|
||||
# DID pass through) but answered every bearer token with
|
||||
# "Invalid gateway API key" — the passthrough list carries the plain
|
||||
# API_SERVER_* vars and drops the secret one.
|
||||
write_env_key() {
|
||||
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||
${pkgs.runtimeShell} -c '
|
||||
set -eu
|
||||
envf=$1
|
||||
name=$2
|
||||
umask 077
|
||||
key=$(cat)
|
||||
[ -e "$envf" ] || : > "$envf"
|
||||
{ grep -v "^$name=" "$envf" || true
|
||||
printf "%s=%s\n" "$name" "$key"; } > "$envf.new"
|
||||
mv -f "$envf.new" "$envf"
|
||||
' _ ${hermesHome}/.env "$1"
|
||||
}
|
||||
write_env_key ELEVENLABS_API_KEY < ${config.sops.secrets.elevenlabs_api_key.path}
|
||||
write_env_key API_SERVER_KEY < ${config.sops.secrets.hermes_api_server_key.path}
|
||||
|
||||
if [ -d ${hermesHome}/.config ]; then
|
||||
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
|
||||
|
||||
Reference in New Issue
Block a user