ksud: check image before shrink

This commit is contained in:
weishu 2024-02-19 12:31:13 +08:00
parent 81f15ef120
commit e0802b0d15
2 changed files with 12 additions and 3 deletions

View File

@ -254,7 +254,7 @@ pub fn run() -> Result<()> {
Module::Enable { id } => module::enable_module(&id),
Module::Disable { id } => module::disable_module(&id),
Module::List => module::list_modules(),
Module::Shrink => module::shrink_image(),
Module::Shrink => module::shrink_ksu_images(),
}
}
Commands::Install => event::install(),

View File

@ -674,11 +674,20 @@ pub fn list_modules() -> Result<()> {
Ok(())
}
pub fn shrink_image() -> Result<()> {
pub fn shrink_image(img: &str) -> Result<()> {
check_image(img)?;
Command::new("resize2fs")
.arg("-M")
.arg(defs::MODULE_IMG)
.arg(img)
.stdout(Stdio::piped())
.status()?;
Ok(())
}
pub fn shrink_ksu_images() -> Result<()> {
shrink_image(defs::MODULE_IMG)?;
if Path::new(defs::MODULE_UPDATE_IMG).exists() {
shrink_image(defs::MODULE_UPDATE_IMG)?;
}
Ok(())
}