Fix deployment and load latest Codex models

This commit is contained in:
2026-07-15 20:31:23 +02:00
parent 654cd0e87c
commit 0a0f8821ce
4 changed files with 74 additions and 23 deletions

View File

@@ -6,8 +6,9 @@ Wants=network-online.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/codex-tg-bot
WorkingDirectory=@PROJECT_DIR@
EnvironmentFile=/etc/codex-tg-bot/.env
Environment=PATH=/opt/codex-tg-bot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
ExecStart=/opt/codex-tg-bot/venv/bin/python -m bot.main
Restart=on-failure
RestartSec=5

View File

@@ -15,21 +15,25 @@ if [[ $EUID -ne 0 ]]; then
fi
echo "==> Checking prerequisites"
if ! command -v python3 >/dev/null; then
echo "ERROR: python3 not found. Install it, for example: apt install python3 python3-venv" >&2
if ! command -v python3 >/dev/null || ! command -v curl >/dev/null; then
echo "ERROR: python3 and curl are required" >&2
exit 1
fi
echo "==> Copying project to $INSTALL_DIR"
echo "==> Preparing runtime in $INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
cp -r "$PROJECT_DIR/bot" "$PROJECT_DIR/requirements.txt" "$INSTALL_DIR/"
echo "==> Creating virtualenv and installing dependencies"
if [[ ! -d "$INSTALL_DIR/venv" ]]; then
python3 -m venv "$INSTALL_DIR/venv"
fi
"$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 --upgrade --pre -r "$PROJECT_DIR/requirements.txt" -q
echo "==> Installing current standalone Codex runtime"
mkdir -p "$INSTALL_DIR/bin"
curl -fsSL https://chatgpt.com/codex/install.sh \
| CODEX_NON_INTERACTIVE=1 CODEX_INSTALL_DIR="$INSTALL_DIR/bin" sh
echo "==> Setting up config in $CONFIG_DIR"
mkdir -p "$CONFIG_DIR"
@@ -44,9 +48,13 @@ if [[ ! -f "$CONFIG_DIR/.env" ]]; then
fi
echo "==> Installing systemd service"
cp "$PROJECT_DIR/deploy/$SERVICE_NAME.service" "/etc/systemd/system/$SERVICE_NAME.service"
escaped_project_dir="${PROJECT_DIR//&/\\&}"
sed "s|@PROJECT_DIR@|$escaped_project_dir|g" \
"$PROJECT_DIR/deploy/$SERVICE_NAME.service" \
> "/etc/systemd/system/$SERVICE_NAME.service"
systemctl daemon-reload
systemctl enable --now "$SERVICE_NAME"
systemctl enable "$SERVICE_NAME"
systemctl restart "$SERVICE_NAME"
echo "==> Done"
systemctl --no-pager status "$SERVICE_NAME" || true