|
|
|
|
@@ -11,6 +11,9 @@ VENV_DIR="${MIRAGE_VENV_DIR:-/opt/mirage/venv}"
|
|
|
|
|
|
|
|
|
|
PYTHON_BIN="${PYTHON_BIN:-python3}"
|
|
|
|
|
|
|
|
|
|
CONFIG_DIR="/etc/mirage"
|
|
|
|
|
CONFIG_FILE="$CONFIG_DIR/config.toml"
|
|
|
|
|
|
|
|
|
|
echo "==> Using python: $PYTHON_BIN"
|
|
|
|
|
echo "==> Mirage user: $MIRAGE_USER"
|
|
|
|
|
echo "==> Mirage group: $MIRAGE_GROUP"
|
|
|
|
|
@@ -18,6 +21,7 @@ echo "==> Mirror root: $MIRROR_ROOT"
|
|
|
|
|
echo "==> Data dir: $DATA_DIR"
|
|
|
|
|
echo "==> Log dir: $LOG_DIR"
|
|
|
|
|
echo "==> Venv dir: $VENV_DIR"
|
|
|
|
|
echo "==> Config file: $CONFIG_FILE"
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then
|
|
|
|
|
@@ -38,10 +42,48 @@ if ! id "$MIRAGE_USER" >/dev/null 2>&1; then
|
|
|
|
|
"$MIRAGE_USER"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "==> Creating directories"
|
|
|
|
|
echo "==> Creating data/log/mirror directories"
|
|
|
|
|
mkdir -p "$MIRROR_ROOT" "$DATA_DIR" "$LOG_DIR"
|
|
|
|
|
chown -R "$MIRAGE_USER:$MIRAGE_GROUP" "$MIRROR_ROOT" "$DATA_DIR" "$LOG_DIR"
|
|
|
|
|
|
|
|
|
|
echo "==> Installing default config in /etc/mirage (if missing)"
|
|
|
|
|
mkdir -p "$CONFIG_DIR"
|
|
|
|
|
|
|
|
|
|
if [ -f "$CONFIG_FILE" ]; then
|
|
|
|
|
echo " Config already exists at $CONFIG_FILE (leaving it untouched)"
|
|
|
|
|
else
|
|
|
|
|
if [ -f "./etc/mirage/config.toml" ]; then
|
|
|
|
|
echo " Using repo template ./etc/mirage/config.toml"
|
|
|
|
|
install -D -m 644 ./etc/mirage/config.toml "$CONFIG_FILE"
|
|
|
|
|
else
|
|
|
|
|
echo " No template found, generating a basic config at $CONFIG_FILE"
|
|
|
|
|
cat >"$CONFIG_FILE" <<EOF
|
|
|
|
|
# Mirage configuration
|
|
|
|
|
# This file was generated by scripts/install.sh
|
|
|
|
|
# Paths must be writable by the 'mirage' user.
|
|
|
|
|
|
|
|
|
|
# Root directory where mirror content is stored.
|
|
|
|
|
mirror_root = "${MIRROR_ROOT}"
|
|
|
|
|
|
|
|
|
|
# Directory for mirage internal state (queue DB, etc.)
|
|
|
|
|
data_dir = "${DATA_DIR}"
|
|
|
|
|
|
|
|
|
|
# Directory for log files (per-mirror logs, daemon logs, etc.)
|
|
|
|
|
log_dir = "${LOG_DIR}"
|
|
|
|
|
|
|
|
|
|
# Path to wget binary
|
|
|
|
|
wget_bin = "/usr/bin/wget"
|
|
|
|
|
|
|
|
|
|
# Maximum number of concurrent mirror updates
|
|
|
|
|
max_concurrent_updates = 4
|
|
|
|
|
EOF
|
|
|
|
|
chmod 644 "$CONFIG_FILE"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Typical /etc ownership: root:root
|
|
|
|
|
chown root:root "$CONFIG_FILE"
|
|
|
|
|
|
|
|
|
|
echo "==> Creating virtualenv at $VENV_DIR"
|
|
|
|
|
mkdir -p "$(dirname "$VENV_DIR")"
|
|
|
|
|
"$PYTHON_BIN" -m venv "$VENV_DIR"
|
|
|
|
|
@@ -69,10 +111,14 @@ 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"
|
|
|
|
|
cat <<EOF
|
|
|
|
|
|
|
|
|
|
==> Install complete.
|
|
|
|
|
|
|
|
|
|
Mirrors root : $MIRROR_ROOT
|
|
|
|
|
Data dir : $DATA_DIR
|
|
|
|
|
Log dir : $LOG_DIR
|
|
|
|
|
Config : $CONFIG_FILE
|
|
|
|
|
Venv : $VENV_DIR
|
|
|
|
|
Binary : $MIRAGE_BIN
|
|
|
|
|
EOF
|
|
|
|
|
|