use crate::error::PeachConfigError; use crate::utils::cmd; /// All configs are stored in this folder, and should be read/writeable by peach group /// so they can be read and written by all PeachCloud services. pub const CONFIGS_DIR: &str = "/var/lib/peachcloud"; pub const PEACH_WEB_DIR: &str = "/usr/share/peach-web"; /// Utility function to set correct file permissions on the PeachCloud device. /// Accidentally changing file permissions is a fairly common thing to happen, /// so this is a useful CLI function for quickly correcting anything that may be out of order. pub fn set_permissions() -> Result<(), PeachConfigError> { println!("[ UPDATING FILE PERMISSIONS ON PEACHCLOUD DEVICE ]"); cmd(&["chmod", "-R", "u+rwX,g+rwX", CONFIGS_DIR])?; cmd(&["chown", "-R", "peach", CONFIGS_DIR])?; cmd(&["chgrp", "-R", "peach", CONFIGS_DIR])?; cmd(&["chmod", "-R", "u+rwX,g+rwX", PEACH_WEB_DIR])?; cmd(&["chown", "-R", "peach-web:peach", PEACH_WEB_DIR])?; println!("[ PERMISSIONS SUCCESSFULLY UPDATED ]"); Ok(()) }