Skip to content

Commit 5ab3242

Browse files
pRizzclaude
andcommitted
fix(bootstrap): make reset unconditionally regenerate IOTP
Extract generate_fresh_otp() from cmd_init_internal() so cmd_reset() can bypass the user-exists guard and always produce a fresh IOTP. This aligns the bootstrap helper's reset behavior with `occ reset iotp`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 76a4d2c commit 5ab3242

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

packages/core/src/docker/files/opencode-cloud-bootstrap.sh

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,7 @@ emit_status() {
240240
jq -cn --arg created_at "${created_at}" '{ok:true,active:true,created_at:$created_at}'
241241
}
242242

243-
cmd_init_internal() {
244-
if has_non_protected_configured_user; then
245-
emit_inactive_and_cleanup
246-
return 0
247-
fi
248-
249-
if bootstrap_is_completed; then
250-
emit_status "0"
251-
return 0
252-
fi
253-
254-
if state_is_active; then
255-
emit_status "1"
256-
return 0
257-
fi
258-
243+
generate_fresh_otp() {
259244
remove_state_files
260245

261246
local otp salt created_at otp_hash
@@ -274,7 +259,27 @@ cmd_init_internal() {
274259
printf "%s" "${otp}" > "${SECRET_FILE}"
275260
chmod 600 "${STATE_FILE}" "${SECRET_FILE}"
276261

277-
jq -cn --arg created_at "${created_at}" --arg otp "${otp}" '{ok:true,active:true,created_at:$created_at,otp:$otp}'
262+
jq -cn --arg created_at "${created_at}" --arg otp "${otp}" \
263+
'{ok:true,active:true,created_at:$created_at,otp:$otp}'
264+
}
265+
266+
cmd_init_internal() {
267+
if has_non_protected_configured_user; then
268+
emit_inactive_and_cleanup
269+
return 0
270+
fi
271+
272+
if bootstrap_is_completed; then
273+
emit_status "0"
274+
return 0
275+
fi
276+
277+
if state_is_active; then
278+
emit_status "1"
279+
return 0
280+
fi
281+
282+
generate_fresh_otp
278283
}
279284

280285
cmd_init() {
@@ -288,9 +293,7 @@ cmd_reset() {
288293
acquire_lock
289294

290295
rm -f "${COMPLETE_MARKER_FILE}"
291-
remove_state_files
292-
293-
cmd_init_internal
296+
generate_fresh_otp
294297
}
295298

296299
cmd_status() {

0 commit comments

Comments
 (0)