install_eth_nextgen_micro_observer.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. APP_DIR=/opt/okx-codex-trader
  4. OBSERVER_SERVICE=eth-nextgen-micro-observer.service
  5. EXECUTOR_SERVICE=bb-squeeze-executor.service
  6. SHORT_BIAS_SERVICE=short-bias-readonly-observer.service
  7. CALENDAR_SERVICE=calendar-fusion-observer.service
  8. FOCUSED_SERVICE=eth-focused-portfolio-observer.service
  9. BB_T_GATED_SERVICE=bb-squeeze-t-gated-observer.service
  10. sudo useradd --system --create-home --shell /usr/sbin/nologin okxbot 2>/dev/null || true
  11. sudo mkdir -p "$APP_DIR" /etc/okx-codex-trader
  12. sudo rsync -a --delete \
  13. --exclude .git \
  14. --exclude .venv \
  15. --exclude .pytest_cache \
  16. --exclude data \
  17. --exclude var \
  18. ./ "$APP_DIR"/
  19. sudo apt-get update
  20. sudo apt-get install -y python3-venv
  21. sudo python3 -m venv "$APP_DIR/.venv"
  22. sudo "$APP_DIR/.venv/bin/python" -m pip install --upgrade pip
  23. sudo "$APP_DIR/.venv/bin/python" -m pip install backtesting requests pandas pytest
  24. sudo mkdir -p "$APP_DIR/var"
  25. sudo chown -R okxbot:okxbot "$APP_DIR"
  26. if [ ! -f /etc/okx-codex-trader/okx.env ]; then
  27. sudo tee /etc/okx-codex-trader/okx.env >/dev/null <<'ENV'
  28. OKX_TRADING_ENV=live
  29. OKX_API_KEY=
  30. OKX_API_SECRET=
  31. OKX_API_PASSPHRASE=
  32. ENV
  33. sudo chmod 600 /etc/okx-codex-trader/okx.env
  34. fi
  35. sudo install -m 0644 "$APP_DIR/deploy/$OBSERVER_SERVICE" "/etc/systemd/system/$OBSERVER_SERVICE"
  36. sudo install -m 0644 "$APP_DIR/deploy/$EXECUTOR_SERVICE" "/etc/systemd/system/$EXECUTOR_SERVICE"
  37. sudo install -m 0644 "$APP_DIR/deploy/$SHORT_BIAS_SERVICE" "/etc/systemd/system/$SHORT_BIAS_SERVICE"
  38. sudo install -m 0644 "$APP_DIR/deploy/$CALENDAR_SERVICE" "/etc/systemd/system/$CALENDAR_SERVICE"
  39. sudo install -m 0644 "$APP_DIR/deploy/$FOCUSED_SERVICE" "/etc/systemd/system/$FOCUSED_SERVICE"
  40. sudo install -m 0644 "$APP_DIR/deploy/$BB_T_GATED_SERVICE" "/etc/systemd/system/$BB_T_GATED_SERVICE"
  41. sudo systemctl daemon-reload
  42. sudo systemctl disable --now eth-nextgen-micro-executor.service 2>/dev/null || true
  43. sudo systemctl enable "$OBSERVER_SERVICE"
  44. sudo systemctl enable "$EXECUTOR_SERVICE"
  45. sudo systemctl enable "$SHORT_BIAS_SERVICE"
  46. sudo systemctl enable "$CALENDAR_SERVICE"
  47. sudo systemctl enable "$FOCUSED_SERVICE"
  48. sudo systemctl enable "$BB_T_GATED_SERVICE"
  49. sudo systemctl restart "$OBSERVER_SERVICE"
  50. sudo systemctl restart "$EXECUTOR_SERVICE"
  51. sudo systemctl restart "$SHORT_BIAS_SERVICE"
  52. sudo systemctl restart "$CALENDAR_SERVICE"
  53. sudo systemctl restart "$FOCUSED_SERVICE"
  54. sudo systemctl restart "$BB_T_GATED_SERVICE"
  55. sudo systemctl status "$OBSERVER_SERVICE" --no-pager
  56. sudo systemctl status "$EXECUTOR_SERVICE" --no-pager
  57. sudo systemctl status "$SHORT_BIAS_SERVICE" --no-pager
  58. sudo systemctl status "$CALENDAR_SERVICE" --no-pager
  59. sudo systemctl status "$FOCUSED_SERVICE" --no-pager
  60. sudo systemctl status "$BB_T_GATED_SERVICE" --no-pager