oasis.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/sh
  2. CURRENT_DIR=$(pwd)
  3. MODE=$1
  4. MODEL_PATH="$CURRENT_DIR/src/AI/oasis-42-1-chat.Q4_K_M.gguf"
  5. CONFIG_FILE="$CURRENT_DIR/src/configs/oasis-config.json"
  6. show_help() {
  7. cat <<'EOF'
  8. Usage: sh oasis.sh [mode] [-- <option>=<value> ...]
  9. Modes:
  10. gui Launch the Oasis web GUI (default).
  11. server Launch only the Oasis backend in headless / pub mode.
  12. help, -h Show this help message.
  13. PUB admin commands (require the sbot to be running: sh oasis.sh server):
  14. whoami Print this PUB id
  15. invite [N] Create an invite code (default uses=1)
  16. name <text> Set this PUB display name
  17. announce <host> [port] Publish a pub address (default port=8008)
  18. follow <feedId> Follow another PUB / feed
  19. status Show peer / replication status
  20. gossip List known gossip peers
  21. GUI options (forwarded to the backend):
  22. --host=<ip> Hostname / IP the web UI listens on (default: localhost).
  23. Use 0.0.0.0 to expose on a VPS.
  24. --port=<n> Port for the web UI (default: 3000).
  25. --allow-host=<host> Extra hostname allowed when behind a reverse proxy.
  26. --public Public-hosting mode: disables POST and redacts content
  27. from people who haven't opted in to public hosting.
  28. --offline Don't try to connect to Oasis peers / pubs.
  29. --no-open Don't auto-open a browser tab on launch (useful on a VPS).
  30. --debug Verbose logging.
  31. Examples:
  32. sh oasis.sh
  33. sh oasis.sh server
  34. sh oasis.sh invite 100
  35. sh oasis.sh name "My PUB"
  36. sh oasis.sh announce mypub.example.com
  37. sh oasis.sh --host=0.0.0.0 --port=8080 --no-open
  38. EOF
  39. }
  40. if [ -f "$CONFIG_FILE" ]; then
  41. if [ -f "$MODEL_PATH" ]; then
  42. sed -i.bak 's/"aiMod": *"off"/"aiMod": "on"/' "$CONFIG_FILE"
  43. else
  44. sed -i.bak 's/"aiMod": *"on"/"aiMod": "off"/' "$CONFIG_FILE"
  45. fi
  46. rm -f "$CONFIG_FILE.bak"
  47. fi
  48. case "$MODE" in
  49. help|-h|--help)
  50. show_help
  51. exit 0
  52. ;;
  53. server|pub)
  54. if [ -f "$CONFIG_FILE" ]; then
  55. sed -i.bak 's/"aiMod": *"on"/"aiMod": "off"/' "$CONFIG_FILE"
  56. sed -i.bak 's/"aiNavMod": *"on"/"aiNavMod": "off"/' "$CONFIG_FILE"
  57. rm -f "$CONFIG_FILE.bak"
  58. fi
  59. cd "$CURRENT_DIR/src/server" || exit 1
  60. exec node SSB_server.js start
  61. ;;
  62. whoami|invite|name|announce|follow|status|gossip)
  63. exec node "$CURRENT_DIR/scripts/oasis-pub.js" "$@"
  64. ;;
  65. gui)
  66. shift
  67. cd "$CURRENT_DIR/src/backend" || exit 1
  68. exec node backend.js "$@"
  69. ;;
  70. *)
  71. cd "$CURRENT_DIR/src/backend" || exit 1
  72. exec node backend.js "$@"
  73. ;;
  74. esac