Add container setup scripts for various services
All checks were successful
GBCI / build (push) Successful in 16m16s
All checks were successful
GBCI / build (push) Successful in 16m16s
- Implemented ALM container setup with Forgejo installation and systemd service configuration. - Created Bot container setup with necessary dependencies and Node.js application installation. - Developed Desktop container setup with XRDP and Brave browser installation. - Established Directory container setup with Zitadel installation and service configuration. - Added Doc Editor container setup for Collabora Online integration. - Implemented Drive container setup with MinIO installation and service configuration. - Created Email container setup with Stalwart Mail installation and service configuration. - Developed Meeting container setup with LiveKit and TURN server configuration. - Added Proxy container setup with Caddy installation and service configuration. - Implemented System container setup for general bots with service configuration. - Created Table Editor container setup with NocoDB installation and service configuration. - Developed Tables container setup with PostgreSQL installation and configuration. - Added Webmail container setup with Roundcube installation and service configuration. - Included prompt guidelines for container setup scripts.
This commit is contained in:
parent
d4697a6a93
commit
7131911313
2 changed files with 151 additions and 134 deletions
|
@ -24,6 +24,8 @@ async fn main() -> std::io::Result<()> {
|
|||
let json = FIND "users", "name=John"
|
||||
let x=2
|
||||
let text = GET "example.com"
|
||||
let nome = "table"
|
||||
let d = FIND nome, "car=2"
|
||||
"#;
|
||||
|
||||
match script_service.compile(script) {
|
||||
|
|
|
@ -20,140 +20,156 @@ impl ScriptService {
|
|||
engine.set_allow_looping(true);
|
||||
|
||||
// Register custom syntax for FOR EACH loop
|
||||
engine.register_custom_syntax(
|
||||
&["FOR", "EACH", "$ident$", "in", "$expr$", "$block$"],
|
||||
false, // Not a statement
|
||||
|context, inputs| {
|
||||
// Simple implementation - just return unit for now
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
).unwrap();
|
||||
engine
|
||||
.register_custom_syntax(
|
||||
&["FOR", "EACH", "$ident$", "in", "$expr$", "$block$"],
|
||||
false, // Not a statement
|
||||
|context, inputs| {
|
||||
// Simple implementation - just return unit for now
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// FIND command: FIND "table", "filter"
|
||||
engine.register_custom_syntax(
|
||||
&["FIND", "$expr$", ",", "$expr$"],
|
||||
false, // Expression, not statement
|
||||
|context, inputs| {
|
||||
let table_name = context.eval_expression_tree(&inputs[0])?;
|
||||
let filter = context.eval_expression_tree(&inputs[1])?;
|
||||
engine
|
||||
.register_custom_syntax(
|
||||
&["FIND", "$expr$", ",", "$expr$"],
|
||||
false, // Expression, not statement
|
||||
|context, inputs| {
|
||||
let table_name = context.eval_expression_tree(&inputs[0])?;
|
||||
let filter = context.eval_expression_tree(&inputs[1])?;
|
||||
|
||||
let table_str = table_name.to_string();
|
||||
let filter_str = filter.to_string();
|
||||
let table_str = table_name.to_string();
|
||||
let filter_str = filter.to_string();
|
||||
|
||||
let result = json!({
|
||||
"command": "find",
|
||||
"table": table_str,
|
||||
"filter": filter_str,
|
||||
"results": []
|
||||
});
|
||||
Ok(Dynamic::from(result.to_string()))
|
||||
},
|
||||
).unwrap();
|
||||
let result = json!({
|
||||
"command": "find",
|
||||
"table": table_str,
|
||||
"filter": filter_str,
|
||||
"results": []
|
||||
});
|
||||
println!("SET executed: {}", result.to_string());
|
||||
Ok(Dynamic::from(result.to_string()))
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// SET command: SET "table", "key", "value"
|
||||
engine.register_custom_syntax(
|
||||
&["SET", "$expr$", ",", "$expr$", ",", "$expr$"],
|
||||
true, // Statement
|
||||
|context, inputs| {
|
||||
let table_name = context.eval_expression_tree(&inputs[0])?;
|
||||
let key_value = context.eval_expression_tree(&inputs[1])?;
|
||||
let value = context.eval_expression_tree(&inputs[2])?;
|
||||
engine
|
||||
.register_custom_syntax(
|
||||
&["SET", "$expr$", ",", "$expr$", ",", "$expr$"],
|
||||
true, // Statement
|
||||
|context, inputs| {
|
||||
let table_name = context.eval_expression_tree(&inputs[0])?;
|
||||
let key_value = context.eval_expression_tree(&inputs[1])?;
|
||||
let value = context.eval_expression_tree(&inputs[2])?;
|
||||
|
||||
let table_str = table_name.to_string();
|
||||
let key_str = key_value.to_string();
|
||||
let value_str = value.to_string();
|
||||
let table_str = table_name.to_string();
|
||||
let key_str = key_value.to_string();
|
||||
let value_str = value.to_string();
|
||||
|
||||
let result = json!({
|
||||
"command": "set",
|
||||
"status": "success",
|
||||
"table": table_str,
|
||||
"key": key_str,
|
||||
"value": value_str
|
||||
});
|
||||
println!("SET executed: {}", result.to_string());
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
).unwrap();
|
||||
let result = json!({
|
||||
"command": "set",
|
||||
"status": "success",
|
||||
"table": table_str,
|
||||
"key": key_str,
|
||||
"value": value_str
|
||||
});
|
||||
println!("SET executed: {}", result.to_string());
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// GET command: GET "url"
|
||||
engine.register_custom_syntax(
|
||||
&["GET", "$expr$"],
|
||||
false, // Expression, not statement
|
||||
|context, inputs| {
|
||||
let url = context.eval_expression_tree(&inputs[0])?;
|
||||
let url_str = url.to_string();
|
||||
engine
|
||||
.register_custom_syntax(
|
||||
&["GET", "$expr$"],
|
||||
false, // Expression, not statement
|
||||
|context, inputs| {
|
||||
let url = context.eval_expression_tree(&inputs[0])?;
|
||||
let url_str = url.to_string();
|
||||
|
||||
Ok(format!("Content from {}", url_str).into())
|
||||
},
|
||||
).unwrap();
|
||||
Ok(format!("Content from {}", url_str).into())
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// CREATE SITE command: CREATE SITE "name", "company", "website", "template", "prompt"
|
||||
engine.register_custom_syntax(
|
||||
&["CREATE", "SITE", "$expr$", ",", "$expr$", ",", "$expr$", ",", "$expr$", ",", "$expr$"],
|
||||
true, // Statement
|
||||
|context, inputs| {
|
||||
if inputs.len() < 5 {
|
||||
return Err("Not enough arguments for CREATE SITE".into());
|
||||
}
|
||||
engine
|
||||
.register_custom_syntax(
|
||||
&[
|
||||
"CREATE", "SITE", "$expr$", ",", "$expr$", ",", "$expr$", ",", "$expr$", ",",
|
||||
"$expr$",
|
||||
],
|
||||
true, // Statement
|
||||
|context, inputs| {
|
||||
if inputs.len() < 5 {
|
||||
return Err("Not enough arguments for CREATE SITE".into());
|
||||
}
|
||||
|
||||
let name = context.eval_expression_tree(&inputs[0])?;
|
||||
let company = context.eval_expression_tree(&inputs[1])?;
|
||||
let website = context.eval_expression_tree(&inputs[2])?;
|
||||
let template = context.eval_expression_tree(&inputs[3])?;
|
||||
let prompt = context.eval_expression_tree(&inputs[4])?;
|
||||
let name = context.eval_expression_tree(&inputs[0])?;
|
||||
let company = context.eval_expression_tree(&inputs[1])?;
|
||||
let website = context.eval_expression_tree(&inputs[2])?;
|
||||
let template = context.eval_expression_tree(&inputs[3])?;
|
||||
let prompt = context.eval_expression_tree(&inputs[4])?;
|
||||
|
||||
let result = json!({
|
||||
"command": "create_site",
|
||||
"name": name.to_string(),
|
||||
"company": company.to_string(),
|
||||
"website": website.to_string(),
|
||||
"template": template.to_string(),
|
||||
"prompt": prompt.to_string()
|
||||
});
|
||||
println!("CREATE SITE executed: {}", result.to_string());
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
).unwrap();
|
||||
let result = json!({
|
||||
"command": "create_site",
|
||||
"name": name.to_string(),
|
||||
"company": company.to_string(),
|
||||
"website": website.to_string(),
|
||||
"template": template.to_string(),
|
||||
"prompt": prompt.to_string()
|
||||
});
|
||||
println!("CREATE SITE executed: {}", result.to_string());
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// CREATE DRAFT command: CREATE DRAFT "to", "subject", "body"
|
||||
engine.register_custom_syntax(
|
||||
&["CREATE", "DRAFT", "$expr$", ",", "$expr$", ",", "$expr$"],
|
||||
true, // Statement
|
||||
|context, inputs| {
|
||||
if inputs.len() < 3 {
|
||||
return Err("Not enough arguments for CREATE DRAFT".into());
|
||||
}
|
||||
engine
|
||||
.register_custom_syntax(
|
||||
&["CREATE", "DRAFT", "$expr$", ",", "$expr$", ",", "$expr$"],
|
||||
true, // Statement
|
||||
|context, inputs| {
|
||||
if inputs.len() < 3 {
|
||||
return Err("Not enough arguments for CREATE DRAFT".into());
|
||||
}
|
||||
|
||||
let to = context.eval_expression_tree(&inputs[0])?;
|
||||
let subject = context.eval_expression_tree(&inputs[1])?;
|
||||
let body = context.eval_expression_tree(&inputs[2])?;
|
||||
let to = context.eval_expression_tree(&inputs[0])?;
|
||||
let subject = context.eval_expression_tree(&inputs[1])?;
|
||||
let body = context.eval_expression_tree(&inputs[2])?;
|
||||
|
||||
let result = json!({
|
||||
"command": "create_draft",
|
||||
"to": to.to_string(),
|
||||
"subject": subject.to_string(),
|
||||
"body": body.to_string()
|
||||
});
|
||||
println!("CREATE DRAFT executed: {}", result.to_string());
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
).unwrap();
|
||||
let result = json!({
|
||||
"command": "create_draft",
|
||||
"to": to.to_string(),
|
||||
"subject": subject.to_string(),
|
||||
"body": body.to_string()
|
||||
});
|
||||
println!("CREATE DRAFT executed: {}", result.to_string());
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// PRINT command
|
||||
engine.register_custom_syntax(
|
||||
&["PRINT", "$expr$"],
|
||||
true, // Statement
|
||||
|context, inputs| {
|
||||
let value = context.eval_expression_tree(&inputs[0])?;
|
||||
println!("{}", value);
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
).unwrap();
|
||||
engine
|
||||
.register_custom_syntax(
|
||||
&["PRINT", "$expr$"],
|
||||
true, // Statement
|
||||
|context, inputs| {
|
||||
let value = context.eval_expression_tree(&inputs[0])?;
|
||||
println!("{}", value);
|
||||
Ok(Dynamic::UNIT)
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Register web service functions
|
||||
engine.register_fn("web_get", |url: &str| {
|
||||
format!("Response from {}", url)
|
||||
});
|
||||
engine.register_fn("web_get", |url: &str| format!("Response from {}", url));
|
||||
|
||||
ScriptService {
|
||||
engine,
|
||||
|
@ -203,14 +219,13 @@ impl ScriptService {
|
|||
|
||||
result
|
||||
}
|
||||
pub fn compile(&self, script: &str) -> Result<rhai::AST, Box<EvalAltResult>> {
|
||||
let processed_script = self.preprocess_basic_script(script);
|
||||
match self.engine.compile(&processed_script) {
|
||||
Ok(ast) => Ok(ast),
|
||||
Err(parse_error) => Err(Box::new(EvalAltResult::from(parse_error))),
|
||||
pub fn compile(&self, script: &str) -> Result<rhai::AST, Box<EvalAltResult>> {
|
||||
let processed_script = self.preprocess_basic_script(script);
|
||||
match self.engine.compile(&processed_script) {
|
||||
Ok(ast) => Ok(ast),
|
||||
Err(parse_error) => Err(Box::new(EvalAltResult::from(parse_error))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn run(&self, ast: &rhai::AST) -> Result<Dynamic, Box<EvalAltResult>> {
|
||||
self.engine.eval_ast(ast)
|
||||
|
|
Loading…
Add table
Reference in a new issue