-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved config to appconfig, moved static ruleset to cloned one, improv…
…ed ruleset strategy, created ruleevent, adapt structure to manage ruleevent
- Loading branch information
Showing
17 changed files
with
1,782 additions
and
305 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (C) 2024, Achiefs. | ||
|
||
use crate::ruleset::Ruleset; | ||
use crate::appconfig::*; | ||
use crate::utils; | ||
|
||
|
||
pub fn init() -> (AppConfig, Ruleset) { | ||
use std::path::Path; | ||
use simplelog::WriteLogger; | ||
use simplelog::Config; | ||
use std::fs; | ||
|
||
println!("[INFO] Achiefs File Integrity Monitoring software starting!"); | ||
println!("[INFO] Reading config..."); | ||
let cfg = AppConfig::new(&utils::get_os(), None); | ||
|
||
// Create folders to store logs based on config.yml | ||
fs::create_dir_all( | ||
Path::new( &cfg.clone().log_file | ||
).parent().unwrap().to_str().unwrap() | ||
).unwrap(); | ||
|
||
// Create logger output to write generated logs. | ||
WriteLogger::init( | ||
cfg.clone().get_level_filter(), | ||
Config::default(), | ||
fs::OpenOptions::new() | ||
.create(true) | ||
.append(true) | ||
.open(cfg.clone().log_file) | ||
.expect("Unable to open log file") | ||
).unwrap(); | ||
|
||
println!("[INFO] Configuration successfully read, forwarding output to log file."); | ||
println!("[INFO] Log file: '{}'", cfg.clone().log_file); | ||
println!("[INFO] Log level: '{}'", cfg.clone().log_level); | ||
|
||
let ruleset = Ruleset::new(&utils::get_os(), None); | ||
|
||
log_panics::init(); | ||
(cfg, ruleset) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.