make stuff actually run in chroot

axtloss/rework-partitioning
amy 3 years ago
parent d32c20e6f7
commit a241d83130

@ -2,8 +2,8 @@ use crate::internal::*;
pub fn set_hostname(hostname: &str) {
println!("Setting hostname to {}", hostname);
files::create_file("/etc/hostname");
let return_val = files::append_file("/etc/hostname", hostname);
files::create_file("/mnt/etc/hostname");
let return_val = files::append_file("/mnt/etc/hostname", hostname);
match return_val {
Ok(_) => {
log(format!("Set hostname to {}", hostname));
@ -19,7 +19,7 @@ pub fn set_hostname(hostname: &str) {
pub fn enable_ipv6(ipv6: bool) {
if ipv6 {
let return_val = files::append_file("/etc/hosts", "::1 localhost");
let return_val = files::append_file("/mnt/etc/hosts", "::1 localhost");
match return_val {
Ok(_) => {
log("Enabled IPv6".to_string());

@ -2,7 +2,7 @@ use crate::internal::exec::*;
use crate::internal::*;
pub fn new_user(username: &str, hasroot: bool, password: &str) {
let return_val = exec(
let return_val = exec_chroot(
"useradd",
vec![
String::from("-m"),
@ -23,7 +23,7 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
}
}
if hasroot {
let return_val = exec(
let return_val = exec_chroot(
"usermod",
vec![
String::from("-a"),
@ -41,11 +41,9 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
}
}
}
let return_val = exec(
"arch-chroot",
let return_val = exec_chroot(
"usermod",
vec![
String::from("/mnt"),
String::from("usermod"),
String::from("--password"),
String::from("$(echo"),
String::from(format!("${}", password)),
@ -72,11 +70,9 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
pub fn root_pass(root_pass: &str) {
println!("Setting root password to '{}'", root_pass);
let return_val = exec(
"arch-chroot",
let return_val = exec_chroot(
"usermod",
vec![
String::from("/mnt"),
String::from("usermod"),
String::from("--password"),
String::from("$(echo"),
String::from(format!("${{{}}}", root_pass)),

@ -5,6 +5,11 @@ pub fn exec(command: &str, args: Vec<String>) -> Result<std::process::Output, st
returncode
}
pub fn exec_chroot(command: &str, args: Vec<String>) -> Result<std::process::Output, std::io::Error> {
let returncode = Command::new("arch-chroot").args(&["/mnt", command]).args(args).output();
returncode
}
pub fn exec_workdir(command: &str, workdir: &str, args: Vec<String>,) -> Result<std::process::Output, std::io::Error> {
let returncode = Command::new(command).args(args).current_dir(workdir).output();
returncode

Loading…
Cancel
Save