From 25c4bcd9fc74bd376fc8e1ef7efc64fa11446696 Mon Sep 17 00:00:00 2001 From: axtloss Date: Sun, 31 Jul 2022 14:17:51 +0200 Subject: [PATCH 1/8] Add sushi for gnome and onyx installation --- src/functions/desktops.rs | 3 +++ src/internal/install.rs | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/functions/desktops.rs b/src/functions/desktops.rs index 3039da8..9217b22 100755 --- a/src/functions/desktops.rs +++ b/src/functions/desktops.rs @@ -155,6 +155,8 @@ fn install_gnome() { "gdm", "xorg", "gnome-tweaks", + "gnome-backgrounds", + "sushi", ]); enable_dm("gdm"); } @@ -166,6 +168,7 @@ fn install_onyx() { "lightdm", "lightdm-gtk-greeter", "lightdm-gtk-greeter-settings", + "sushi", ]); files_eval( files::append_file( diff --git a/src/internal/install.rs b/src/internal/install.rs index 7d94d43..b803c4f 100755 --- a/src/internal/install.rs +++ b/src/internal/install.rs @@ -1,5 +1,4 @@ use crate::internal::*; -use crate::functions::partition::mount; use crate::functions::partition::umount; use std::process::Command; From 36590317aa8982075149ee0a1cf045118e0fc324 Mon Sep 17 00:00:00 2001 From: UsernameSwift Date: Wed, 3 Aug 2022 13:13:27 -0400 Subject: [PATCH 2/8] Added shell chooser --- src/args.rs | 4 +++ src/functions/unakite.rs | 1 + src/functions/users.rs | 61 ++++++++++++++++++++++++++++++++++++++-- src/internal/config.rs | 3 ++ src/main.rs | 2 +- 5 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/args.rs b/src/args.rs index 7e6d01c..b656852 100644 --- a/src/args.rs +++ b/src/args.rs @@ -228,6 +228,10 @@ pub struct NewUserArgs { /// When not providing a password openssl jumps into an interactive masked input mode allowing you to hide your password /// from the terminal history. pub password: String, + + /// The shell to use for the user. The current options are bash, csh, fish, tcsh, and zsh. + /// If a shell is not specified or unknown, it defaults to fish. + pub shell: String, } #[derive(Debug, ArgEnum, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Serialize, Deserialize)] diff --git a/src/functions/unakite.rs b/src/functions/unakite.rs index c4028f4..06e1a6d 100644 --- a/src/functions/unakite.rs +++ b/src/functions/unakite.rs @@ -127,6 +127,7 @@ pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev true, "Cp7oN04ZY0PsA", // unakite false, + "/bin/bash", ); exec_eval( exec( diff --git a/src/functions/users.rs b/src/functions/users.rs index d63d445..8bcc7b4 100755 --- a/src/functions/users.rs +++ b/src/functions/users.rs @@ -2,7 +2,8 @@ use crate::internal::exec::*; use crate::internal::*; use std::process::Command; -pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: bool) { +pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: bool, shell: &str) { + let mut shell: &str = shell; if do_hash_pass { let hashed_pass = &*hash_pass(password).stdout; let _password = match std::str::from_utf8(hashed_pass) { @@ -10,13 +11,66 @@ pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: boo Err(e) => panic!("Failed to hash password, invalid UTF-8 sequence {}", e), }; } + if shell == "fish" { + exec_eval( + exec_chroot( + "bash", + vec![ + String::from("pacman -S fish --noconfirm"), + ], + ), + "installed fish", + ); + } + if shell == "zsh" { + exec_eval( + exec_chroot( + "bash", + vec![ + String::from("pacman -S zsh --noconfirm"), + ], + ), + "installed zsh", + ); + } + else if shell == "tcsh" || shell == "csh" { + exec_eval( + exec_chroot( + "bash", + vec![ + String::from("pacman -S tcsh --noconfirm"), + ], + ), + "installed tcsh and csh", + ); + } + else { + exec_eval( + exec_chroot( + "bash", + vec![ + String::from("pacman -S fish --noconfirm"), + ], + ), + "no shell or unknown shell specified, installed fish", + ); + shell = "fish"; + } + let shell_path = match shell { + "bash" => "/bin/bash", + "csh" => "/bin/csh", + "fish" => "/bin/fish", + "tcsh" => "/bin/tcsh", + "zsh" => "/bin/zsh", + &_ => "/bin/fish", + }; exec_eval( exec_chroot( "useradd", vec![ String::from("-m"), String::from("-s"), - String::from("/bin/bash"), + String::from(shell_path), String::from("-p"), String::from(password).replace('\n', ""), String::from(username), @@ -49,7 +103,7 @@ pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: boo pub fn hash_pass(password: &str) -> std::process::Output { let output = Command::new("openssl") - .args(["passwd", "-1", password]) + .args(["passwd", "-6", password]) .output() .expect("Failed to hash password"); output @@ -67,3 +121,4 @@ pub fn root_pass(root_pass: &str) { "set root password", ); } + diff --git a/src/internal/config.rs b/src/internal/config.rs index 928014f..080383d 100755 --- a/src/internal/config.rs +++ b/src/internal/config.rs @@ -53,6 +53,7 @@ struct Users { name: String, password: String, hasroot: bool, + shell: String, } #[derive(Serialize, Deserialize)] @@ -138,11 +139,13 @@ pub fn read_config(configpath: PathBuf) { log::info!("Creating user : {}", config.users[i].name); log::info!("Setting use password : {}", config.users[i].password); log::info!("Enabling root for user : {}", config.users[i].hasroot); + log::info!("Setting user shell : {}", config.users[i].shell); users::new_user( config.users[i].name.as_str(), config.users[i].hasroot, config.users[i].password.as_str(), false, + config.users[i].shell.as_str(), ); println!("---------"); } diff --git a/src/main.rs b/src/main.rs index 95c13fe..c3d924a 100755 --- a/src/main.rs +++ b/src/main.rs @@ -53,7 +53,7 @@ fn main() { } Command::Users { subcommand } => match subcommand { UsersSubcommand::NewUser(args) => { - users::new_user(&args.username, args.hasroot, &args.password, true); + users::new_user(&args.username, args.hasroot, &args.password, true, &args.shell); } UsersSubcommand::RootPass { password } => { users::root_pass(&password); From ede22122820db0d5fb98bad1c72743240440534b Mon Sep 17 00:00:00 2001 From: usernameswift Date: Wed, 3 Aug 2022 17:06:31 -0400 Subject: [PATCH 3/8] Fixed shell paths --- src/functions/users.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/functions/users.rs b/src/functions/users.rs index 8bcc7b4..4d3b194 100755 --- a/src/functions/users.rs +++ b/src/functions/users.rs @@ -58,11 +58,11 @@ pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: boo } let shell_path = match shell { "bash" => "/bin/bash", - "csh" => "/bin/csh", - "fish" => "/bin/fish", - "tcsh" => "/bin/tcsh", - "zsh" => "/bin/zsh", - &_ => "/bin/fish", + "csh" => "/usr/bin/csh", + "fish" => "/usr/bin/fish", + "tcsh" => "/usr/bin/tcsh", + "zsh" => "/usr/bin/zsh", + &_ => "/usr/bin/fish", }; exec_eval( exec_chroot( From 2c83afa4fe366eda37c99e9e1e23ba651ea20e1e Mon Sep 17 00:00:00 2001 From: usernameswift Date: Wed, 3 Aug 2022 17:53:30 -0400 Subject: [PATCH 4/8] Reworked the shell choosing --- src/functions/users.rs | 68 +++++++++++++----------------------------- 1 file changed, 21 insertions(+), 47 deletions(-) diff --git a/src/functions/users.rs b/src/functions/users.rs index 4d3b194..cf8c325 100755 --- a/src/functions/users.rs +++ b/src/functions/users.rs @@ -3,7 +3,7 @@ use crate::internal::*; use std::process::Command; pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: bool, shell: &str) { - let mut shell: &str = shell; + let shell: &str = shell; if do_hash_pass { let hashed_pass = &*hash_pass(password).stdout; let _password = match std::str::from_utf8(hashed_pass) { @@ -11,51 +11,25 @@ pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: boo Err(e) => panic!("Failed to hash password, invalid UTF-8 sequence {}", e), }; } - if shell == "fish" { - exec_eval( - exec_chroot( - "bash", - vec![ - String::from("pacman -S fish --noconfirm"), - ], - ), - "installed fish", - ); - } - if shell == "zsh" { - exec_eval( - exec_chroot( - "bash", - vec![ - String::from("pacman -S zsh --noconfirm"), - ], - ), - "installed zsh", - ); - } - else if shell == "tcsh" || shell == "csh" { - exec_eval( - exec_chroot( - "bash", - vec![ - String::from("pacman -S tcsh --noconfirm"), - ], - ), - "installed tcsh and csh", - ); - } - else { - exec_eval( - exec_chroot( - "bash", - vec![ - String::from("pacman -S fish --noconfirm"), - ], - ), - "no shell or unknown shell specified, installed fish", - ); - shell = "fish"; - } + let shell_to_install = match shell { + "bash" => "bash", + "csh" => "tcsh", + "fish" => "fish", + "tcsh" => "tcsh", + "zsh" => "zsh", + &_ => "bash", + }; + exec_eval( + exec_chroot( + "bash", + vec![ + String::from("pacman -S "), + String::from(shell_to_install), + String::from("--noconfirm"), + ], + ), + format!("installed {shell:?}").as_str(), + ); let shell_path = match shell { "bash" => "/bin/bash", "csh" => "/usr/bin/csh", @@ -103,7 +77,7 @@ pub fn new_user(username: &str, hasroot: bool, password: &str, do_hash_pass: boo pub fn hash_pass(password: &str) -> std::process::Output { let output = Command::new("openssl") - .args(["passwd", "-6", password]) + .args(["passwd", "-1", password]) .output() .expect("Failed to hash password"); output From f835115eef5727a87f6dd66c6636b07b3d2983f8 Mon Sep 17 00:00:00 2001 From: axtloss Date: Thu, 4 Aug 2022 12:06:33 +0200 Subject: [PATCH 5/8] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 72ddd7f..c2a1eff 100755 --- a/README.md +++ b/README.md @@ -67,17 +67,17 @@ jade networking getcryst.al --ipv6 ### configure users ```sh -# make a new user called nonRootHaver, without sudo and easytohack as the password -jade users newUser nonRootHaver easytohack +# make a new user called nonRootHaver, without sudo, easytohack as the password and bash as the default shell +jade users new-user nonRootHaver easytohack bash -# make a user called rootHaver, with sudo and omgsosuperhardtohack as the password -jade users newUser rootHaver omgsuperhardtohack --sudoer +# make a user called rootHaver, with sudo, omgsosuperhardtohack as the password and fish as the default shell +jade users new-user rootHaver omgsuperhardtohack fish --hasroot ``` ### set root password ```sh # set the root password to 'muchSecurity,veryHardToHack' -jade users rootPass muchSecurity,veryHardToHack +jade users root-password muchSecurity,veryHardToHack ``` ### install a desktop environment From b9547beba72d82b388b6d34f9384784884f4f108 Mon Sep 17 00:00:00 2001 From: axtloss Date: Fri, 5 Aug 2022 15:30:12 +0200 Subject: [PATCH 6/8] Add new desktop environments and window managers --- src/args.rs | 18 ++++++ src/functions/desktops.rs | 126 ++++++++++++++++++++++++++++++++++++++ src/internal/config.rs | 6 ++ 3 files changed, 150 insertions(+) diff --git a/src/args.rs b/src/args.rs index b656852..eb21828 100644 --- a/src/args.rs +++ b/src/args.rs @@ -260,6 +260,24 @@ pub enum DesktopSetup { #[clap(name = "enlightenment")] Enlightenment, + #[clap(name = "lxqt")] + Lxqt, + + #[clap(name = "sway")] + Sway, + + #[clap(name = "i3gaps")] + I3gaps, + + #[clap(name = "herbstluftwm")] + Herbstluftwm, + + #[clap(name = "awesome")] + Awesome, + + #[clap(name = "bspwm")] + Bspwm, + #[clap(name = "None/DIY")] None, } diff --git a/src/functions/desktops.rs b/src/functions/desktops.rs index 9217b22..5f86e04 100755 --- a/src/functions/desktops.rs +++ b/src/functions/desktops.rs @@ -13,6 +13,12 @@ pub fn install_desktop_setup(desktop_setup: DesktopSetup) { DesktopSetup::Mate => install_mate(), DesktopSetup::Xfce => install_xfce(), DesktopSetup::Enlightenment => install_enlightenment(), + DesktopSetup::Lxqt => install_lxqt(), + DesktopSetup::Sway => install_sway(), + DesktopSetup::I3gaps => install_i3gaps(), + DesktopSetup::Herbstluftwm => install_herbstluftwm(), + DesktopSetup::Awesome => install_awesome(), + DesktopSetup::Bspwm => install_bspwm(), DesktopSetup::None => log::debug!("No desktop setup selected"), } install_networkmanager(); @@ -29,6 +35,126 @@ fn install_networkmanager() { ); } +fn install_bspwm() { + install(vec![ + "xorg", + "bspwm", + "sxhkd", + "xdo", + "lightdm", + "lightdm-gtk-greeter", + "lightdm-gtk-greeter-settings", + ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); +} + +fn install_awesome() { + install(vec![ + "xorg", + "awesome", + "dex", + "rlwrap", + "vicious", + "lightdm", + "lightdm-gtk-greeter", + "lightdm-gtk-greeter-settings", + ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); +} + +fn install_herbstluftwm() { + install(vec![ + "xorg", + "herbstluftwm", + "dmenu", + "dzen2", + "xorg-xsetroot", + "xterm", + "lightdm", + "lightdm-gtk-greeter", + "lightdm-gtk-greeter-settings", + ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); +} + +fn install_i3gaps() { + install(vec![ + "xorg", + "i3-gaps", + "dmenu", + "i3lock", + "i3status", + "rxvt-unicode", + "lightdm", + "lightdm-gtk-greeter", + "lightdm-gtk-greeter-settings", + ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); +} + +fn install_sway() { + install(vec![ + "xorg-xwayland", + "sway", + "bemenu", + "foot", + "mako", + "polkit", + "swaybg", + "lightdm", + "lightdm-gtk-greeter", + "lightdm-gtk-greeter-settings", + ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); +} + +fn install_lxqt() { + install(vec![ + "xorg", + "lxqt", + "breeze-icons", + "nm-tray", + "xscreensaver", + "sddm", + ]); + enable_dm("sddm"); +} + fn install_enlightenment() { install(vec![ "xorg", diff --git a/src/internal/config.rs b/src/internal/config.rs index 080383d..09655b0 100755 --- a/src/internal/config.rs +++ b/src/internal/config.rs @@ -166,6 +166,12 @@ pub fn read_config(configpath: PathBuf) { "xfce" => desktops::install_desktop_setup(DesktopSetup::Xfce), "budgie" => desktops::install_desktop_setup(DesktopSetup::Budgie), "enlightenment" => desktops::install_desktop_setup(DesktopSetup::Enlightenment), + "lxqt" => desktops::install_desktop_setup(DesktopSetup::Lxqt), + "sway" => desktops::install_desktop_setup(DesktopSetup::Sway), + "i3-gaps" => desktops::install_desktop_setup(DesktopSetup::I3gaps), + "herbstluftwm" => desktops::install_desktop_setup(DesktopSetup::Herbstluftwm), + "awesome" => desktops::install_desktop_setup(DesktopSetup::Awesome), + "bspwm" => desktops::install_desktop_setup(DesktopSetup::Bspwm), "None/DIY" => desktops::install_desktop_setup(DesktopSetup::None), _ => log::info!("No desktop setup selected!"), } From c9a812a61465aa48855dda7acb6b7d0a6659f754 Mon Sep 17 00:00:00 2001 From: axtloss Date: Fri, 5 Aug 2022 16:13:31 +0200 Subject: [PATCH 7/8] Remove onyx --- src/args.rs | 4 ++-- src/functions/desktops.rs | 2 +- src/internal/config.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/args.rs b/src/args.rs index eb21828..53f0201 100644 --- a/src/args.rs +++ b/src/args.rs @@ -236,8 +236,8 @@ pub struct NewUserArgs { #[derive(Debug, ArgEnum, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Serialize, Deserialize)] pub enum DesktopSetup { - #[clap(name = "onyx")] - Onyx, + //#[clap(name = "onyx")] + //Onyx, #[clap(name = "gnome")] Gnome, diff --git a/src/functions/desktops.rs b/src/functions/desktops.rs index 5f86e04..a0a073e 100755 --- a/src/functions/desktops.rs +++ b/src/functions/desktops.rs @@ -5,7 +5,7 @@ use crate::internal::*; pub fn install_desktop_setup(desktop_setup: DesktopSetup) { log::debug!("Installing {:?}", desktop_setup); match desktop_setup { - DesktopSetup::Onyx => install_onyx(), + // DesktopSetup::Onyx => install_onyx(), DesktopSetup::Gnome => install_gnome(), DesktopSetup::Kde => install_kde(), DesktopSetup::Budgie => install_budgie(), diff --git a/src/internal/config.rs b/src/internal/config.rs index 09655b0..d3ddbd1 100755 --- a/src/internal/config.rs +++ b/src/internal/config.rs @@ -158,7 +158,7 @@ pub fn read_config(configpath: PathBuf) { desktops::install_desktop_setup(*desktop); }*/ match config.desktop.as_str() { - "onyx" => desktops::install_desktop_setup(DesktopSetup::Onyx), + // "onyx" => desktops::install_desktop_setup(DesktopSetup::Onyx), "plasma" => desktops::install_desktop_setup(DesktopSetup::Kde), "mate" => desktops::install_desktop_setup(DesktopSetup::Mate), "gnome" => desktops::install_desktop_setup(DesktopSetup::Gnome), From ae881c5bacb664c79f5179aa63715dddac457d7c Mon Sep 17 00:00:00 2001 From: axtloss Date: Fri, 5 Aug 2022 18:40:58 +0200 Subject: [PATCH 8/8] fmt --- src/args.rs | 1 - src/functions/desktops.rs | 2 +- src/functions/users.rs | 1 - src/internal/config.rs | 2 +- src/internal/install.rs | 2 +- src/main.rs | 8 +++++++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/args.rs b/src/args.rs index 53f0201..0f42b06 100644 --- a/src/args.rs +++ b/src/args.rs @@ -238,7 +238,6 @@ pub struct NewUserArgs { pub enum DesktopSetup { //#[clap(name = "onyx")] //Onyx, - #[clap(name = "gnome")] Gnome, diff --git a/src/functions/desktops.rs b/src/functions/desktops.rs index a0a073e..cdeb4ed 100755 --- a/src/functions/desktops.rs +++ b/src/functions/desktops.rs @@ -5,7 +5,7 @@ use crate::internal::*; pub fn install_desktop_setup(desktop_setup: DesktopSetup) { log::debug!("Installing {:?}", desktop_setup); match desktop_setup { - // DesktopSetup::Onyx => install_onyx(), + // DesktopSetup::Onyx => install_onyx(), DesktopSetup::Gnome => install_gnome(), DesktopSetup::Kde => install_kde(), DesktopSetup::Budgie => install_budgie(), diff --git a/src/functions/users.rs b/src/functions/users.rs index cf8c325..81502df 100755 --- a/src/functions/users.rs +++ b/src/functions/users.rs @@ -95,4 +95,3 @@ pub fn root_pass(root_pass: &str) { "set root password", ); } - diff --git a/src/internal/config.rs b/src/internal/config.rs index d3ddbd1..e413133 100755 --- a/src/internal/config.rs +++ b/src/internal/config.rs @@ -158,7 +158,7 @@ pub fn read_config(configpath: PathBuf) { desktops::install_desktop_setup(*desktop); }*/ match config.desktop.as_str() { - // "onyx" => desktops::install_desktop_setup(DesktopSetup::Onyx), + // "onyx" => desktops::install_desktop_setup(DesktopSetup::Onyx), "plasma" => desktops::install_desktop_setup(DesktopSetup::Kde), "mate" => desktops::install_desktop_setup(DesktopSetup::Mate), "gnome" => desktops::install_desktop_setup(DesktopSetup::Gnome), diff --git a/src/internal/install.rs b/src/internal/install.rs index b803c4f..a136fac 100755 --- a/src/internal/install.rs +++ b/src/internal/install.rs @@ -1,5 +1,5 @@ -use crate::internal::*; use crate::functions::partition::umount; +use crate::internal::*; use std::process::Command; pub fn install(pkgs: Vec<&str>) { diff --git a/src/main.rs b/src/main.rs index c3d924a..3925e73 100755 --- a/src/main.rs +++ b/src/main.rs @@ -53,7 +53,13 @@ fn main() { } Command::Users { subcommand } => match subcommand { UsersSubcommand::NewUser(args) => { - users::new_user(&args.username, args.hasroot, &args.password, true, &args.shell); + users::new_user( + &args.username, + args.hasroot, + &args.password, + true, + &args.shell, + ); } UsersSubcommand::RootPass { password } => { users::root_pass(&password);