diff options
author | Simon Rettberg | 2018-04-20 14:17:54 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-04-20 14:17:54 +0200 |
commit | 78e4f08001cc66dcfc48617a7b002f30d6bf7de4 (patch) | |
tree | 72ead3a9a830069913d8ba3c5e4e0e505aeb3075 /satellit_installer | |
parent | [SSPS] Fix systemd dropin filename (diff) | |
download | setup-scripts-78e4f08001cc66dcfc48617a7b002f30d6bf7de4.tar.gz setup-scripts-78e4f08001cc66dcfc48617a7b002f30d6bf7de4.tar.xz setup-scripts-78e4f08001cc66dcfc48617a7b002f30d6bf7de4.zip |
[SSPS] Include IP address in PS1
Diffstat (limited to 'satellit_installer')
-rw-r--r-- | satellit_installer/includes/90-patch_misc_files.inc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/satellit_installer/includes/90-patch_misc_files.inc b/satellit_installer/includes/90-patch_misc_files.inc index 9729a18..22ba205 100644 --- a/satellit_installer/includes/90-patch_misc_files.inc +++ b/satellit_installer/includes/90-patch_misc_files.inc @@ -1,14 +1,21 @@ patch_bashrc() { echo "#" echo "# As one of the last things here we will set a new prompt to distinguish" - echo "# the beLehrpool satellite server from other servers. To accomplish this" + 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." echo "# Setting prompt..." - if grep -q 'PS1=".*01;31m.*01;32m.*01;34m' /root/.bashrc; then + if grep -q '^IP=' /root/.bashrc; then echo "...already done." else - echo 'PS1="\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;32m\]\h \[\033[01;34m\]\w\[\033[00m\] # "' >> /root/.bashrc + cat >> /root/.bashrc <<-"ENDO" + IP=$(ip -4 a show eth0 | 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%/*} + PS1="\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;32m\]\h \[\033[00m\]($IP) + \[\033[01;34m\]\w\[\033[00m\] # " + ENDO fi + # aliases, dircolors sed -i -r 's/# *(alias|export LS|eval ")/\1/' /root/.bashrc } |