-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·101 lines (87 loc) · 2.07 KB
/
install.sh
File metadata and controls
executable file
·101 lines (87 loc) · 2.07 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
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SOURCE_BIN="$SCRIPT_DIR/bin/agentlayer"
BIN_DIR="${HOME}/.local/bin"
LINK_MODE="symlink"
FORCE=0
usage() {
cat <<'EOF'
agentlayer installer
Usage:
bash install.sh [options]
Options:
--bin-dir PATH Destination directory for the installed command
--copy Copy the binary instead of creating a symlink
--force Replace an existing target file if present
--help Show this help
Examples:
bash install.sh
bash install.sh --bin-dir "$HOME/bin"
bash install.sh --copy --force
EOF
}
die() {
printf 'ERROR: %s\n' "$*" >&2
exit 1
}
while [ $# -gt 0 ]; do
case "$1" in
--bin-dir)
BIN_DIR="${2:-}"
shift 2
;;
--copy)
LINK_MODE="copy"
shift
;;
--force)
FORCE=1
shift
;;
--help|-h)
usage
exit 0
;;
*)
die "Unknown argument: $1"
;;
esac
done
[ -f "$SOURCE_BIN" ] || die "Missing CLI at $SOURCE_BIN"
case "$SCRIPT_DIR" in
/tmp/*|/private/tmp/*|/var/folders/*|/var/tmp/*)
printf 'WARN: installing from a volatile path (%s). The symlink will break when the OS cleans this directory.\n' "$SCRIPT_DIR" >&2
printf ' Clone into a persistent location (for example ~/.agentlayer) and re-run install.sh.\n' >&2
;;
esac
mkdir -p "$BIN_DIR"
TARGET_BIN="$BIN_DIR/agentlayer"
if [ -e "$TARGET_BIN" ] || [ -L "$TARGET_BIN" ]; then
[ "$FORCE" -eq 1 ] || die "Target already exists: $TARGET_BIN (use --force to replace it)"
rm -f "$TARGET_BIN"
fi
case "$LINK_MODE" in
symlink)
ln -s "$SOURCE_BIN" "$TARGET_BIN"
;;
copy)
cp "$SOURCE_BIN" "$TARGET_BIN"
chmod +x "$TARGET_BIN"
;;
*)
die "Unsupported install mode: $LINK_MODE"
;;
esac
printf 'Installed agentlayer at %s\n' "$TARGET_BIN"
case ":$PATH:" in
*":$BIN_DIR:"*)
printf 'PATH already includes %s\n' "$BIN_DIR"
;;
*)
printf 'Add this to your shell profile if needed:\n'
printf ' export PATH="%s:$PATH"\n' "$BIN_DIR"
;;
esac
printf 'Try:\n'
printf ' agentlayer --help\n'