fix(deploy): install sudo on minimal Debian, use runuser instead of sudo
Minimal-LXC-Templates (debian-13-standard) have no sudo. Script runs as root anyway, so switch to runuser. Also install sudo so the systemd service file's 'User=deploy' has the helper available when needed.
This commit is contained in:
parent
5321c8602e
commit
27f2f91ec6
@ -7,10 +7,13 @@ REPO_URL="${REPO_URL:-https://git.cynfo.net/christian/voice-agent.git}"
|
|||||||
APP_DIR="/var/www/voice-agent"
|
APP_DIR="/var/www/voice-agent"
|
||||||
APP_USER="deploy"
|
APP_USER="deploy"
|
||||||
|
|
||||||
|
echo "[0/7] Sicherstellen: nicht-interaktive apt"
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
echo "[1/7] System-Pakete installieren"
|
echo "[1/7] System-Pakete installieren"
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
git python3 python3-venv python3-pip nginx ca-certificates curl ffmpeg
|
git python3 python3-venv python3-pip nginx ca-certificates curl ffmpeg sudo
|
||||||
|
|
||||||
echo "[2/7] Deploy-User sicherstellen"
|
echo "[2/7] Deploy-User sicherstellen"
|
||||||
id "$APP_USER" >/dev/null 2>&1 || useradd -m -s /bin/bash "$APP_USER"
|
id "$APP_USER" >/dev/null 2>&1 || useradd -m -s /bin/bash "$APP_USER"
|
||||||
@ -19,17 +22,17 @@ chown -R "$APP_USER:$APP_USER" "$APP_DIR"
|
|||||||
|
|
||||||
echo "[3/7] Repo klonen/aktualisieren"
|
echo "[3/7] Repo klonen/aktualisieren"
|
||||||
if [ -d "$APP_DIR/.git" ]; then
|
if [ -d "$APP_DIR/.git" ]; then
|
||||||
sudo -u "$APP_USER" git -C "$APP_DIR" fetch --all --prune
|
runuser -u "$APP_USER" -- git -C "$APP_DIR" fetch --all --prune
|
||||||
sudo -u "$APP_USER" git -C "$APP_DIR" reset --hard origin/main
|
runuser -u "$APP_USER" -- git -C "$APP_DIR" reset --hard origin/main
|
||||||
else
|
else
|
||||||
sudo -u "$APP_USER" git clone "$REPO_URL" "$APP_DIR"
|
runuser -u "$APP_USER" -- git clone "$REPO_URL" "$APP_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[4/7] Python-venv + Dependencies"
|
echo "[4/7] Python-venv + Dependencies"
|
||||||
cd "$APP_DIR/lxc-frontend"
|
cd "$APP_DIR/lxc-frontend"
|
||||||
sudo -u "$APP_USER" python3 -m venv .venv
|
runuser -u "$APP_USER" -- python3 -m venv .venv
|
||||||
sudo -u "$APP_USER" .venv/bin/pip install --upgrade pip
|
runuser -u "$APP_USER" -- .venv/bin/pip install --upgrade pip
|
||||||
sudo -u "$APP_USER" .venv/bin/pip install -r requirements.txt
|
runuser -u "$APP_USER" -- .venv/bin/pip install -r requirements.txt
|
||||||
|
|
||||||
echo "[5/7] .env anlegen falls fehlt"
|
echo "[5/7] .env anlegen falls fehlt"
|
||||||
if [ ! -f "$APP_DIR/lxc-frontend/.env" ]; then
|
if [ ! -f "$APP_DIR/lxc-frontend/.env" ]; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user