added install logic to configure distrobox
to not pull the container image always. this should save space, and fix cloning on universal blue distros.
This commit is contained in:
@@ -9,6 +9,7 @@ use reqwest::blocking::get;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::process::exit;
|
||||
use directories::UserDirs;
|
||||
|
||||
|
||||
fn setup_folders(config_path: &PathBuf) -> (String, String, String, String, String, String, String, String, String){
|
||||
@@ -166,6 +167,71 @@ fn setup_folders(config_path: &PathBuf) -> (String, String, String, String, Stri
|
||||
}
|
||||
|
||||
|
||||
fn configure_distrobox(){
|
||||
let user_dirs_result = UserDirs::new();
|
||||
let mut success = false;
|
||||
let mut dbrcpath = PathBuf::new();
|
||||
if user_dirs_result.is_some(){
|
||||
let home = user_dirs_result.unwrap().home_dir().to_path_buf();
|
||||
dbrcpath.push(home);
|
||||
dbrcpath.push(".distroboxrc");
|
||||
let box_config_string_result = fs::read_to_string("/usr/etc/distrobox/distrobox.conf");
|
||||
if box_config_string_result.is_err(){
|
||||
println!("error reading distrobox config file");
|
||||
}
|
||||
else{
|
||||
let box_rc_file_res = fs::File::create(&dbrcpath);
|
||||
if box_rc_file_res.is_err(){
|
||||
println!("error creating {}", &dbrcpath.display());
|
||||
}
|
||||
else{
|
||||
let mut box_rc_file = box_rc_file_res.unwrap();
|
||||
let box_config_string = box_config_string_result.unwrap();
|
||||
let box_config_lines: Vec<&str> = box_config_string.split("\n").collect();
|
||||
let mut line_write_result = true;
|
||||
while line_write_result{
|
||||
for line in &box_config_lines{
|
||||
let mut _outline = String::new();
|
||||
if line.contains("container_always_pull"){
|
||||
_outline = "container_always_pull=\"0\"".to_owned();
|
||||
}
|
||||
else{
|
||||
_outline = line.to_string();
|
||||
}
|
||||
let box_rc_file_result = box_rc_file.write(_outline.as_bytes());
|
||||
if box_rc_file_result.is_ok(){
|
||||
box_rc_file_result.unwrap();
|
||||
line_write_result = true;
|
||||
}
|
||||
else{
|
||||
line_write_result = false;
|
||||
}
|
||||
}
|
||||
if line_write_result == false{
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
else{
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if success == false{
|
||||
println!("Error getting user dirs!");
|
||||
println!("distrobox config failed, please follow the following instructions...");
|
||||
print!("
|
||||
copy the distrobox config file to your home folder with the name .distroboxrc
|
||||
cp /usr/etc/distrobox/distrobox.conf ~/.distroboxrc
|
||||
|
||||
Then edit the file to change the line container_always_pull=\"1\" to container_always_pull=\"0\"
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub fn install(config_path: &PathBuf){
|
||||
let mut _terminal_commands = HashMap::from([
|
||||
@@ -284,5 +350,6 @@ Do you have a distrobox set up to function as your template for all new projects
|
||||
- [ ] Service
|
||||
- [ ] Service!
|
||||
- [ ] Serviceyear!").expect("error writing password spray template");
|
||||
configure_distrobox();
|
||||
std::process::exit(0);
|
||||
}
|
||||
@@ -369,22 +369,6 @@ pub fn promote_project(projects: &mut Vec<Project>, config_path: &PathBuf, proje
|
||||
new_files_dir.push(&promoted_project.project_name);
|
||||
new_notes_dir.push(&promoted_project.customer);
|
||||
new_notes_dir.push(&promoted_project.project_name);
|
||||
let files_dir_creation = fs::create_dir_all(&new_files_dir);
|
||||
if files_dir_creation.is_err(){
|
||||
let error = files_dir_creation.err().unwrap();
|
||||
println!("error creating current files directory!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
files_dir_creation.unwrap();
|
||||
let notes_dir_creation = fs::create_dir_all(&new_notes_dir);
|
||||
if notes_dir_creation.is_err(){
|
||||
let error = notes_dir_creation.err().unwrap();
|
||||
println!("error creating current notes directory!");
|
||||
println!("{}", error);
|
||||
return;
|
||||
}
|
||||
notes_dir_creation.unwrap();
|
||||
let folder_move_success = process::Command::new("mv")
|
||||
.arg("-i")
|
||||
.arg(&project.files_folder)
|
||||
|
||||
Reference in New Issue
Block a user