install_eth_nextgen_micro_observer.sh 3.0 KB

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