arfandi7322 commited on
Commit
cd91ff6
·
1 Parent(s): 324aa0a

Regenerate incomplete OpenClaw config before startup

Browse files
Files changed (1) hide show
  1. start.sh +41 -3
start.sh CHANGED
@@ -131,11 +131,47 @@ generate_openclaw_config() {
131
  JSONEOF
132
  }
133
 
134
- if [ ! -f /root/.openclaw/openclaw.json ] || ! python3 -c 'import json; json.load(open("/root/.openclaw/openclaw.json"))' 2>/dev/null; then
135
- echo "Generating default /root/.openclaw/openclaw.json..."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  generate_openclaw_config
137
  else
138
- echo "Existing /root/.openclaw/openclaw.json found; keeping it."
139
  fi
140
 
141
  python3 - <<'PY'
@@ -165,6 +201,8 @@ else:
165
  print(f'Telegram apiRoot already set to {api_root}')
166
  PY
167
 
 
 
168
  /app/sync-root-data.sh loop &
169
 
170
  run_openclaw() {
 
131
  JSONEOF
132
  }
133
 
134
+ config_is_complete() {
135
+ python3 - <<'PY'
136
+ import json
137
+ from pathlib import Path
138
+
139
+ path = Path('/root/.openclaw/openclaw.json')
140
+ if not path.exists():
141
+ raise SystemExit(1)
142
+
143
+ try:
144
+ data = json.loads(path.read_text())
145
+ except Exception:
146
+ raise SystemExit(1)
147
+
148
+ required_paths = [
149
+ ('models', 'providers'),
150
+ ('models', 'providers', 'kilo_gateway'),
151
+ ('models', 'providers', 'nvidia'),
152
+ ('agents', 'defaults'),
153
+ ('browser',),
154
+ ('gateway',),
155
+ ('gateway', 'controlUi'),
156
+ ('channels', 'telegram'),
157
+ ]
158
+
159
+ for parts in required_paths:
160
+ cur = data
161
+ for part in parts:
162
+ if not isinstance(cur, dict) or part not in cur:
163
+ raise SystemExit(1)
164
+ cur = cur[part]
165
+
166
+ raise SystemExit(0)
167
+ PY
168
+ }
169
+
170
+ if ! config_is_complete; then
171
+ echo "Generating full /root/.openclaw/openclaw.json before OpenClaw startup..."
172
  generate_openclaw_config
173
  else
174
+ echo "Complete /root/.openclaw/openclaw.json found; keeping it."
175
  fi
176
 
177
  python3 - <<'PY'
 
201
  print(f'Telegram apiRoot already set to {api_root}')
202
  PY
203
 
204
+ /app/sync-root-data.sh persist
205
+
206
  /app/sync-root-data.sh loop &
207
 
208
  run_openclaw() {