etc.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. use serde::Deserialize;
  2. use toml::Value;
  3. use crate::cfg::boot::BootConfigDef;
  4. #[derive(Deserialize, Clone)]
  5. pub struct EtcConfigDef{
  6. pub sys: SysCfg,
  7. pub env: toml::map::Map<String, Value>,
  8. pub boot_default: BootConfigDef,
  9. pub secure: SecureCfg,
  10. }
  11. impl EtcConfigDef {
  12. pub fn default() -> EtcConfigDef {
  13. EtcConfigDef{
  14. sys: SysCfg {
  15. sys_loader: "/nagae/elip4ng/bin/chen".to_string(),
  16. service_mgr: "/nagae/elip4ng/bin/ran".to_string(),
  17. shell_spawner: "/nagae/elip4ng/bin/reimu".to_string(),
  18. svc_mgr_exit_restart_limit: 10,
  19. svc_mgr_exit_restart_delay_secs: 1,
  20. },
  21. env: toml::map::Map::new(),
  22. boot_default: BootConfigDef::default(),
  23. secure: SecureCfg{
  24. bcrypt_password: "$2a$10$9Nk9um4osOsdDPw.NjgBx.0qbQ/5H/qLXplaNjBeKKj6N13.PE3YK".to_string(),
  25. },
  26. }
  27. }
  28. pub fn get_boot_default_clone(&self) -> BootConfigDef{
  29. self.boot_default.clone()
  30. }
  31. }
  32. #[derive(Deserialize, Clone)]
  33. pub struct SecureCfg {
  34. pub bcrypt_password: String,
  35. }
  36. #[derive(Deserialize, Clone)]
  37. pub struct SysCfg {
  38. pub sys_loader: String,
  39. pub service_mgr: String,
  40. pub shell_spawner: String,
  41. pub svc_mgr_exit_restart_limit: u64,
  42. pub svc_mgr_exit_restart_delay_secs: u64,
  43. }
  44. #[derive(Deserialize, Clone)]
  45. pub struct TeletypeCfg {
  46. pub baudrate: u32,
  47. pub device: String,
  48. pub getty: String,
  49. pub shell: String,
  50. }