Files

31 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
set -eu
[ "$(id -u)" = 0 ] || { echo 'Run as root'; exit 1; }
base=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
apt-get update
apt-get install -y --no-install-recommends python3-venv ffmpeg libvulkan1 mesa-vulkan-drivers
getent passwd athena-tts >/dev/null || useradd --system --user-group --home-dir /var/lib/athena-helper-tts --shell /usr/sbin/nologin athena-tts
usermod -a -G video,render athena-tts
install -d -m 755 /opt/athena-helper-tts
install -d -o athena-tts -g athena-tts -m 750 /var/lib/athena-helper-tts
install -d -o root -g athena-tts -m 750 /etc/athena-helper-tts
if [ "$base" != /opt/athena-helper-tts ]; then
install -m 644 "$base/gateway.py" /opt/athena-helper-tts/gateway.py
fi
python3 "$base/restore_models.py"
python3 -m venv /opt/athena-helper-tts/piper-venv
/opt/athena-helper-tts/piper-venv/bin/pip install -r "$base/requirements.txt"
python3 - <<'PY'
import pathlib,secrets,os,pwd,grp
p=pathlib.Path('/etc/athena-helper-tts/api-key')
if not p.exists():
fd=os.open(p,os.O_WRONLY|os.O_CREAT|os.O_EXCL,0o640)
with os.fdopen(fd,'w') as f: f.write(secrets.token_urlsafe(48)+'\n')
os.chown(p,0,grp.getgrnam('athena-tts').gr_gid);p.chmod(0o640)
PY
install -m 644 "$base/athena-helper-tts.service" /etc/systemd/system/
install -m 644 "$base/athena-helper-tts-api.service" /etc/systemd/system/
systemctl daemon-reload
# Do not start the slow GPU engine automatically.
systemctl enable --now athena-helper-tts-api.service