

























@@ -159,13 +159,16 @@ case "\$command" in
159159 echo "systemctl shim: unit not found: \$unit" >&2
160160 exit 1
161161 fi
162- exec_start="\$(grep "^ExecStart=" "\$unit" | head -1 | sed "s/^ExecStart=//")"
162+ exec_start_line="\$(grep "^ExecStart=" "\$unit" | head -1 || true)"
163+ exec_start="\${exec_start_line#ExecStart=}"
163164 if [ -z "\$exec_start" ]; then
164165 echo "systemctl shim: no ExecStart in \$unit" >&2
165166 exit 1
166167 fi
167168 # Source EnvironmentFile if present
168- env_file="\$(grep "^EnvironmentFile=" "\$unit" | head -1 | sed "s/^EnvironmentFile=//" | sed "s/^-//")"
169+ env_file_line="\$(grep "^EnvironmentFile=" "\$unit" | head -1 || true)"
170+ env_file="\${env_file_line#EnvironmentFile=}"
171+ env_file="\${env_file#-}"
169172 if [ -n "\$env_file" ] && [ -f "\$env_file" ]; then
170173 set -a; source "\$env_file"; set +a
171174 fi
@@ -197,7 +200,20 @@ case "\$command" in
197200 fi
198201 ;;
199202 show)
200- echo "ActiveState=inactive"
203+ if [ -s "$GATEWAY_PID_FILE" ] && kill -0 "\$(cat "$GATEWAY_PID_FILE" 2>/dev/null)" 2>/dev/null; then
204+ pid="\$(cat "$GATEWAY_PID_FILE")"
205+ echo "ActiveState=active"
206+ echo "SubState=running"
207+ echo "MainPID=\$pid"
208+ echo "ExecMainStatus=0"
209+ echo "ExecMainCode=0"
210+ else
211+ echo "ActiveState=inactive"
212+ echo "SubState=dead"
213+ echo "MainPID=0"
214+ echo "ExecMainStatus=0"
215+ echo "ExecMainCode=0"
216+ fi
201217 ;;
202218 *)
203219 echo "systemctl shim: ignoring: \$*"
@@ -240,6 +256,8 @@ echo "── Step 5: Switch PATH so node-B comes first ──"
240256# Crucially, node-B has its own working npm with its own global prefix,
241257# but openclaw is NOT installed there.
242258export PATH="$NPM_PREFIX_B/bin:$NODE_B_ROOT/bin:$NPM_PREFIX_A/bin:$NODE_A_DIR:$PATH"
259+export npm_config_prefix="$NPM_PREFIX_B"
260+export NPM_CONFIG_PREFIX="$NPM_PREFIX_B"
243261244262# Verify node-B npm works independently.
245263echo "node-B npm prefix: $($NODE_B_ROOT/bin/node $NODE_B_ROOT/bin/npm prefix -g 2>/dev/null || echo unknown)"
@@ -343,6 +361,7 @@ fi
343361echo ""
344362echo "── Step 9: Try starting the gateway with the post-update unit ──"
345363364+GATEWAY_START_FAILED=0
346365if [ -f "$GATEWAY_UNIT_PATH" ]; then
347366 systemctl restart 2>&1 || true
348367 sleep 3
@@ -359,6 +378,7 @@ if [ -f "$GATEWAY_UNIT_PATH" ]; then
359378 else
360379 echo "BUG: Gateway failed to start with the post-update unit"
361380 cat "$GATEWAY_DAEMON_LOG" 2>/dev/null | tail -20 || true
381+ GATEWAY_START_FAILED=1
362382 fi
363383fi
364384@@ -383,6 +403,9 @@ if [ -f "$GATEWAY_UNIT_PATH" ]; then
383403 EXIT_CODE=1
384404 fi
385405fi
406+if [ "$GATEWAY_START_FAILED" -ne 0 ]; then
407+ EXIT_CODE=1
408+fi
386409exit $EXIT_CODE
387410' || CONTAINER_EXIT=$?
388411此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。