save default peachcloud config if file does not exist
This commit is contained in:
parent
84656ff251
commit
824cbdbc0c
|
@ -34,6 +34,7 @@ use std::{process, sync::RwLock};
|
|||
|
||||
use lazy_static::lazy_static;
|
||||
use log::{debug, error, info};
|
||||
use peach_lib::{config_manager, config_manager::YAML_PATH as PEACH_CONFIG};
|
||||
use rocket::{fairing::AdHoc, serde::Deserialize, Build, Rocket};
|
||||
|
||||
use utils::Theme;
|
||||
|
@ -90,6 +91,18 @@ async fn main() {
|
|||
// initialize logger
|
||||
env_logger::init();
|
||||
|
||||
// check if /var/lib/peachcloud/config.yml exists
|
||||
if !std::path::Path::new(PEACH_CONFIG).exists() {
|
||||
info!("PeachCloud configuration file not found; loading default values");
|
||||
// since we're in the intialisation phase, panic if the loading fails
|
||||
let config =
|
||||
config_manager::load_peach_config().expect("peachcloud configuration loading failed");
|
||||
|
||||
info!("Saving default PeachCloud configuration values to file");
|
||||
// this ensures a config file is created if it does not already exist
|
||||
config_manager::save_peach_config(config).expect("peachcloud configuration saving failed");
|
||||
}
|
||||
|
||||
// initialize rocket
|
||||
let rocket = init_rocket();
|
||||
|
||||
|
|
Loading…
Reference in New Issue