Skip to content

Commit 11c9eb9

Browse files
authored
Install script fix (#5)
1 parent 6470e3c commit 11c9eb9

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

install.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
REPO="dcodesdev/clawd"
5-
INSTALL_DIR="${CLAWD_INSTALL_DIR:-/usr/local/bin}"
5+
INSTALL_DIR="${CLAWD_INSTALL_DIR:-$HOME/.local/bin}"
66
BINARY_NAME="clawd"
77

88
# Colors for output
@@ -60,7 +60,7 @@ download_binary() {
6060
local filename="${BINARY_NAME}-${os}-${arch}${ext}"
6161
local url="https://github.com/${REPO}/releases/download/${version}/${filename}"
6262

63-
info "Downloading ${filename} (${version})..."
63+
printf "${GREEN}[INFO]${NC} Downloading ${filename} (${version})...\n" >&2
6464

6565
local tmp_dir
6666
tmp_dir=$(mktemp -d)
@@ -76,7 +76,7 @@ download_binary() {
7676
local checksums_file="${tmp_dir}/checksums.sha256"
7777

7878
if curl -fsSL "$checksum_url" -o "$checksums_file" 2>/dev/null; then
79-
info "Verifying checksum..."
79+
printf "${GREEN}[INFO]${NC} Verifying checksum...\n" >&2
8080
local expected_checksum
8181
expected_checksum=$(grep "$filename" "$checksums_file" | awk '{print $1}')
8282

@@ -95,19 +95,24 @@ download_binary() {
9595
rm -rf "$tmp_dir"
9696
error "Checksum verification failed!"
9797
fi
98-
info "Checksum verified!"
98+
printf "${GREEN}[INFO]${NC} Checksum verified!\n" >&2
9999
fi
100100
else
101101
warn "Could not download checksums, skipping verification"
102102
fi
103103

104-
echo "$tmp_file"
104+
printf '%s' "$tmp_file"
105105
}
106106

107107
install_binary() {
108108
local tmp_file="$1"
109109
local install_path="${INSTALL_DIR}/${BINARY_NAME}"
110110

111+
# Create install directory if it doesn't exist
112+
if [ ! -d "$INSTALL_DIR" ]; then
113+
mkdir -p "$INSTALL_DIR"
114+
fi
115+
111116
chmod +x "$tmp_file"
112117

113118
if [ -w "$INSTALL_DIR" ]; then
@@ -118,6 +123,15 @@ install_binary() {
118123
fi
119124

120125
info "Installed to ${install_path}"
126+
127+
# Check if install directory is in PATH
128+
case ":$PATH:" in
129+
*":$INSTALL_DIR:"*) ;;
130+
*)
131+
warn "${INSTALL_DIR} is not in your PATH"
132+
info "Add it by running: export PATH=\"\$PATH:${INSTALL_DIR}\""
133+
;;
134+
esac
121135
}
122136

123137
main() {

0 commit comments

Comments
 (0)