From 079d9ad2e33d4d45f2fa5755b0f28a07bac8b75e Mon Sep 17 00:00:00 2001 From: amy Date: Wed, 26 Jan 2022 22:07:38 +0100 Subject: [PATCH] add function to setup timeshift ( #4 ) --- src/functions/base.rs | 10 ++++++++-- src/functions/desktops.rs | 7 +++++-- src/functions/locale.rs | 5 +---- src/main.rs | 13 ++++++++++++- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/functions/base.rs b/src/functions/base.rs index def7676..939deec 100755 --- a/src/functions/base.rs +++ b/src/functions/base.rs @@ -19,8 +19,6 @@ pub fn install_base_packages() { "archlinux-keyring", "neofetch", "btrfs-progs", - "timeshift", - "timeshift-autosnap", "which", ]); } @@ -77,3 +75,11 @@ pub fn install_bootloader_legacy(device: &str) { "create grub.cfg", ); } + +pub fn setup_timeshift() { + install(vec!["timeshift", "timeshift-autosnap"]); + exec_eval( + exec_chroot("timeshift", vec![String::from("--btrfs")]), + "setup timeshift", + ) +} diff --git a/src/functions/desktops.rs b/src/functions/desktops.rs index 3f36f53..c6499c5 100755 --- a/src/functions/desktops.rs +++ b/src/functions/desktops.rs @@ -140,8 +140,11 @@ pub fn choose_pkgs(desktop_setup: &str) { } install(vec!["networkmanager"]); exec_eval( - exec_chroot("systemctl", vec![String::from("enable"), String::from("NetworkManager")]), - "Enable network manager" + exec_chroot( + "systemctl", + vec![String::from("enable"), String::from("NetworkManager")], + ), + "Enable network manager", ); } diff --git a/src/functions/locale.rs b/src/functions/locale.rs index 7c1b1e5..f3c5ed5 100755 --- a/src/functions/locale.rs +++ b/src/functions/locale.rs @@ -30,10 +30,7 @@ pub fn set_locale(locale: String) { "add locales to locale.gen", ); } - exec_eval( - exec_chroot("locale-gen", vec![]), - "generate locales", - ); + exec_eval(exec_chroot("locale-gen", vec![]), "generate locales"); files::create_file("/mnt/etc/locale.conf"); files_eval( files::append_file("/mnt/etc/locale.conf", "LANG=en_US.UTF-8"), diff --git a/src/main.rs b/src/main.rs index e215f04..c117ed6 100755 --- a/src/main.rs +++ b/src/main.rs @@ -38,6 +38,10 @@ fn main() { SubCommand::with_name("genfstab") .about("Generate fstab") ) + .subcommand( + SubCommand::with_name("setup-timeshift") + .about("Setup timeshift") + ) .subcommand( SubCommand::with_name("bootloader") .about("Install bootloader") @@ -154,7 +158,12 @@ fn main() { } else if let Some(app) = app.subcommand_matches("locale") { let kbrlayout = app.value_of("keyboard").unwrap(); let timezn = app.value_of("timezone").unwrap(); - locale::set_locale(app.values_of("locales").unwrap().collect::>().join(" ")); + locale::set_locale( + app.values_of("locales") + .unwrap() + .collect::>() + .join(" "), + ); locale::set_keyboard(kbrlayout); locale::set_timezone(timezn); } else if let Some(app) = app.subcommand_matches("networking") { @@ -187,6 +196,8 @@ fn main() { base::install_base_packages(); } else if app.subcommand_matches("genfstab").is_some() { base::genfstab(); + } else if app.subcommand_matches("setup-timeshift").is_some() { + base::setup_timeshift(); } else { println!("Running TUI installer"); }