From ddae640f77b618c024460c3c13315852e4dcd025 Mon Sep 17 00:00:00 2001 From: Sonny Date: Sun, 30 Sep 2018 13:50:45 +0200 Subject: [PATCH] Detect lxc containers --- .bashrc | 2 +- .profile | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.bashrc b/.bashrc index 29fb4bc..7941729 100644 --- a/.bashrc +++ b/.bashrc @@ -50,7 +50,7 @@ fi # Show different prompts for vm users or "normal" users if [ "$color_prompt" = yes ]; then - if [ $VM = true ]; then + if [ "$CONTAINER_OR_VM" = true ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else PS1="\[\033[1;33m\]\u\[\033[1;34m\]@\[\033[1;32m\]\h \[\033[1;34m\]\w\\[\033[0;37m\]$ " diff --git a/.profile b/.profile index 8a7d735..460b370 100644 --- a/.profile +++ b/.profile @@ -4,15 +4,19 @@ export SYSTEMD_EDITOR="/usr/bin/vim" export PAGER=less export BROWSER=/usr/bin/firefox +CONTAINER_OR_VM=false +SSH_ENV="$HOME/.ssh/environment" -VM=false -if [ "$(grep hypervisor /proc/cpuinfo)" ]; then - VM=true +if [ -z "$(which systemd-detect-virt)" ] || [ "$(systemd-detect-virt)" != "none" ]; then + CONTAINER_OR_VM=true fi -export VM +export CONTAINER_OR_VM + +if [ ! -f $SSH_ENV ]; then + mkdir $HOME/.ssh && touch $HOME/.ssh/environment +fi -SSH_ENV="$HOME/.ssh/environment" function start_agent { /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" chmod 600 "${SSH_ENV}"