-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·138 lines (119 loc) · 4.71 KB
/
install.sh
File metadata and controls
executable file
·138 lines (119 loc) · 4.71 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env bash
#
# Install ocdc
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/athal7/ocdc/main/install.sh | bash
# curl -fsSL https://raw.githubusercontent.com/athal7/ocdc/main/install.sh | bash -s -- ~/.local/bin
#
set -euo pipefail
INSTALL_DIR="${1:-$HOME/.local/bin}"
LIB_DIR="$INSTALL_DIR/../lib"
REPO="athal7/ocdc"
LIB_SCRIPTS="ocdc-up ocdc-down ocdc-list ocdc-exec ocdc-go ocdc-tui ocdc-clean ocdc-poll ocdc-paths.bash ocdc-sessions.bash ocdc-poll-config.bash ocdc-poll-defaults.bash ocdc-poll-fetch.bash ocdc-poll-filter.bash ocdc-file-lock.bash ocdc-yaml.bash ocdc-mcp-fetch.js"
echo "Installing ocdc to $INSTALL_DIR"
# Create install directories
mkdir -p "$INSTALL_DIR"
mkdir -p "$LIB_DIR"
# Check if we're running from a local clone or need to download
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" 2>/dev/null)" && pwd 2>/dev/null)" || SCRIPT_DIR=""
if [[ -n "$SCRIPT_DIR" ]] && [[ -f "$SCRIPT_DIR/bin/ocdc" ]]; then
# Local install from clone
echo "Installing from local directory..."
# Install main executable
cp "$SCRIPT_DIR/bin/ocdc" "$INSTALL_DIR/ocdc"
chmod +x "$INSTALL_DIR/ocdc"
echo " Installed: bin/ocdc"
# Install lib scripts
for script in $LIB_SCRIPTS; do
if [[ -f "$SCRIPT_DIR/lib/$script" ]]; then
cp "$SCRIPT_DIR/lib/$script" "$LIB_DIR/$script"
chmod +x "$LIB_DIR/$script"
echo " Installed: lib/$script"
fi
done
# Install Node.js dependencies for MCP fetch
if [[ -f "$SCRIPT_DIR/package.json" ]]; then
cp "$SCRIPT_DIR/package.json" "$LIB_DIR/package.json"
cp "$SCRIPT_DIR/package-lock.json" "$LIB_DIR/package-lock.json" 2>/dev/null || true
echo " Installing Node.js dependencies..."
(cd "$LIB_DIR" && npm ci --omit=dev --silent 2>/dev/null) || \
(cd "$LIB_DIR" && npm install --omit=dev --silent 2>/dev/null) || \
echo " WARNING: npm install failed. Poll MCP sources may not work."
fi
else
# Remote install - download from GitHub
echo "Downloading from GitHub..."
# Download main executable
echo " Downloading: bin/ocdc"
if curl -fsSL "https://raw.githubusercontent.com/$REPO/main/bin/ocdc" -o "$INSTALL_DIR/ocdc"; then
chmod +x "$INSTALL_DIR/ocdc"
echo " Installed: bin/ocdc"
else
echo " ERROR: Failed to download ocdc"
exit 1
fi
# Download lib scripts
for script in $LIB_SCRIPTS; do
echo " Downloading: lib/$script"
if curl -fsSL "https://raw.githubusercontent.com/$REPO/main/lib/$script" -o "$LIB_DIR/$script"; then
chmod +x "$LIB_DIR/$script"
echo " Installed: lib/$script"
else
echo " ERROR: Failed to download $script"
exit 1
fi
done
# Download and install Node.js dependencies for MCP fetch
echo " Downloading: package.json"
curl -fsSL "https://raw.githubusercontent.com/$REPO/main/package.json" -o "$LIB_DIR/package.json" || true
curl -fsSL "https://raw.githubusercontent.com/$REPO/main/package-lock.json" -o "$LIB_DIR/package-lock.json" 2>/dev/null || true
if [[ -f "$LIB_DIR/package.json" ]]; then
echo " Installing Node.js dependencies..."
(cd "$LIB_DIR" && npm ci --omit=dev --silent 2>/dev/null) || \
(cd "$LIB_DIR" && npm install --omit=dev --silent 2>/dev/null) || \
echo " WARNING: npm install failed. Poll MCP sources may not work."
fi
fi
# Check if install dir is in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo ""
echo "Note: $INSTALL_DIR is not in your PATH."
echo "Add this to your shell profile:"
echo ""
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
fi
# Check dependencies
echo ""
echo "Checking dependencies..."
missing_deps=false
if ! command -v jq >/dev/null 2>&1; then
echo " WARNING: jq not found. Install with: brew install jq"
missing_deps=true
fi
if ! command -v node >/dev/null 2>&1; then
echo " WARNING: node not found. Required for poll MCP sources. Install with: brew install node"
missing_deps=true
fi
if ! command -v devcontainer >/dev/null 2>&1; then
echo " WARNING: devcontainer CLI not found. Install with: npm install -g @devcontainers/cli"
missing_deps=true
fi
if [[ "$missing_deps" == "false" ]]; then
echo " All dependencies found!"
fi
echo ""
echo "Installation complete!"
echo ""
echo "Commands:"
echo " ocdc # Launch TUI or show help"
echo " ocdc up [branch] # Start devcontainer"
echo " ocdc down # Stop devcontainer"
echo " ocdc list # List instances"
echo " ocdc go [branch] # Navigate to clone"
echo " ocdc exec <cmd> # Execute in container"
echo " ocdc poll # Run poll manually (once)"
echo ""
echo "Optional: Set up automatic polling"
echo " See: https://github.com/athal7/ocdc#automatic-polling-optional"
echo " Or install via Homebrew for automatic setup: brew install athal7/tap/ocdc"