| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #!/usr/bin/env bash
- set -euo pipefail
- APP_DIR=/opt/okx-codex-trader
- OBSERVER_SERVICE=eth-nextgen-micro-observer.service
- EXECUTOR_SERVICE=bb-squeeze-executor.service
- SHORT_BIAS_SERVICE=short-bias-readonly-observer.service
- CALENDAR_SERVICE=calendar-fusion-observer.service
- FOCUSED_SERVICE=eth-focused-portfolio-observer.service
- sudo useradd --system --create-home --shell /usr/sbin/nologin okxbot 2>/dev/null || true
- sudo mkdir -p "$APP_DIR" /etc/okx-codex-trader
- sudo rsync -a --delete \
- --exclude .git \
- --exclude .venv \
- --exclude .pytest_cache \
- --exclude data \
- --exclude var \
- ./ "$APP_DIR"/
- sudo apt-get update
- sudo apt-get install -y python3-venv
- sudo python3 -m venv "$APP_DIR/.venv"
- sudo "$APP_DIR/.venv/bin/python" -m pip install --upgrade pip
- sudo "$APP_DIR/.venv/bin/python" -m pip install backtesting requests pandas pytest
- sudo mkdir -p "$APP_DIR/var"
- sudo chown -R okxbot:okxbot "$APP_DIR"
- if [ ! -f /etc/okx-codex-trader/okx.env ]; then
- sudo tee /etc/okx-codex-trader/okx.env >/dev/null <<'ENV'
- OKX_TRADING_ENV=live
- OKX_API_KEY=
- OKX_API_SECRET=
- OKX_API_PASSPHRASE=
- ENV
- sudo chmod 600 /etc/okx-codex-trader/okx.env
- fi
- sudo install -m 0644 "$APP_DIR/deploy/$OBSERVER_SERVICE" "/etc/systemd/system/$OBSERVER_SERVICE"
- sudo install -m 0644 "$APP_DIR/deploy/$EXECUTOR_SERVICE" "/etc/systemd/system/$EXECUTOR_SERVICE"
- sudo install -m 0644 "$APP_DIR/deploy/$SHORT_BIAS_SERVICE" "/etc/systemd/system/$SHORT_BIAS_SERVICE"
- sudo install -m 0644 "$APP_DIR/deploy/$CALENDAR_SERVICE" "/etc/systemd/system/$CALENDAR_SERVICE"
- sudo install -m 0644 "$APP_DIR/deploy/$FOCUSED_SERVICE" "/etc/systemd/system/$FOCUSED_SERVICE"
- sudo systemctl daemon-reload
- sudo systemctl disable --now eth-nextgen-micro-executor.service 2>/dev/null || true
- sudo systemctl enable "$OBSERVER_SERVICE"
- sudo systemctl enable "$EXECUTOR_SERVICE"
- sudo systemctl enable "$SHORT_BIAS_SERVICE"
- sudo systemctl enable "$CALENDAR_SERVICE"
- sudo systemctl enable "$FOCUSED_SERVICE"
- sudo systemctl restart "$OBSERVER_SERVICE"
- sudo systemctl restart "$EXECUTOR_SERVICE"
- sudo systemctl restart "$SHORT_BIAS_SERVICE"
- sudo systemctl restart "$CALENDAR_SERVICE"
- sudo systemctl restart "$FOCUSED_SERVICE"
- sudo systemctl status "$OBSERVER_SERVICE" --no-pager
- sudo systemctl status "$EXECUTOR_SERVICE" --no-pager
- sudo systemctl status "$SHORT_BIAS_SERVICE" --no-pager
- sudo systemctl status "$CALENDAR_SERVICE" --no-pager
- sudo systemctl status "$FOCUSED_SERVICE" --no-pager
|