diff options
author | Simon Rettberg | 2018-05-04 15:48:02 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-05-04 15:48:02 +0200 |
commit | 4dadaec99bcf1793801d514e85dcd0111ce16dc9 (patch) | |
tree | e4864ccd6c7f3fa1e7366053c50e8af3a75cf795 | |
parent | [SSUS] Properly stop and remove atftpd (diff) | |
download | setup-scripts-4dadaec99bcf1793801d514e85dcd0111ce16dc9.tar.gz setup-scripts-4dadaec99bcf1793801d514e85dcd0111ce16dc9.tar.xz setup-scripts-4dadaec99bcf1793801d514e85dcd0111ce16dc9.zip |
[SSPS] Fix IP detection in bashrc
-rw-r--r-- | satellit_installer/includes/90-patch_misc_files.inc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/satellit_installer/includes/90-patch_misc_files.inc b/satellit_installer/includes/90-patch_misc_files.inc index 22ba205..1edf931 100644 --- a/satellit_installer/includes/90-patch_misc_files.inc +++ b/satellit_installer/includes/90-patch_misc_files.inc @@ -3,14 +3,16 @@ patch_bashrc() { echo "# As one of the last things here we will set a new prompt to distinguish" echo "# the bwLehrpool satellite server from other servers. To accomplish this" echo "# we will set a very classy prompt. This will take effect at next root login." + local ifname=$( ifconfig | grep -oEm1 '^e\w+' ) echo "# Setting prompt..." if grep -q '^IP=' /root/.bashrc; then echo "...already done." else - cat >> /root/.bashrc <<-"ENDO" - IP=$(ip -4 a show eth0 | grep '^\s*inet\s' | awk -F ' ' '{print $2}') + sed "s/%ifname%/$ifname/g" >> /root/.bashrc <<-"ENDO" + IP=$( ip -4 a show "%ifname%" 2>/dev/null | grep '^\s*inet\s' | awk -F ' ' '{print $2}' ) [ -z "$IP" ] && IP=$(ip -4 a | grep '^\s*inet\s'| grep -v '127.0.0' | head -n 1 | awk -F ' ' '{print $2}') IP=${IP%/*} + [ -z "$IP" ] && IP="noip???" PS1="\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;32m\]\h \[\033[00m\]($IP) \[\033[01;34m\]\w\[\033[00m\] # " ENDO |