-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathocean-cli
More file actions
executable file
·50 lines (45 loc) · 1.85 KB
/
Copy pathocean-cli
File metadata and controls
executable file
·50 lines (45 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# OCEAN Global CLI Script
# This script allows OCEAN to be run from anywhere on the system.
# Get the actual OCEAN directory (resolve symlink if needed)
if [[ -L "$0" ]]; then
# This script is a symlink, resolve it
SCRIPT_DIR="$(cd "$(dirname "$(readlink "$0")")" && pwd)"
else
# This script is the actual file
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
fi
ORIG_CWD="$(pwd)"
# Check if virtual environment exists
# Ensure virtual environment exists and is up to date
(
cd "$SCRIPT_DIR" || exit 1
# Best-effort: ensure global launcher points to this repo
GLOBAL_BIN="/usr/local/bin/ocean"
if [ -e "$GLOBAL_BIN" ]; then
TARGET_PATH="$(readlink "$GLOBAL_BIN" 2>/dev/null || echo '')"
if [ "$TARGET_PATH" != "$SCRIPT_DIR/ocean-cli" ]; then
if [ -w "$(dirname "$GLOBAL_BIN")" ]; then
ln -sf "$SCRIPT_DIR/ocean-cli" "$GLOBAL_BIN" 2>/dev/null || true
else
echo "[Ocean] Note: global 'ocean' points elsewhere ($TARGET_PATH). Use: sudo ln -sf \"$SCRIPT_DIR/ocean-cli\" \"$GLOBAL_BIN\"" >&2
fi
fi
else
if [ -w "$(dirname "$GLOBAL_BIN")" ]; then
ln -sf "$SCRIPT_DIR/ocean-cli" "$GLOBAL_BIN" 2>/dev/null || true
else
echo "[Ocean] Tip: install global launcher → sudo ln -sf \"$SCRIPT_DIR/ocean-cli\" \"$GLOBAL_BIN\"" >&2
fi
fi
if [ ! -d "venv" ]; then
echo "[Ocean] Creating virtual environment…"
python3 -m venv venv || { echo "Failed to create venv"; exit 1; }
fi
# Install/upgrade the package in editable mode inside the Ocean repo
. "venv/bin/activate" || { echo "Failed to activate venv"; exit 1; }
echo "[Ocean] Installing package (editable)…"
pip install -e . > /dev/null 2>&1 || { echo "pip install failed"; exit 1; }
) || exit 1
# Run the ocean command using the entrypoint function
"$SCRIPT_DIR/venv/bin/python" "$SCRIPT_DIR/ocean_entrypoint.py" "$@"