forked from zeroclaw-labs/zeroclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzeroclaw_install.sh
More file actions
executable file
·93 lines (78 loc) · 2.16 KB
/
zeroclaw_install.sh
File metadata and controls
executable file
·93 lines (78 loc) · 2.16 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
#!/usr/bin/env sh
set -eu
have_cmd() {
command -v "$1" >/dev/null 2>&1
}
run_privileged() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
elif have_cmd sudo; then
sudo "$@"
else
echo "error: sudo is required to install missing dependencies." >&2
exit 1
fi
}
is_container_runtime() {
if [ -f /.dockerenv ] || [ -f /run/.containerenv ]; then
return 0
fi
if [ -r /proc/1/cgroup ] && grep -Eq '(docker|containerd|kubepods|podman|lxc)' /proc/1/cgroup; then
return 0
fi
return 1
}
run_pacman() {
if ! is_container_runtime; then
run_privileged pacman "$@"
return $?
fi
PACMAN_CFG_TMP="$(mktemp /tmp/zeroclaw-pacman.XXXXXX.conf)"
cp /etc/pacman.conf "$PACMAN_CFG_TMP"
if ! grep -Eq '^[[:space:]]*DisableSandboxSyscalls([[:space:]]|$)' "$PACMAN_CFG_TMP"; then
printf '\nDisableSandboxSyscalls\n' >> "$PACMAN_CFG_TMP"
fi
if run_privileged pacman --config "$PACMAN_CFG_TMP" "$@"; then
PACMAN_RC=0
else
PACMAN_RC=$?
fi
rm -f "$PACMAN_CFG_TMP"
return "$PACMAN_RC"
}
ensure_bash() {
if have_cmd bash; then
return 0
fi
echo "==> bash not found; attempting to install it"
if have_cmd apk; then
run_privileged apk add --no-cache bash
elif have_cmd apt-get; then
run_privileged apt-get update -qq
run_privileged apt-get install -y bash
elif have_cmd dnf; then
run_privileged dnf install -y bash
elif have_cmd pacman; then
run_pacman -Sy --noconfirm
run_pacman -S --noconfirm --needed bash
else
echo "error: unsupported package manager; install bash manually and retry." >&2
exit 1
fi
}
ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" >/dev/null 2>&1 && pwd || pwd)"
BOOTSTRAP_SCRIPT="$ROOT_DIR/scripts/bootstrap.sh"
if [ ! -f "$BOOTSTRAP_SCRIPT" ]; then
echo "error: scripts/bootstrap.sh not found from repository root." >&2
exit 1
fi
ensure_bash
if [ "$#" -eq 0 ]; then
if [ -t 0 ] && [ -t 1 ]; then
# Default one-click interactive path: guided install + full-screen TUI onboarding.
exec bash "$BOOTSTRAP_SCRIPT" --guided --interactive-onboard
fi
# Non-interactive no-arg path remains install-only.
exec bash "$BOOTSTRAP_SCRIPT"
fi
exec bash "$BOOTSTRAP_SCRIPT" "$@"