somratpro Claude Haiku 4.5 commited on
Commit
7a3506c
·
1 Parent(s): 0502cce

Auto-create Paperclip instance config.json on first boot

Browse files

bootstrap-ceo exits early with "No config found" when config.json is absent.
Generate a minimal valid config at PAPERCLIP_CONFIG before launching Paperclip,
using env vars for DB URL, public URL, and deployment mode. Skipped when config
was already restored from HF Dataset backup.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. start.sh +57 -0
start.sh CHANGED
@@ -223,6 +223,63 @@ export OPENCODE_ALLOW_ALL_MODELS="${OPENCODE_ALLOW_ALL_MODELS:-true}"
223
  export PAPERCLIP_ALLOWED_HOSTNAMES
224
  export PAPERCLIP_PUBLIC_URL
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  echo -e "${GREEN}✓ All systems ready${NC}"
227
  echo -e "${GREEN}═══════════════════════════════════════════${NC}"
228
  echo -e " Health Dashboard: http://localhost:7861/"
 
223
  export PAPERCLIP_ALLOWED_HOSTNAMES
224
  export PAPERCLIP_PUBLIC_URL
225
 
226
+ # Create Paperclip instance config.json if it doesn't exist.
227
+ # Required by bootstrap-ceo CLI to find DB and generate the admin invite URL.
228
+ # Skipped when a config was already restored from HF Dataset backup.
229
+ if [ ! -f "${PAPERCLIP_CONFIG}" ]; then
230
+ echo "Creating Paperclip instance config (first boot)..."
231
+ mkdir -p "$(dirname "${PAPERCLIP_CONFIG}")"
232
+ python3 <<'PYEOF'
233
+ import json, os
234
+
235
+ home = os.environ.get("PAPERCLIP_HOME", "/paperclip")
236
+ port = int(os.environ.get("PORT", "3100"))
237
+ public_url = os.environ.get("PAPERCLIP_PUBLIC_URL", f"http://localhost:{port}")
238
+
239
+ config = {
240
+ "$meta": {"version": 1, "updatedAt": "2024-01-01T00:00:00Z", "source": "onboard"},
241
+ "llm": {"provider": "claude", "apiKey": ""},
242
+ "database": {
243
+ "mode": "postgres",
244
+ "connectionString": os.environ.get("DATABASE_URL", "postgres://postgres:paperclip@localhost:5432/paperclip")
245
+ },
246
+ "logging": {"mode": "file", "logDir": f"{home}/instances/default/logs"},
247
+ "server": {
248
+ "deploymentMode": os.environ.get("PAPERCLIP_DEPLOYMENT_MODE", "authenticated"),
249
+ "exposure": os.environ.get("PAPERCLIP_DEPLOYMENT_EXPOSURE", "private"),
250
+ "host": "0.0.0.0",
251
+ "port": port,
252
+ "allowedHostnames": [],
253
+ "serveUi": True
254
+ },
255
+ "auth": {
256
+ "baseUrlMode": "explicit",
257
+ "publicBaseUrl": public_url,
258
+ "disableSignUp": False
259
+ },
260
+ "storage": {
261
+ "provider": "local_disk",
262
+ "localDisk": {"baseDir": f"{home}/instances/default/data/storage"}
263
+ },
264
+ "secrets": {
265
+ "provider": "local_encrypted",
266
+ "strictMode": False,
267
+ "localEncrypted": {"keyFilePath": f"{home}/instances/default/secrets/master.key"}
268
+ },
269
+ "telemetry": {"enabled": False}
270
+ }
271
+
272
+ config_path = os.environ.get("PAPERCLIP_CONFIG", f"{home}/instances/default/config.json")
273
+ os.makedirs(os.path.dirname(config_path), exist_ok=True)
274
+ with open(config_path, "w") as f:
275
+ json.dump(config, f, indent=2)
276
+ print(f" Config written to {config_path}")
277
+ PYEOF
278
+ echo -e "${GREEN}✓ Instance config created${NC}"
279
+ else
280
+ echo -e "${GREEN}✓ Instance config found at ${PAPERCLIP_CONFIG}${NC}"
281
+ fi
282
+
283
  echo -e "${GREEN}✓ All systems ready${NC}"
284
  echo -e "${GREEN}═══════════════════════════════════════════${NC}"
285
  echo -e " Health Dashboard: http://localhost:7861/"