Spaces:
Paused
Paused
Commit Β·
c26fdc3
1
Parent(s): 49cc5fe
Allow startup installed plugins before gateway
Browse filesFiles changed (3)
- Dockerfile+11-2
- README.md+45
- start.sh+420-14
13 unmodified lines14151617181924 unmodified lines44454647484950515213 unmodified lines# Install system dependenciesRUN apt-get update && apt-get install -y \git \ca-certificates \jq \curl \24 unmodified linespip3 install --no-cache-dir --break-system-packages huggingface_hub && \rm -rf /var/lib/apt/lists/*# Reuse existing node user (UID 1000)RUN mkdir -p /home/node/app /home/node/.openclaw && \chown -R 1000:1000 /home/node# Copy pre-built OpenClaw (skips npm install entirely β much faster!)COPY --from=openclaw --chown=1000:1000 /app /home/node/.openclaw/openclaw-app13 unmodified lines1415161718192024 unmodified lines454647484950515253545556575859606113 unmodified lines# Install system dependenciesRUN apt-get update && apt-get install -y \git \sudo \ca-certificates \jq \curl \24 unmodified linespip3 install --no-cache-dir --break-system-packages huggingface_hub && \rm -rf /var/lib/apt/lists/*# Reuse existing node user (UID 1000). Allow passwordless package-manager# commands only so runtime apt installs can be replayed after HF Space restarts# without granting unrestricted sudo access.RUN mkdir -p /home/node/app /home/node/.openclaw && \chown -R 1000:1000 /home/node && \printf '%s\n' \'Cmnd_Alias HUGGINGCLAW_APT = /usr/bin/apt, /usr/bin/apt-get, /usr/bin/dpkg' \'node ALL=(root) NOPASSWD: HUGGINGCLAW_APT' \> /etc/sudoers.d/huggingclaw-apt && \chmod 0440 /etc/sudoers.d/huggingclaw-apt && \visudo -cf /etc/sudoers.d/huggingclaw-apt# Copy pre-built OpenClaw (skips npm install entirely β much faster!)COPY --from=openclaw --chown=1000:1000 /app /home/node/.openclaw/openclaw-app
163 unmodified lines164165166167168169163 unmodified lines| `HF_TOKEN` | β | HF token with **Write** access || `SYNC_INTERVAL` | `180` | Backup frequency in seconds |## π Staying Alive *(Recommended on Free HF Spaces)*Your Space will automatically be kept awake by a background Cloudflare Worker when you configure the `CLOUDFLARE_WORKERS_TOKEN` secret. The worker uses a cron trigger to regularly ping your Space's `/health` endpoint. The dashboard displays the current keep-alive worker status.163 unmodified lines164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214163 unmodified lines| `HF_TOKEN` | β | HF token with **Write** access || `SYNC_INTERVAL` | `180` | Backup frequency in seconds |## π¦ Ephemeral Package Re-install *(Optional)*Yes β you can use extra packages after a Space restart without storing package files. The easiest option is to remember **one variable**:| Variable | What to put in it || :--- | :--- || `HUGGINGCLAW_RUN` | Any bash commands you want to run on every startup |Example:```bashHUGGINGCLAW_RUN="""set -esudo apt-get updatesudo apt-get install -y ffmpegpython3 -m pip install --user pandas requestsnpm install -g typescript"""```For very quote-heavy or strange scripts, put a base64 script in the same variable:```bash# locallybase64 -w0 setup.sh# HF VariableHUGGINGCLAW_RUN=base64:<paste-output-here>```How it works:1. `HUGGINGCLAW_RUN` is run as a full bash script on every boot before the OpenClaw gateway launches, so multi-line commands, `if`, loops, functions, and heredocs work. Long installs will delay gateway startup.2. Startup scripts load the same HuggingClaw shell wrappers as the interactive shell, so `apt install ...`, `pip install ...`, `npm install -g ...`, and `openclaw plugins install ...` behave consistently.3. OpenClaw plugins installed at startup are synced into `plugins.allow` before the gateway launches, so the gateway can load them instead of reporting them as not installed.4. If you install from the OpenClaw shell manually, HuggingClaw records only successful install commands in `/home/node/.openclaw/workspace/startup.sh` for replay. Failed or dummy commands are not saved by the wrapper.5. Package files are not persisted; commands are replayed to reconstruct them after restart.Errors are always printed as `ERROR:` lines in Space logs. By default HuggingClaw logs the error and continues booting; set `HUGGINGCLAW_STARTUP_STRICT=true` if the Space should fail fast when any startup install command fails.Advanced/backward-compatible variables still work if you prefer package-specific fields: `HUGGINGCLAW_APT_PACKAGES`, `HUGGINGCLAW_PIP_PACKAGES`, `HUGGINGCLAW_NPM_PACKAGES`, `HUGGINGCLAW_OPENCLAW_PLUGINS`, `HUGGINGCLAW_STARTUP_COMMANDS`, `HUGGINGCLAW_STARTUP_COMMAND_1`...`100`, `HUGGINGCLAW_STARTUP_SCRIPT`, and `HUGGINGCLAW_STARTUP_SCRIPT_B64`.> [!IMPORTANT]> `sudo` is available for package-manager commands only (`apt`, `apt-get`, and `dpkg`). This is enough for `sudo apt-get update` and `sudo apt-get install -y ...`, but it is not unrestricted root access. Apt-installed packages still disappear on Space restart, so put them in `HUGGINGCLAW_RUN` or let the shell wrapper record the command in `startup.sh`.## π Staying Alive *(Recommended on Free HF Spaces)*Your Space will automatically be kept awake by a background Cloudflare Worker when you configure the `CLOUDFLARE_WORKERS_TOKEN` secret. The worker uses a cron trigger to regularly ping your Space's `/health` endpoint. The dashboard displays the current keep-alive worker status.
128 unmodified lines129130131132133134135136137283 unmodified lines42142242342442542642742842943043143243343443543643743843997 unmodified lines53753853954054154254354454554654754854955055155255355455555655755855956056156217 unmodified lines5805815825835845852 unmodified lines588589590591592593594595596597128 unmodified linesmkdir -p /home/node/.openclaw/memorymkdir -p /home/node/.openclaw/extensionsmkdir -p /home/node/.openclaw/workspacechmod 700 /home/node/.openclawchmod 700 /home/node/.openclaw/credentials# ββ Restore workspace/state from HF Dataset ββBACKUP_DATASET="${BACKUP_DATASET_NAME:-huggingclaw-backup}"if [ -n "${HF_TOKEN:-}" ]; then283 unmodified lines# Write configEXISTING_CONFIG="/home/node/.openclaw/openclaw.json"if [ -f "$EXISTING_CONFIG" ]; thenecho "Restored config found β patching required fields only..."PATCHED=$(jq \--arg token "$GATEWAY_TOKEN" \--arg model "$LLM_MODEL" \--arg fileLevel "$OPENCLAW_FILE_LOG_LEVEL" \--arg consoleLevel "$OPENCLAW_CONSOLE_LOG_LEVEL" \--arg consoleStyle "$OPENCLAW_CONSOLE_LOG_STYLE" \'.gateway.auth.token = $token| .agents.defaults.model = $model| .logging.level = $fileLevel| .logging.consoleLevel = $consoleLevel| .logging.consoleStyle = $consoleStyle' \"$EXISTING_CONFIG" 2>/dev/null)if [ -n "$PATCHED" ]; then97 unmodified linesfi# ββ Write shell capture wrappers to .bashrc ββSTARTUP_FILE="/home/node/.openclaw/workspace/startup.sh"cat > /home/node/.bashrc << 'BASHRC'STARTUP_FILE="/home/node/.openclaw/workspace/startup.sh"_hc_append() {local line="$*"grep -qxF "$line" "$STARTUP_FILE" 2>/dev/null || echo "$line" >> "$STARTUP_FILE"}apt-get() {command apt-get "$@"[[ "$1" == "install" ]] && _hc_append "apt-get install -y ${@:2}"}apt() {command apt "$@"[[ "$1" == "install" ]] && _hc_append "apt-get install -y ${@:2}"}pip() { command pip "$@"; [[ "$1" == "install" ]] && _hc_append "pip install ${@:2}"; }pip3() { command pip3 "$@"; [[ "$1" == "install" ]] && _hc_append "pip3 install ${@:2}"; }npm() { command npm "$@"; [[ "$1" == "install" && "$2" == "-g" ]] && _hc_append "npm install -g ${@:3}"; }openclaw() { command openclaw "$@"; [[ "$1" == "plugins" && "$2" == "install" ]] && _hc_append "openclaw plugins install ${@:3}"; }BASHRCecho "Shell capture wrappers ready."# ββ Re-install previously installed plugins ββ17 unmodified linesfifi# ββ Run workspace startup script ββSTARTUP_FILE="/home/node/.openclaw/workspace/startup.sh"if [ ! -f "$STARTUP_FILE" ]; then2 unmodified linesecho "Created workspace/startup.sh"fiif [ -s "$STARTUP_FILE" ]; thenecho "Running workspace/startup.sh..."bash "$STARTUP_FILE" || echo "Warning: startup.sh had errors, continuing..."echo "Startup script complete."fi# ββ Launch gateway ββecho "Launching OpenClaw gateway on port 7860..."128 unmodified lines129130131132133134135136137138139140141142143144145146147148283 unmodified lines43243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646797 unmodified lines56556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375417 unmodified lines7727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889892 unmodified lines9929939949959969979989991000100110021003128 unmodified linesmkdir -p /home/node/.openclaw/memorymkdir -p /home/node/.openclaw/extensionsmkdir -p /home/node/.openclaw/workspacemkdir -p /home/node/.local/bin /home/node/.local/lib /home/node/.npm-globalchmod 700 /home/node/.openclawchmod 700 /home/node/.openclaw/credentials# User-installed packages are intentionally ephemeral in the container. Keep# npm/pip installs in user-writable locations, make apt noninteractive,# and persist only a tiny replay script in the synced workspace so packages# are re-installed after restart.export NPM_CONFIG_PREFIX="${NPM_CONFIG_PREFIX:-/home/node/.local}"export npm_config_prefix="$NPM_CONFIG_PREFIX"export PYTHONUSERBASE="${PYTHONUSERBASE:-/home/node/.local}"export DEBIAN_FRONTEND="${DEBIAN_FRONTEND:-noninteractive}"STARTUP_FILE="/home/node/.openclaw/workspace/startup.sh"# ββ Restore workspace/state from HF Dataset ββBACKUP_DATASET="${BACKUP_DATASET_NAME:-huggingclaw-backup}"if [ -n "${HF_TOKEN:-}" ]; then283 unmodified lines# Write configEXISTING_CONFIG="/home/node/.openclaw/openclaw.json"WHATSAPP_CONFIG_ENABLED=falseif [ "$WHATSAPP_ENABLED_NORMALIZED" = "true" ]; thenWHATSAPP_CONFIG_ENABLED=truefiif [ -f "$EXISTING_CONFIG" ]; thenecho "Restored config found β patching required fields and runtime channel/plugin toggles..."PATCHED=$(jq \--arg token "$GATEWAY_TOKEN" \--arg model "$LLM_MODEL" \--arg fileLevel "$OPENCLAW_FILE_LOG_LEVEL" \--arg consoleLevel "$OPENCLAW_CONSOLE_LOG_LEVEL" \--arg consoleStyle "$OPENCLAW_CONSOLE_LOG_STYLE" \--argjson desired "$CONFIG_JSON" \--argjson whatsappEnabled "$WHATSAPP_CONFIG_ENABLED" \'.gateway.auth.token = $token| .agents.defaults.model = $model| .logging.level = $fileLevel| .logging.consoleLevel = $consoleLevel| .logging.consoleStyle = $consoleStyle| .channels = ((.channels // {}) * ($desired.channels // {}))| .plugins.allow = (((.plugins.allow // []) + ($desired.plugins.allow // [])) | unique)| .plugins.deny = (((.plugins.deny // []) + ($desired.plugins.deny // [])) | unique)| .plugins.entries = ((.plugins.entries // {}) * ($desired.plugins.entries // {}))| if $whatsappEnabled then.plugins.entries.whatsapp.enabled = true| .channels.whatsapp = ($desired.channels.whatsapp // {"dmPolicy": "pairing"})else.plugins.entries.whatsapp.enabled = false| del(.channels.whatsapp)end' \"$EXISTING_CONFIG" 2>/dev/null)if [ -n "$PATCHED" ]; then97 unmodified linesfi# ββ Write shell capture wrappers to .bashrc ββ# The wrappers persist only install commands, not downloaded package files.# On the next boot the synced workspace/startup.sh replays those commands.if [ ! -f "$STARTUP_FILE" ]; thentouch "$STARTUP_FILE"chmod +x "$STARTUP_FILE"echo "Created workspace/startup.sh"ficat > /home/node/.bashrc << 'BASHRC'export PATH="/home/node/.local/bin:$PATH"export NPM_CONFIG_PREFIX="${NPM_CONFIG_PREFIX:-/home/node/.local}"export npm_config_prefix="$NPM_CONFIG_PREFIX"export PYTHONUSERBASE="${PYTHONUSERBASE:-/home/node/.local}"export DEBIAN_FRONTEND="${DEBIAN_FRONTEND:-noninteractive}"STARTUP_FILE="/home/node/.openclaw/workspace/startup.sh"_hc_append() {local line="$*"mkdir -p "$(dirname "$STARTUP_FILE")"touch "$STARTUP_FILE"chmod +x "$STARTUP_FILE" 2>/dev/null || truegrep -qxF "$line" "$STARTUP_FILE" 2>/dev/null || echo "$line" >> "$STARTUP_FILE"}_hc_quote_args() {local quoted=()local argfor arg in "$@"; doprintf -v arg '%q' "$arg"quoted+=("$arg")doneprintf '%s' "${quoted[*]}"}_hc_append_cmd() {local cmd="$1"shiftlocal argsargs=$(_hc_quote_args "$@")if [ -n "$args" ]; then_hc_append "$cmd $args"else_hc_append "$cmd"fi}_hc_allow_openclaw_plugins() {local config="/home/node/.openclaw/openclaw.json"[ -f "$config" ] || return 0local plugins=()local pluginfor plugin in "$@"; do[ -n "$plugin" ] || continue[[ "$plugin" == -* ]] && continueplugins+=("$plugin")if [[ "$plugin" == @openclaw/* ]]; thenplugins+=("${plugin#@openclaw/}")fidone[ "${#plugins[@]}" -gt 0 ] || return 0local plugins_jsonplugins_json=$(printf '%s\n' "${plugins[@]}" | jq -R 'select(length > 0)' | jq -s 'unique') || return 0jq --argjson plugins "$plugins_json" \'.plugins.allow = (((.plugins.allow // []) + $plugins) | unique)' \"$config" > "$config.tmp" && mv "$config.tmp" "$config"}_hc_has_arg() {local needle="$1"shiftlocal argfor arg in "$@"; do[ "$arg" = "$needle" ] && return 0donereturn 1}_hc_can_sudo_apt() {command -v sudo >/dev/null 2>&1 && sudo -n apt-get --version >/dev/null 2>&1}_hc_apt_install() {if [ "$(id -u)" -eq 0 ]; thencommand apt-get update && command apt-get install -y "$@"elif _hc_can_sudo_apt; thensudo apt-get update && sudo apt-get install -y "$@"elseecho "Error: apt install needs root. Rebuild with the latest HuggingClaw image or add packages to Dockerfile." >&2return 1fi}apt-get() {case "${1:-}" ininstall)shift_hc_apt_install "$@"local rc=$?if [ $rc -eq 0 ]; then_hc_append_cmd "sudo apt-get update && sudo apt-get install -y" "$@"fireturn $rc;;update)if [ "$(id -u)" -eq 0 ]; thencommand apt-get "$@"elif _hc_can_sudo_apt; thensudo apt-get "$@"elsecommand apt-get "$@"fireturn $?;;*)command apt-get "$@"return $?;;esac}apt() {case "${1:-}" ininstall)shift_hc_apt_install "$@"local rc=$?if [ $rc -eq 0 ]; then_hc_append_cmd "sudo apt-get update && sudo apt-get install -y" "$@"fireturn $rc;;update)if [ "$(id -u)" -eq 0 ]; thencommand apt "$@"elif _hc_can_sudo_apt; thensudo apt "$@"elsecommand apt "$@"fireturn $?;;*)command apt "$@"return $?;;esac}pip() {if [ "${1:-}" = "install" ] && [ -z "${VIRTUAL_ENV:-}" ] && ! _hc_has_arg --user "$@" && ! _hc_has_arg --prefix "$@"; thencommand pip install --user "${@:2}"elsecommand pip "$@"filocal rc=$?if [ $rc -eq 0 ] && [ "${1:-}" = "install" ]; then_hc_append_cmd "python3 -m pip install --user" "${@:2}"fireturn $rc}pip3() {if [ "${1:-}" = "install" ] && [ -z "${VIRTUAL_ENV:-}" ] && ! _hc_has_arg --user "$@" && ! _hc_has_arg --prefix "$@"; thencommand pip3 install --user "${@:2}"elsecommand pip3 "$@"filocal rc=$?if [ $rc -eq 0 ] && [ "${1:-}" = "install" ]; then_hc_append_cmd "python3 -m pip install --user" "${@:2}"fireturn $rc}npm() {command npm "$@"local rc=$?if [ $rc -eq 0 ] && [ "${1:-}" = "install" ] && { [ "${2:-}" = "-g" ] || [ "${2:-}" = "--global" ]; }; then_hc_append_cmd "npm install -g" "${@:3}"fireturn $rc}openclaw() {command openclaw "$@"local rc=$?if [ $rc -eq 0 ] && [ "${1:-}" = "plugins" ] && [ "${2:-}" = "install" ]; then_hc_allow_openclaw_plugins "${@:3}"_hc_append_cmd "openclaw plugins install" "${@:3}"fireturn $rc}BASHRCcat > /home/node/.profile <<'PROFILE'[ -f ~/.bashrc ] && . ~/.bashrcPROFILEecho "Shell capture wrappers ready."# ββ Re-install previously installed plugins ββ17 unmodified linesfifi# ββ Startup command runner ββ# Runs user-provided boot commands one by one so failures are visible in logs.# By default failures are logged and boot continues; set# HUGGINGCLAW_STARTUP_STRICT=true to fail the Space startup on any error.HC_STARTUP_FAILURES=0HC_STARTUP_STRICT_NORMALIZED=$(printf '%s' "${HUGGINGCLAW_STARTUP_STRICT:-false}" | tr '[:upper:]' '[:lower:]')hc_run_startup_command() {local source_label="$1"local command_text="$2"[ -n "$command_text" ] || return 0echo "[startup:${source_label}] $command_text"set +ebash -lc "$command_text"local rc=$?set -eif [ "$rc" -eq 0 ]; thenecho "[startup:${source_label}] ok"return 0fiHC_STARTUP_FAILURES=$((HC_STARTUP_FAILURES + 1))echo "ERROR: startup command failed (${source_label}, exit ${rc}): $command_text" >&2return "$rc"}hc_run_startup_script() {local source_label="$1"local script_text="$2"[ -n "$script_text" ] || return 0local script_filescript_file=$(mktemp "/tmp/huggingclaw-startup-${source_label//[^A-Za-z0-9_.-]/_}.XXXXXX.sh"){# Load HuggingClaw's install wrappers for env-provided scripts too, so# `apt install`, `pip install`, `npm install -g`, and OpenClaw plugin# installs behave the same way as they do in the interactive shell.echo '[ -f /home/node/.bashrc ] && . /home/node/.bashrc'printf '%s\n' "$script_text"} > "$script_file"chmod 700 "$script_file"echo "[startup:${source_label}] running script (${script_file})"set +ebash "$script_file"local rc=$?set -erm -f "$script_file"if [ "$rc" -eq 0 ]; thenecho "[startup:${source_label}] ok"return 0fiHC_STARTUP_FAILURES=$((HC_STARTUP_FAILURES + 1))echo "ERROR: startup script failed (${source_label}, exit ${rc})" >&2return "$rc"}hc_run_startup_script_b64() {local source_label="$1"local encoded_script="$2"[ -n "$encoded_script" ] || return 0local script_textif ! script_text=$(printf '%s' "$encoded_script" | base64 -d 2>/dev/null); thenHC_STARTUP_FAILURES=$((HC_STARTUP_FAILURES + 1))echo "ERROR: startup script base64 decode failed (${source_label})" >&2return 1fihc_run_startup_script "$source_label" "$script_text"}hc_run_startup_auto() {local source_label="$1"local payload="$2"[ -n "$payload" ] || return 0if [[ "$payload" == base64:* ]]; thenhc_run_startup_script_b64 "$source_label" "${payload#base64:}"elif [[ "$payload" == b64:* ]]; thenhc_run_startup_script_b64 "$source_label" "${payload#b64:}"elsehc_run_startup_script "$source_label" "$payload"fi}hc_run_command_block() {local source_label="$1"local command_block="$2"local linelocal index=0while IFS= read -r line || [ -n "$line" ]; do# Skip blank lines and comments so multi-line env vars can be documented.[[ "$line" =~ ^[[:space:]]*$ ]] && continue[[ "$line" =~ ^[[:space:]]*# ]] && continueindex=$((index + 1))hc_run_startup_command "${source_label}[${index}]" "$line" || truedone <<< "$command_block"}sync_installed_plugins_into_allow() {local config="/home/node/.openclaw/openclaw.json"[ -f "$config" ] || return 0local patchedpatched=$(jq '(.plugins.installs // {}) as $installs| ($installs | keys) as $installed| ($installed | map(if startswith("@openclaw/") then sub("^@openclaw/"; "") else . end)) as $short| .plugins.allow = (((.plugins.allow // []) + $installed + $short) | unique)' "$config" 2>/dev/null) || {echo "Warning: could not sync installed plugins into plugins.allow"return 0}echo "$patched" > "$config.tmp" && mv "$config.tmp" "$config"}hc_finish_startup_commands() {if [ "$HC_STARTUP_FAILURES" -gt 0 ]; thenecho "ERROR: ${HC_STARTUP_FAILURES} startup command(s) failed. Check the log lines above." >&2if [ "$HC_STARTUP_STRICT_NORMALIZED" = "true" ] || [ "$HC_STARTUP_STRICT_NORMALIZED" = "1" ] || [ "$HC_STARTUP_STRICT_NORMALIZED" = "yes" ]; thenecho "ERROR: HUGGINGCLAW_STARTUP_STRICT=true, stopping startup." >&2exit 1fifireturn 0}# ββ Optional package install lists from HF Variables/Secrets ββ# These install package names every boot without persisting package files.# Use them when you prefer HF Variables over editing workspace/startup.sh.if [ -n "${HUGGINGCLAW_APT_PACKAGES:-}" ]; thenecho "Installing apt packages from HUGGINGCLAW_APT_PACKAGES..."read -r -a HC_APT_PACKAGES <<< "$HUGGINGCLAW_APT_PACKAGES"if command -v sudo >/dev/null 2>&1; thenif sudo apt-get update && sudo apt-get install -y "${HC_APT_PACKAGES[@]}"; thenecho "HUGGINGCLAW_APT_PACKAGES install complete."elseHC_STARTUP_FAILURES=$((HC_STARTUP_FAILURES + 1))echo "ERROR: HUGGINGCLAW_APT_PACKAGES install failed: ${HUGGINGCLAW_APT_PACKAGES}" >&2fielseHC_STARTUP_FAILURES=$((HC_STARTUP_FAILURES + 1))echo "ERROR: sudo is unavailable; HUGGINGCLAW_APT_PACKAGES install skipped" >&2fifiif [ -n "${HUGGINGCLAW_PIP_PACKAGES:-}" ]; thenecho "Installing Python packages from HUGGINGCLAW_PIP_PACKAGES..."read -r -a HC_PIP_PACKAGES <<< "$HUGGINGCLAW_PIP_PACKAGES"if python3 -m pip install --user "${HC_PIP_PACKAGES[@]}"; thenecho "HUGGINGCLAW_PIP_PACKAGES install complete."elseHC_STARTUP_FAILURES=$((HC_STARTUP_FAILURES + 1))echo "ERROR: HUGGINGCLAW_PIP_PACKAGES install failed: ${HUGGINGCLAW_PIP_PACKAGES}" >&2fifiif [ -n "${HUGGINGCLAW_NPM_PACKAGES:-}" ]; thenecho "Installing global npm packages from HUGGINGCLAW_NPM_PACKAGES..."read -r -a HC_NPM_PACKAGES <<< "$HUGGINGCLAW_NPM_PACKAGES"if npm install -g "${HC_NPM_PACKAGES[@]}"; thenecho "HUGGINGCLAW_NPM_PACKAGES install complete."elseHC_STARTUP_FAILURES=$((HC_STARTUP_FAILURES + 1))echo "ERROR: HUGGINGCLAW_NPM_PACKAGES install failed: ${HUGGINGCLAW_NPM_PACKAGES}" >&2fifiif [ -n "${HUGGINGCLAW_OPENCLAW_PLUGINS:-}" ]; thenecho "Installing OpenClaw plugins from HUGGINGCLAW_OPENCLAW_PLUGINS..."read -r -a HC_OPENCLAW_PLUGINS <<< "$HUGGINGCLAW_OPENCLAW_PLUGINS"if openclaw plugins install "${HC_OPENCLAW_PLUGINS[@]}"; thenecho "HUGGINGCLAW_OPENCLAW_PLUGINS install complete."elseHC_STARTUP_FAILURES=$((HC_STARTUP_FAILURES + 1))echo "ERROR: HUGGINGCLAW_OPENCLAW_PLUGINS install failed: ${HUGGINGCLAW_OPENCLAW_PLUGINS}" >&2fifi# ββ Arbitrary startup commands from HF Variables/Secrets ββ# Recommended: use one variable, HUGGINGCLAW_RUN, as a full bash script. If the# value starts with base64: or b64:, the rest is decoded and run as the script.# Legacy granular HUGGINGCLAW_STARTUP_* variables are still supported below.if [ -n "${HUGGINGCLAW_RUN:-}" ]; thenhc_run_startup_auto "HUGGINGCLAW_RUN" "$HUGGINGCLAW_RUN" || truefiif [ -n "${HUGGINGCLAW_STARTUP_COMMANDS:-}" ]; thenecho "Running commands from HUGGINGCLAW_STARTUP_COMMANDS..."hc_run_command_block "HUGGINGCLAW_STARTUP_COMMANDS" "$HUGGINGCLAW_STARTUP_COMMANDS"fifor HC_STARTUP_INDEX in $(seq 1 100); doHC_STARTUP_VAR="HUGGINGCLAW_STARTUP_COMMAND_${HC_STARTUP_INDEX}"if [ -n "${!HC_STARTUP_VAR:-}" ]; thenhc_run_startup_command "$HC_STARTUP_VAR" "${!HC_STARTUP_VAR}" || truefidoneif [ -n "${HUGGINGCLAW_STARTUP_SCRIPT:-}" ]; thenhc_run_startup_script "HUGGINGCLAW_STARTUP_SCRIPT" "$HUGGINGCLAW_STARTUP_SCRIPT" || truefiif [ -n "${HUGGINGCLAW_STARTUP_SCRIPT_B64:-}" ]; thenhc_run_startup_script_b64 "HUGGINGCLAW_STARTUP_SCRIPT_B64" "$HUGGINGCLAW_STARTUP_SCRIPT_B64" || truefifor HC_STARTUP_INDEX in $(seq 1 20); doHC_STARTUP_VAR="HUGGINGCLAW_STARTUP_SCRIPT_B64_${HC_STARTUP_INDEX}"if [ -n "${!HC_STARTUP_VAR:-}" ]; thenhc_run_startup_script_b64 "$HC_STARTUP_VAR" "${!HC_STARTUP_VAR}" || truefidone# ββ Run workspace startup script ββSTARTUP_FILE="/home/node/.openclaw/workspace/startup.sh"if [ ! -f "$STARTUP_FILE" ]; then2 unmodified linesecho "Created workspace/startup.sh"fiif [ -s "$STARTUP_FILE" ]; thenecho "Running workspace/startup.sh script..."hc_run_startup_script "workspace/startup.sh" "$(cat "$STARTUP_FILE")" || trueecho "Workspace startup script complete."fihc_finish_startup_commandssync_installed_plugins_into_allow# ββ Launch gateway ββecho "Launching OpenClaw gateway on port 7860..."
Dockerfile+11-2
README.md+45
start.sh+420-14