Merge pull request #14 from crystal-linux/development

Development
axtloss/rework-partitioning
axtloss 2 years ago committed by GitHub
commit 3e722345b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -67,17 +67,17 @@ jade networking getcryst.al --ipv6
### configure users ### configure users
```sh ```sh
# make a new user called nonRootHaver, without sudo and easytohack as the password # make a new user called nonRootHaver, without sudo, easytohack as the password and bash as the default shell
jade users newUser nonRootHaver easytohack jade users new-user nonRootHaver easytohack bash
# make a user called rootHaver, with sudo and omgsosuperhardtohack as the password # make a user called rootHaver, with sudo, omgsosuperhardtohack as the password and fish as the default shell
jade users newUser rootHaver omgsuperhardtohack --sudoer jade users new-user rootHaver omgsuperhardtohack fish --hasroot
``` ```
### set root password ### set root password
```sh ```sh
# set the root password to 'muchSecurity,veryHardToHack' # set the root password to 'muchSecurity,veryHardToHack'
jade users rootPass muchSecurity,veryHardToHack jade users root-password muchSecurity,veryHardToHack
``` ```
### install a desktop environment ### install a desktop environment

@ -228,13 +228,16 @@ pub struct NewUserArgs {
/// When not providing a password openssl jumps into an interactive masked input mode allowing you to hide your password /// When not providing a password openssl jumps into an interactive masked input mode allowing you to hide your password
/// from the terminal history. /// from the terminal history.
pub password: String, 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)] #[derive(Debug, ArgEnum, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Serialize, Deserialize)]
pub enum DesktopSetup { pub enum DesktopSetup {
#[clap(name = "onyx")] //#[clap(name = "onyx")]
Onyx, //Onyx,
#[clap(name = "gnome")] #[clap(name = "gnome")]
Gnome, Gnome,
@ -256,6 +259,24 @@ pub enum DesktopSetup {
#[clap(name = "enlightenment")] #[clap(name = "enlightenment")]
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")] #[clap(name = "None/DIY")]
None, None,
} }

@ -5,7 +5,7 @@ use crate::internal::*;
pub fn install_desktop_setup(desktop_setup: DesktopSetup) { pub fn install_desktop_setup(desktop_setup: DesktopSetup) {
log::debug!("Installing {:?}", desktop_setup); log::debug!("Installing {:?}", desktop_setup);
match desktop_setup { match desktop_setup {
DesktopSetup::Onyx => install_onyx(), // DesktopSetup::Onyx => install_onyx(),
DesktopSetup::Gnome => install_gnome(), DesktopSetup::Gnome => install_gnome(),
DesktopSetup::Kde => install_kde(), DesktopSetup::Kde => install_kde(),
DesktopSetup::Budgie => install_budgie(), DesktopSetup::Budgie => install_budgie(),
@ -13,6 +13,12 @@ pub fn install_desktop_setup(desktop_setup: DesktopSetup) {
DesktopSetup::Mate => install_mate(), DesktopSetup::Mate => install_mate(),
DesktopSetup::Xfce => install_xfce(), DesktopSetup::Xfce => install_xfce(),
DesktopSetup::Enlightenment => install_enlightenment(), 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"), DesktopSetup::None => log::debug!("No desktop setup selected"),
} }
install_networkmanager(); 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() { fn install_enlightenment() {
install(vec![ install(vec![
"xorg", "xorg",
@ -155,6 +281,8 @@ fn install_gnome() {
"gdm", "gdm",
"xorg", "xorg",
"gnome-tweaks", "gnome-tweaks",
"gnome-backgrounds",
"sushi",
]); ]);
enable_dm("gdm"); enable_dm("gdm");
} }
@ -166,6 +294,7 @@ fn install_onyx() {
"lightdm", "lightdm",
"lightdm-gtk-greeter", "lightdm-gtk-greeter",
"lightdm-gtk-greeter-settings", "lightdm-gtk-greeter-settings",
"sushi",
]); ]);
files_eval( files_eval(
files::append_file( files::append_file(

@ -127,6 +127,7 @@ pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev
true, true,
"Cp7oN04ZY0PsA", // unakite "Cp7oN04ZY0PsA", // unakite
false, false,
"/bin/bash",
); );
exec_eval( exec_eval(
exec( exec(

@ -2,7 +2,8 @@ use crate::internal::exec::*;
use crate::internal::*; use crate::internal::*;
use std::process::Command; 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 shell: &str = shell;
if do_hash_pass { if do_hash_pass {
let hashed_pass = &*hash_pass(password).stdout; let hashed_pass = &*hash_pass(password).stdout;
let _password = match std::str::from_utf8(hashed_pass) { let _password = match std::str::from_utf8(hashed_pass) {
@ -10,13 +11,40 @@ 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), Err(e) => panic!("Failed to hash password, invalid UTF-8 sequence {}", e),
}; };
} }
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",
"fish" => "/usr/bin/fish",
"tcsh" => "/usr/bin/tcsh",
"zsh" => "/usr/bin/zsh",
&_ => "/usr/bin/fish",
};
exec_eval( exec_eval(
exec_chroot( exec_chroot(
"useradd", "useradd",
vec![ vec![
String::from("-m"), String::from("-m"),
String::from("-s"), String::from("-s"),
String::from("/bin/bash"), String::from(shell_path),
String::from("-p"), String::from("-p"),
String::from(password).replace('\n', ""), String::from(password).replace('\n', ""),
String::from(username), String::from(username),

@ -53,6 +53,7 @@ struct Users {
name: String, name: String,
password: String, password: String,
hasroot: bool, hasroot: bool,
shell: String,
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
@ -138,11 +139,13 @@ pub fn read_config(configpath: PathBuf) {
log::info!("Creating user : {}", config.users[i].name); log::info!("Creating user : {}", config.users[i].name);
log::info!("Setting use password : {}", config.users[i].password); log::info!("Setting use password : {}", config.users[i].password);
log::info!("Enabling root for user : {}", config.users[i].hasroot); log::info!("Enabling root for user : {}", config.users[i].hasroot);
log::info!("Setting user shell : {}", config.users[i].shell);
users::new_user( users::new_user(
config.users[i].name.as_str(), config.users[i].name.as_str(),
config.users[i].hasroot, config.users[i].hasroot,
config.users[i].password.as_str(), config.users[i].password.as_str(),
false, false,
config.users[i].shell.as_str(),
); );
println!("---------"); println!("---------");
} }
@ -155,7 +158,7 @@ pub fn read_config(configpath: PathBuf) {
desktops::install_desktop_setup(*desktop); desktops::install_desktop_setup(*desktop);
}*/ }*/
match config.desktop.as_str() { 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), "plasma" => desktops::install_desktop_setup(DesktopSetup::Kde),
"mate" => desktops::install_desktop_setup(DesktopSetup::Mate), "mate" => desktops::install_desktop_setup(DesktopSetup::Mate),
"gnome" => desktops::install_desktop_setup(DesktopSetup::Gnome), "gnome" => desktops::install_desktop_setup(DesktopSetup::Gnome),
@ -163,6 +166,12 @@ pub fn read_config(configpath: PathBuf) {
"xfce" => desktops::install_desktop_setup(DesktopSetup::Xfce), "xfce" => desktops::install_desktop_setup(DesktopSetup::Xfce),
"budgie" => desktops::install_desktop_setup(DesktopSetup::Budgie), "budgie" => desktops::install_desktop_setup(DesktopSetup::Budgie),
"enlightenment" => desktops::install_desktop_setup(DesktopSetup::Enlightenment), "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), "None/DIY" => desktops::install_desktop_setup(DesktopSetup::None),
_ => log::info!("No desktop setup selected!"), _ => log::info!("No desktop setup selected!"),
} }

@ -1,6 +1,5 @@
use crate::internal::*;
use crate::functions::partition::mount;
use crate::functions::partition::umount; use crate::functions::partition::umount;
use crate::internal::*;
use std::process::Command; use std::process::Command;
pub fn install(pkgs: Vec<&str>) { pub fn install(pkgs: Vec<&str>) {

@ -53,7 +53,13 @@ fn main() {
} }
Command::Users { subcommand } => match subcommand { Command::Users { subcommand } => match subcommand {
UsersSubcommand::NewUser(args) => { 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 } => { UsersSubcommand::RootPass { password } => {
users::root_pass(&password); users::root_pass(&password);

Loading…
Cancel
Save