This commit is contained in:
2026-05-03 23:55:01 -04:00
parent 8b96dd1465
commit 842c50bb6a

View File

@@ -24,8 +24,12 @@ echo "Installing crypto-trader to $INSTALL_DIR ..."
mkdir -p "$INSTALL_DIR" mkdir -p "$INSTALL_DIR"
# ── 2. Copy project files ───────────────────────────────────────────────── # ── 2. Copy project files ─────────────────────────────────────────────────
rsync -a --exclude='.git' --exclude='venv' --exclude='__pycache__' \ # Skip if already running from the install directory
"$SCRIPT_DIR/" "$INSTALL_DIR/" if [ "$SCRIPT_DIR" != "$INSTALL_DIR" ]; then
for item in *.py *.txt *.sh *.md .env.example systemd; do
[ -e "$SCRIPT_DIR/$item" ] && cp -r "$SCRIPT_DIR/$item" "$INSTALL_DIR/"
done
fi
# ── 3. Create dedicated system user ────────────────────────────────────── # ── 3. Create dedicated system user ──────────────────────────────────────
if ! id -u "$SERVICE_USER" &>/dev/null; then if ! id -u "$SERVICE_USER" &>/dev/null; then
@@ -45,13 +49,16 @@ if [ ! -f "$INSTALL_DIR/.env" ]; then
fi fi
# ── 5. Python virtual environment ───────────────────────────────────────── # ── 5. Python virtual environment ─────────────────────────────────────────
if ! command -v python3 &>/dev/null; then # python3 is pre-installed on Ubuntu but python3-venv is a separate package
echo "Installing python3-venv ..." # that is frequently absent — install it unconditionally (apt is idempotent)
apt-get install -y python3-venv python3-pip echo "Ensuring python3-venv and pip are available..."
fi apt-get install -y python3-venv python3-pip
if [ ! -d "$INSTALL_DIR/venv" ]; then if [ ! -d "$INSTALL_DIR/venv" ]; then
python3 -m venv "$INSTALL_DIR/venv" python3 -m venv "$INSTALL_DIR/venv" || {
echo "ERROR: 'python3 -m venv' failed. Try: apt-get install python3-venv"
exit 1
}
fi fi
"$INSTALL_DIR/venv/bin/pip" install --upgrade pip -q "$INSTALL_DIR/venv/bin/pip" install --upgrade pip -q
"$INSTALL_DIR/venv/bin/pip" install -r "$INSTALL_DIR/requirements.txt" -q "$INSTALL_DIR/venv/bin/pip" install -r "$INSTALL_DIR/requirements.txt" -q