summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-10-23 09:37:55 +0200
committerSimon Rettberg2023-10-23 09:37:55 +0200
commit57a43a136d5a8c09e1fde393d75a3d66d6008482 (patch)
tree3d4609feca908a6bfeec57ab9ea8d4cd5401f496
parent[SSPS] Cleanup (diff)
downloadsetup-scripts-57a43a136d5a8c09e1fde393d75a3d66d6008482.tar.gz
setup-scripts-57a43a136d5a8c09e1fde393d75a3d66d6008482.tar.xz
setup-scripts-57a43a136d5a8c09e1fde393d75a3d66d6008482.zip
[SSPS] bashrc: No more ifconfig; fix prompt char #/$
-rw-r--r--satellit_installer/static_files/system/opt/openslx/bashrc.inc10
1 files changed, 6 insertions, 4 deletions
diff --git a/satellit_installer/static_files/system/opt/openslx/bashrc.inc b/satellit_installer/static_files/system/opt/openslx/bashrc.inc
index 98711d4..6e8689e 100644
--- a/satellit_installer/static_files/system/opt/openslx/bashrc.inc
+++ b/satellit_installer/static_files/system/opt/openslx/bashrc.inc
@@ -1,13 +1,15 @@
-ifname="$( ifconfig | grep -oEm1 '^e\w+' )"
-slxip="$( ip -4 a show "$ifname" 2>/dev/null | grep -m1 '^\s*inet ' | awk '{print $2}' )"
+slxif="$( ip a s 2> /dev/null | grep -oPm1 '(?<=^[0-9]: )e[^:]+' )"
+slxip="$( ip -4 a s "$slxif" 2> /dev/null | grep -m1 '^\s*inet ' | awk '{print $2}' )"
[ -z "$slxip" ] && slxip="$( ip -4 a | grep '^\s*inet '| grep -vFm1 ' 127.' | awk '{print $2}' )"
slxip=${slxip%/*}
[ -z "$slxip" ] && read -r _ _ slxip _ <<<"$SSH_CONNECTION"
[ -z "$slxip" ] && slxip="noip???"
slxcol=32
+slxchar='$'
(( UID == 0 )) && slxcol=31
+(( UID == 0 )) && slxchar='#'
PS1="\[\033[01;${slxcol}m\]\u\[\033[00m\]@\[\033[01;32m\]\h \[\033[00m\]($slxip)
-\[\033[01;34m\]\w\[\033[00m\] # "
-unset ifname slxip slxcol
+\[\033[01;34m\]\w\[\033[00m\] $slxchar "
+unset slxif slxip slxcol slxchar
# We always want to run this as root; sudo is a noop in case we already are.
alias tmate='sudo tmate'