Skip to content

Commit 241a6bf

Browse files
author
openclaw-installer-sync[bot]
committed
chore: sync installers from openclaw 82af6119faff
1 parent c8ede2c commit 241a6bf

2 files changed

Lines changed: 65 additions & 11 deletions

File tree

public/install-cli.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,34 @@ ensure_home_env() {
2929

3030
ensure_home_env
3131

32+
resolve_openclaw_effective_home() {
33+
local openclaw_home="${OPENCLAW_HOME:-}"
34+
if [[ -z "$openclaw_home" ]]; then
35+
echo "$HOME"
36+
return 0
37+
fi
38+
39+
case "$openclaw_home" in
40+
\~)
41+
echo "$HOME"
42+
;;
43+
\~/*)
44+
echo "${HOME}/${openclaw_home#~/}"
45+
;;
46+
*)
47+
echo "$openclaw_home"
48+
;;
49+
esac
50+
}
51+
52+
OPENCLAW_EFFECTIVE_HOME="$(resolve_openclaw_effective_home)"
3253
PREFIX="${OPENCLAW_PREFIX:-${HOME}/.openclaw}"
3354
OPENCLAW_VERSION="${OPENCLAW_VERSION:-latest}"
3455
NODE_VERSION="${OPENCLAW_NODE_VERSION:-22.22.0}"
3556
SHARP_IGNORE_GLOBAL_LIBVIPS="${SHARP_IGNORE_GLOBAL_LIBVIPS:-1}"
3657
NPM_LOGLEVEL="${OPENCLAW_NPM_LOGLEVEL:-error}"
3758
INSTALL_METHOD="${OPENCLAW_INSTALL_METHOD:-npm}"
38-
GIT_DIR="${OPENCLAW_GIT_DIR:-${HOME}/openclaw}"
59+
GIT_DIR="${OPENCLAW_GIT_DIR:-${OPENCLAW_EFFECTIVE_HOME}/openclaw}"
3960
GIT_UPDATE="${OPENCLAW_GIT_UPDATE:-1}"
4061
JSON=0
4162
RUN_ONBOARD=0
@@ -46,11 +67,11 @@ print_usage() {
4667
cat <<EOF
4768
Usage: install-cli.sh [options]
4869
--json Emit NDJSON events (no human output)
49-
--prefix <path> Install prefix (default: ~/.openclaw)
70+
--prefix <path> Install prefix (default: ~/.openclaw; use \$OPENCLAW_PREFIX to override)
5071
--install-method, --method npm|git Install via npm (default) or from a git checkout
5172
--npm Shortcut for --install-method npm
5273
--git, --github Shortcut for --install-method git
53-
--git-dir, --dir <path> Checkout directory (default: ~/openclaw)
74+
--git-dir, --dir <path> Checkout directory (default: ~/openclaw, or \$OPENCLAW_HOME/openclaw)
5475
--version <ver> OpenClaw version (default: latest)
5576
--node-version <ver> Node version (default: 22.22.0)
5677
--onboard Run "openclaw onboard" after install
@@ -61,6 +82,8 @@ Environment variables:
6182
SHARP_IGNORE_GLOBAL_LIBVIPS=0|1 Default: 1 (avoid sharp building against global libvips)
6283
OPENCLAW_NPM_LOGLEVEL=error|warn|notice Default: error (hide npm deprecation noise)
6384
OPENCLAW_INSTALL_METHOD=git|npm
85+
OPENCLAW_HOME=...
86+
OPENCLAW_PREFIX=...
6487
OPENCLAW_VERSION=latest|next|<semver>
6588
OPENCLAW_GIT_DIR=...
6689
OPENCLAW_GIT_UPDATE=0|1
@@ -100,7 +123,7 @@ download_file() {
100123
}
101124

102125
cleanup_legacy_submodules() {
103-
local repo_dir="${1:-${OPENCLAW_GIT_DIR:-${HOME}/openclaw}}"
126+
local repo_dir="${1:-${OPENCLAW_GIT_DIR:-${OPENCLAW_EFFECTIVE_HOME}/openclaw}}"
104127
local legacy_dir="${repo_dir}/Peekaboo"
105128
if [[ -d "$legacy_dir" ]]; then
106129
emit_json "{\"event\":\"step\",\"name\":\"legacy-submodule\",\"status\":\"start\",\"path\":\"${legacy_dir//\"/\\\"}\"}"

public/install.sh

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ mktempfile() {
3939
echo "$f"
4040
}
4141

42+
resolve_openclaw_effective_home() {
43+
local openclaw_home="${OPENCLAW_HOME:-}"
44+
if [[ -z "$openclaw_home" ]]; then
45+
echo "$HOME"
46+
return
47+
fi
48+
if [[ "$openclaw_home" == "~" ]]; then
49+
echo "$HOME"
50+
return
51+
fi
52+
if [[ "$openclaw_home" == \~/* ]]; then
53+
echo "${HOME}${openclaw_home:1}"
54+
return
55+
fi
56+
echo "$openclaw_home"
57+
}
58+
4259
DOWNLOADER=""
4360
detect_downloader() {
4461
if command -v curl &> /dev/null; then
@@ -1024,7 +1041,7 @@ DRY_RUN=${OPENCLAW_DRY_RUN:-0}
10241041
INSTALL_METHOD=${OPENCLAW_INSTALL_METHOD:-}
10251042
OPENCLAW_VERSION=${OPENCLAW_VERSION:-latest}
10261043
USE_BETA=${OPENCLAW_BETA:-0}
1027-
GIT_DIR_DEFAULT="${HOME}/openclaw"
1044+
GIT_DIR_DEFAULT="$(resolve_openclaw_effective_home)/openclaw"
10281045
GIT_DIR=${OPENCLAW_GIT_DIR:-$GIT_DIR_DEFAULT}
10291046
GIT_UPDATE=${OPENCLAW_GIT_UPDATE:-1}
10301047
SHARP_IGNORE_GLOBAL_LIBVIPS="${SHARP_IGNORE_GLOBAL_LIBVIPS:-1}"
@@ -2388,6 +2405,7 @@ install_openclaw_from_git() {
23882405
ensure_pnpm_binary_for_scripts
23892406

23902407
if [[ ! -d "$repo_dir" ]]; then
2408+
mkdir -p "$(dirname "$repo_dir")"
23912409
run_quiet_step "Cloning OpenClaw" git clone "$repo_url" "$repo_dir"
23922410
fi
23932411

@@ -2585,10 +2603,12 @@ maybe_open_dashboard() {
25852603

25862604
resolve_workspace_dir() {
25872605
local profile="${OPENCLAW_PROFILE:-default}"
2606+
local effective_home
2607+
effective_home="$(resolve_openclaw_effective_home)"
25882608
if [[ "${profile}" != "default" ]]; then
2589-
echo "${HOME}/.openclaw/workspace-${profile}"
2609+
echo "${effective_home}/.openclaw/workspace-${profile}"
25902610
else
2591-
echo "${HOME}/.openclaw/workspace"
2611+
echo "${effective_home}/.openclaw/workspace"
25922612
fi
25932613
}
25942614

@@ -2597,10 +2617,19 @@ run_bootstrap_onboarding_if_needed() {
25972617
return
25982618
fi
25992619

2600-
local config_path="${OPENCLAW_CONFIG_PATH:-$HOME/.openclaw/openclaw.json}"
2601-
if [[ -f "${config_path}" || -f "$HOME/.clawdbot/clawdbot.json" ]]; then
2620+
local effective_home
2621+
effective_home="$(resolve_openclaw_effective_home)"
2622+
local config_path="${OPENCLAW_CONFIG_PATH:-$effective_home/.openclaw/openclaw.json}"
2623+
local legacy_config_path="${HOME}/.openclaw/openclaw.json"
2624+
local legacy_clawdbot_path="${HOME}/.clawdbot/clawdbot.json"
2625+
if [[ -f "${config_path}" || -f "$effective_home/.clawdbot/clawdbot.json" ]]; then
26022626
return
26032627
fi
2628+
if [[ -z "${OPENCLAW_CONFIG_PATH:-}" && "${effective_home}" != "${HOME}" ]]; then
2629+
if [[ -f "$legacy_config_path" || -f "$legacy_clawdbot_path" ]]; then
2630+
return
2631+
fi
2632+
fi
26042633

26052634
local workspace
26062635
workspace="$(resolve_workspace_dir)"
@@ -3033,8 +3062,10 @@ main() {
30333062
user_claw="$(openclaw_command_for_user "${OPENCLAW_BIN:-}")"
30343063
ui_info "Skipping onboard (requested); run ${user_claw} onboard later"
30353064
else
3036-
local config_path="${OPENCLAW_CONFIG_PATH:-$HOME/.openclaw/openclaw.json}"
3037-
if [[ -f "${config_path}" || -f "$HOME/.clawdbot/clawdbot.json" ]]; then
3065+
local effective_home
3066+
effective_home="$(resolve_openclaw_effective_home)"
3067+
local config_path="${OPENCLAW_CONFIG_PATH:-$effective_home/.openclaw/openclaw.json}"
3068+
if [[ -f "${config_path}" || -f "$effective_home/.clawdbot/clawdbot.json" ]]; then
30383069
ui_info "Config already present; running doctor"
30393070
run_doctor
30403071
should_open_dashboard=true

0 commit comments

Comments
 (0)