Update entrypoint.sh
Browse files- entrypoint.sh +36 -10
entrypoint.sh
CHANGED
|
@@ -41,6 +41,42 @@ fi
|
|
| 41 |
export OPENCLAW_HOME
|
| 42 |
log "OPENCLAW_HOME=$OPENCLAW_HOME"
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# ----------------------------------------------------------------
|
| 45 |
# Export provider API keys from Secrets
|
| 46 |
# ----------------------------------------------------------------
|
|
@@ -119,15 +155,6 @@ JSEOF
|
|
| 119 |
|
| 120 |
# ----------------------------------------------------------------
|
| 121 |
# Gateway loop
|
| 122 |
-
#
|
| 123 |
-
# OpenClaw restart behaviour:
|
| 124 |
-
# - On config save it spawns a child process (new gateway) then
|
| 125 |
-
# the parent exits with code 0.
|
| 126 |
-
# - The child inherits the port 7860 lock.
|
| 127 |
-
# - We must NOT restart until the child also exits (port is free).
|
| 128 |
-
#
|
| 129 |
-
# Normal crash: port is immediately free, loop restarts quickly.
|
| 130 |
-
# Config-save restart: port stays held by child; we wait up to 90s.
|
| 131 |
# ----------------------------------------------------------------
|
| 132 |
log "Starting gateway loop..."
|
| 133 |
|
|
@@ -142,7 +169,6 @@ while true; do
|
|
| 142 |
|
| 143 |
log "Gateway exited (code $CODE)"
|
| 144 |
|
| 145 |
-
# Wait for port 7860 to be released before starting a new instance
|
| 146 |
WAITED=0
|
| 147 |
while nc -z 127.0.0.1 7860 2>/dev/null; do
|
| 148 |
if [ $WAITED -eq 0 ]; then
|
|
|
|
| 41 |
export OPENCLAW_HOME
|
| 42 |
log "OPENCLAW_HOME=$OPENCLAW_HOME"
|
| 43 |
|
| 44 |
+
# ----------------------------------------------------------------
|
| 45 |
+
# Clean up stale/uid-mismatched plugins from previous runs
|
| 46 |
+
# These cause "suspicious ownership" warnings and block startup.
|
| 47 |
+
# ----------------------------------------------------------------
|
| 48 |
+
EXTENSIONS_DIR="$OPENCLAW_HOME/.openclaw/extensions"
|
| 49 |
+
if [ -d "$EXTENSIONS_DIR" ]; then
|
| 50 |
+
log "Removing stale extensions dir (uid mismatch fix)..."
|
| 51 |
+
rm -rf "$EXTENSIONS_DIR" || warn "Could not remove extensions dir (non-fatal)"
|
| 52 |
+
fi
|
| 53 |
+
|
| 54 |
+
# Also clean stale plugin config entries from openclaw.json if it exists
|
| 55 |
+
CONFIG_PATH="$OPENCLAW_HOME/.openclaw/openclaw.json"
|
| 56 |
+
if [ -f "$CONFIG_PATH" ]; then
|
| 57 |
+
node - << 'JSEOF' || true
|
| 58 |
+
const fs = require('fs');
|
| 59 |
+
const p = process.env.OPENCLAW_HOME + '/.openclaw/openclaw.json';
|
| 60 |
+
try {
|
| 61 |
+
const raw = fs.readFileSync(p, 'utf-8');
|
| 62 |
+
const cfg = JSON.parse(raw);
|
| 63 |
+
let changed = false;
|
| 64 |
+
// Remove stale plugins section entirely
|
| 65 |
+
if (cfg.plugins) {
|
| 66 |
+
delete cfg.plugins;
|
| 67 |
+
changed = true;
|
| 68 |
+
console.log('[entrypoint] Removed stale plugins config from openclaw.json');
|
| 69 |
+
}
|
| 70 |
+
if (changed) {
|
| 71 |
+
fs.copyFileSync(p, p + '.bak');
|
| 72 |
+
fs.writeFileSync(p, JSON.stringify(cfg, null, 2), 'utf-8');
|
| 73 |
+
}
|
| 74 |
+
} catch(e) {
|
| 75 |
+
console.log('[entrypoint] Plugin cleanup skipped: ' + e.message);
|
| 76 |
+
}
|
| 77 |
+
JSEOF
|
| 78 |
+
fi
|
| 79 |
+
|
| 80 |
# ----------------------------------------------------------------
|
| 81 |
# Export provider API keys from Secrets
|
| 82 |
# ----------------------------------------------------------------
|
|
|
|
| 155 |
|
| 156 |
# ----------------------------------------------------------------
|
| 157 |
# Gateway loop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
# ----------------------------------------------------------------
|
| 159 |
log "Starting gateway loop..."
|
| 160 |
|
|
|
|
| 169 |
|
| 170 |
log "Gateway exited (code $CODE)"
|
| 171 |
|
|
|
|
| 172 |
WAITED=0
|
| 173 |
while nc -z 127.0.0.1 7860 2>/dev/null; do
|
| 174 |
if [ $WAITED -eq 0 ]; then
|