summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files/system/opt/openslx/bashrc.inc
diff options
context:
space:
mode:
authorSimon Rettberg2023-10-19 13:22:27 +0200
committerSimon Rettberg2023-10-19 13:22:27 +0200
commitf3ce2e1cbf6368a0e3bd176c59f0d0ab7cadd6c7 (patch)
tree64e31708c54461caf65710578d3fd1dc037bf266 /satellit_installer/static_files/system/opt/openslx/bashrc.inc
parent[SSPS] issue: lightred for better readablity on black background (diff)
downloadsetup-scripts-f3ce2e1cbf6368a0e3bd176c59f0d0ab7cadd6c7.tar.gz
setup-scripts-f3ce2e1cbf6368a0e3bd176c59f0d0ab7cadd6c7.tar.xz
setup-scripts-f3ce2e1cbf6368a0e3bd176c59f0d0ab7cadd6c7.zip
[SSPS] Modernize; switch default user to openslx + sudo
Diffstat (limited to 'satellit_installer/static_files/system/opt/openslx/bashrc.inc')
-rw-r--r--satellit_installer/static_files/system/opt/openslx/bashrc.inc13
1 files changed, 13 insertions, 0 deletions
diff --git a/satellit_installer/static_files/system/opt/openslx/bashrc.inc b/satellit_installer/static_files/system/opt/openslx/bashrc.inc
new file mode 100644
index 0000000..98711d4
--- /dev/null
+++ b/satellit_installer/static_files/system/opt/openslx/bashrc.inc
@@ -0,0 +1,13 @@
+ifname="$( ifconfig | grep -oEm1 '^e\w+' )"
+slxip="$( ip -4 a show "$ifname" 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
+(( UID == 0 )) && slxcol=31
+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
+# We always want to run this as root; sudo is a noop in case we already are.
+alias tmate='sudo tmate'