- Fix PAT extraction timing with retry loop (waits up to 60s for PAT in logs) - Add sync command to flush filesystem buffers before extraction - Improve logging with progress messages and PAT verification - Refactor setup code into consolidated setup.rs module - Fix YAML indentation for PatPath and MachineKeyPath - Change Zitadel init parameter from --config to --steps The timing issue occurred because: 1. Zitadel writes PAT to logs at startup (~18:08:59) 2. Post-install extraction ran too early (~18:09:35) 3. PAT file wasn't created until ~18:10:38 (63s after installation) 4. OAuth client creation failed because PAT file didn't exist yet With the retry loop: - Waits for PAT to appear in logs with sync+grep check - Extracts PAT immediately when found - OAuth client creation succeeds - directory_config.json saved with valid credentials - Login flow works end-to-end Tested: Full reset.sh and login verification successful
76 lines
2.2 KiB
Rust
76 lines
2.2 KiB
Rust
pub mod mail;
|
|
pub mod talk;
|
|
|
|
pub use mail::convert_mail_block;
|
|
pub use talk::convert_talk_block;
|
|
|
|
use log::trace;
|
|
|
|
pub fn convert_begin_blocks(script: &str) -> String {
|
|
let mut result = String::new();
|
|
let mut in_talk_block = false;
|
|
let mut talk_block_lines: Vec<String> = Vec::new();
|
|
let mut in_mail_block = false;
|
|
let mut mail_recipient = String::new();
|
|
let mut mail_block_lines: Vec<String> = Vec::new();
|
|
|
|
for line in script.lines() {
|
|
let trimmed = line.trim();
|
|
let upper = trimmed.to_uppercase();
|
|
|
|
if trimmed.is_empty() || trimmed.starts_with('\'') || trimmed.starts_with("//") {
|
|
continue;
|
|
}
|
|
|
|
if upper == "BEGIN TALK" {
|
|
trace!("Converting BEGIN TALK statement");
|
|
in_talk_block = true;
|
|
talk_block_lines.clear();
|
|
continue;
|
|
}
|
|
|
|
if upper == "END TALK" {
|
|
trace!("Converting END TALK statement, processing {} lines", talk_block_lines.len());
|
|
in_talk_block = false;
|
|
let converted = convert_talk_block(&talk_block_lines);
|
|
result.push_str(&converted);
|
|
talk_block_lines.clear();
|
|
continue;
|
|
}
|
|
|
|
if in_talk_block {
|
|
talk_block_lines.push(trimmed.to_string());
|
|
continue;
|
|
}
|
|
|
|
if upper.starts_with("BEGIN MAIL ") {
|
|
let recipient = &trimmed[11..].trim();
|
|
trace!("Converting BEGIN MAIL statement: recipient='{}'", recipient);
|
|
mail_recipient = recipient.to_string();
|
|
in_mail_block = true;
|
|
mail_block_lines.clear();
|
|
continue;
|
|
}
|
|
|
|
if upper == "END MAIL" {
|
|
trace!("Converting END MAIL statement, processing {} lines", mail_block_lines.len());
|
|
in_mail_block = false;
|
|
let converted = convert_mail_block(&mail_recipient, &mail_block_lines);
|
|
result.push_str(&converted);
|
|
result.push('\n');
|
|
mail_recipient.clear();
|
|
mail_block_lines.clear();
|
|
continue;
|
|
}
|
|
|
|
if in_mail_block {
|
|
mail_block_lines.push(trimmed.to_string());
|
|
continue;
|
|
}
|
|
|
|
result.push_str(line);
|
|
result.push('\n');
|
|
}
|
|
|
|
result
|
|
}
|