Fix install script

This commit is contained in:
2025-12-02 05:14:03 -05:00
parent c0f308761b
commit 9b21a43c62
3 changed files with 32 additions and 7 deletions

View File

@@ -7,6 +7,23 @@ MIRAGE_GROUP="${MIRAGE_GROUP:-mirage}"
MIRROR_ROOT="${MIRAGE_MIRROR_ROOT:-/srv/www/mirrors}"
DATA_DIR="${MIRAGE_DATA_DIR:-/var/lib/mirage}"
LOG_DIR="${MIRAGE_LOG_DIR:-/var/log/mirage}"
VENV_DIR="${MIRAGE_VENV_DIR:-/opt/mirage/venv}"
PYTHON_BIN="${PYTHON_BIN:-python3}"
echo "==> Using python: $PYTHON_BIN"
echo "==> Mirage user: $MIRAGE_USER"
echo "==> Mirage group: $MIRAGE_GROUP"
echo "==> Mirror root: $MIRROR_ROOT"
echo "==> Data dir: $DATA_DIR"
echo "==> Log dir: $LOG_DIR"
echo "==> Venv dir: $VENV_DIR"
echo
if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then
echo "ERROR: $PYTHON_BIN not found" >&2
exit 1
fi
echo "==> Creating mirage user/group (if needed)"
if ! getent group "$MIRAGE_GROUP" >/dev/null 2>&1; then
@@ -25,12 +42,18 @@ echo "==> Creating directories"
mkdir -p "$MIRROR_ROOT" "$DATA_DIR" "$LOG_DIR"
chown -R "$MIRAGE_USER:$MIRAGE_GROUP" "$MIRROR_ROOT" "$DATA_DIR" "$LOG_DIR"
echo "==> Installing mirage Python package (pip install .)"
pip install .
echo "==> Creating virtualenv at $VENV_DIR"
mkdir -p "$(dirname "$VENV_DIR")"
"$PYTHON_BIN" -m venv "$VENV_DIR"
MIRAGE_BIN="$(command -v mirage || true)"
if [ -z "$MIRAGE_BIN" ]; then
echo "ERROR: 'mirage' not found in PATH after pip install" >&2
echo "==> Installing mirage into virtualenv"
"$VENV_DIR/bin/pip" install --upgrade pip setuptools wheel
"$VENV_DIR/bin/pip" install .
MIRAGE_BIN="$VENV_DIR/bin/mirage"
if [ ! -x "$MIRAGE_BIN" ]; then
echo "ERROR: $MIRAGE_BIN not found or not executable" >&2
exit 1
fi
@@ -46,8 +69,10 @@ echo "==> Enabling and starting mirage daemon + timer"
systemctl enable --now mirage.service
systemctl enable --now mirage-update.timer
echo
echo "==> Done."
echo "Mirrors root : $MIRROR_ROOT"
echo "Data dir : $DATA_DIR"
echo "Log dir : $LOG_DIR"
echo "Venv : $VENV_DIR"
echo "Binary : $MIRAGE_BIN"

View File

@@ -5,5 +5,5 @@ Description=Enqueue periodic updates for Mirage mirrors
Type=oneshot
User=mirage
Group=mirage
ExecStart=/usr/bin/mirage mirrors update-all
ExecStart=/opt/mirage/venv/bin/mirage mirrors update-all
WorkingDirectory=/var/lib/mirage

View File

@@ -7,7 +7,7 @@ Wants=network-online.target
Type=simple
User=mirage
Group=mirage
ExecStart=/usr/bin/mirage daemon
ExecStart=/opt/mirage/venv/bin/mirage daemon
Restart=on-failure
RestartSec=5
WorkingDirectory=/var/lib/mirage