-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·82 lines (69 loc) · 1.96 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·82 lines (69 loc) · 1.96 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
#!/usr/bin/env bash
set -e
INSTALL_DIR="${HOME}/.local/lib/opencode-remote-ctrl"
BIN_LINK="${HOME}/.local/bin/opencode-remote-ctrl"
BIN_NAME="opencode-remote-ctrl"
echo ""
echo "━━━ Installing ${BIN_NAME} ━━━"
echo ""
# Check if node is available
if ! command -v node &> /dev/null; then
echo "✗ Node.js is not installed"
echo " Install from: https://nodejs.org"
exit 1
fi
NODE_PATH="$(command -v node)"
echo "✓ Found Node.js at ${NODE_PATH}"
# Create install directory
mkdir -p "${INSTALL_DIR}"
# Copy source files
cd "$(dirname "$0")"
cp -r src "${INSTALL_DIR}/"
# Create package.json
cat > "${INSTALL_DIR}/package.json" << 'PKGJSON'
{
"name": "opencode-remote-ctrl",
"version": "1.1.0",
"type": "module"
}
PKGJSON
# Create bin symlink
rm -f "${BIN_LINK}"
cat > "${BIN_LINK}" << 'WRAPPER'
#!/usr/bin/env bash
exec node "$(dirname "$(readlink -f "$0")")/../lib/opencode-remote-ctrl/src/cli.js" "$@"
WRAPPER
chmod +x "${BIN_LINK}"
# Add to PATH if not already there
BASHRC="${HOME}/.bashrc"
ZSHRC="${HOME}/.zshrc"
SHELL_RC=""
PATH_LINE="export PATH=\"${HOME}/.local/bin:\$PATH\""
# Detect which rc file to use
if [ -f "$ZSHRC" ]; then
SHELL_RC="$ZSHRC"
elif [ -f "$BASHRC" ]; then
SHELL_RC="$BASHRC"
fi
# Check if PATH line already exists
if [ -n "$SHELL_RC" ] && ! grep -q "${HOME}/.local/bin" "$SHELL_RC" 2>/dev/null; then
echo "" >> "$SHELL_RC"
echo "# Added by ${BIN_NAME}" >> "$SHELL_RC"
echo "${PATH_LINE}" >> "$SHELL_RC"
echo "✓ Added ~/.local/bin to PATH in ${SHELL_RC}"
elif [ -n "$SHELL_RC" ]; then
echo "✓ ~/.local/bin already in PATH"
else
echo "⚠ Could not find .bashrc or .zshrc"
echo " Please add this line to your shell config:"
echo " ${PATH_LINE}"
fi
echo ""
echo "━━━ Installation Complete ━━━"
echo ""
echo "✓ ${BIN_NAME} installed to ${BIN_LINK}"
echo ""
echo "Next steps:"
echo " 1. Run: source ~/.bashrc (or open a new terminal)"
echo " 2. Then: ${BIN_NAME} start"
echo ""