From 23f5903e1fa3940a9df9bceb4d00fa9684de5688 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Thu, 26 Sep 2019 22:49:01 -0400 Subject: [PATCH] set up color scheme on console shell --- ph-init/src/error.rs | 4 ++++ ph-init/src/init.rs | 15 +++++++++++++++ ph-init/src/service.rs | 7 +++++-- src/vm/config.rs | 7 +++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ph-init/src/error.rs b/ph-init/src/error.rs index 8340459..a7a10a8 100644 --- a/ph-init/src/error.rs +++ b/ph-init/src/error.rs @@ -31,6 +31,8 @@ pub enum Error { RebootFailed(io::Error), OpenLogFailed(io::Error), XAuthFail(io::Error), + WriteBashrc(io::Error), + NetworkConfigure(netlink::Error), } impl fmt::Display for Error { @@ -67,6 +69,8 @@ impl fmt::Display for Error { RebootFailed(err) => write!(f, "could not reboot system: {}", err), OpenLogFailed(err) => write!(f, "failed to open log file: {}", err), XAuthFail(err) => write!(f, "error creating .Xauthority file: {}", err), + WriteBashrc(err) => write!(f, "error writing bashrc file: {}", err), + NetworkConfigure(err) => write!(f, "error configuring network: {}", err), } } } diff --git a/ph-init/src/init.rs b/ph-init/src/init.rs index 6cc0c5a..26b48fd 100644 --- a/ph-init/src/init.rs +++ b/ph-init/src/init.rs @@ -7,6 +7,21 @@ use std::{fs, process, io, env}; use crate::service::{Service, ServiceLaunch}; use std::collections::BTreeMap; use std::io::Read; +use std::net::Ipv4Addr; +use std::str::FromStr; +use crate::netlink::NetlinkSocket; + +const BASHRC: &str = r#" +export PS1="airwolf > " +umask 022 +shopt -s checkwinsize +alias ls='ls --color=auto' +if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion +elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi +"#; pub struct InitServer { hostname: String, diff --git a/ph-init/src/service.rs b/ph-init/src/service.rs index b28ec66..64fcd95 100644 --- a/ph-init/src/service.rs +++ b/ph-init/src/service.rs @@ -22,6 +22,8 @@ const BASE_ENVIRONMENT: &[&str] = &[ const SHELL_ENVIRONMENT: &[&str] = &[ "SHELL=/bin/bash", + "PATH=/usr/bin:/usr/sbin", + "COLORTERM=truecolor", "TERM=xterm-256color", "GNOME_DESKTOP_SESSION_ID=this-is-deprecated", "NO_AT_BRIDGE=1", @@ -32,6 +34,7 @@ const SHELL_ENVIRONMENT: &[&str] = &[ "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus", ]; + pub struct Service { name: String, child: Child, @@ -136,8 +139,8 @@ impl ServiceLaunch { .root(root) .home(home) .env("HOME", home) - .shell_environment() - .arg("--login"); + .shell_environment(); + // .arg("--login"); match realm { Some(name) => shell.env("REALM_NAME", name), diff --git a/src/vm/config.rs b/src/vm/config.rs index 380d26a..ecbf2eb 100644 --- a/src/vm/config.rs +++ b/src/vm/config.rs @@ -105,6 +105,13 @@ impl VmConfig { let _terminal_restore = TerminalRestore::save(); + if let Some(scheme) = Base16Scheme::by_name("black-metal-immortal") { + let mut term = AnsiTerminal::new().unwrap(); + if let Err(err) = term.apply_base16(scheme) { + warn!("Failed to set terminal color scheme: {}", err); + } + } + match Vm::open(self) { Ok(vm) => if let Err(err) = vm.start() { notify!("Error starting VM: {}", err);