Removed cism stuff.

This commit is contained in:
Stefan Gaiselmann 2020-10-23 18:59:25 +02:00
parent b0a5695a2c
commit 73bb47d4a9
2 changed files with 34 additions and 191 deletions

View File

@ -9,7 +9,8 @@ TODO: how to handle a new linux system correctly.
Test with `centos7-01`: Test with `centos7-01`:
. put executable to HOME dir . put executable to HOME dir
. initialize with `./chezmoi init https://gitea.sdroid.uber.space/heavy/dotfiles.git` . add public ssh key to gitea user
. initialize with `./chezmoi init sdroid@gitea.sdroid.uber.space:heavy/dotfiles.git`
. check what will happen with `./chezmoi diff` . check what will happen with `./chezmoi diff`
. apply it with `./chezmoi apply` . apply it with `./chezmoi apply`

216
dot_sshrc
View File

@ -1,125 +1,46 @@
if [ -f $HOME/.profile ]; then #
source $HOME/.profile # sshrc will be called byaliased ssh command 's'.
fi #
# if [ -f $HOME/.profile ]; then
# source $HOME/.profile
# fi
# if [ -f $HOME/.bashrc ]; then
# source $HOME/.bashrc
# fi
# #
# TODO: CISM Section # System Name and type detectedn
# #
mySystem=$(uname -n) mySystem=$(uname -n)
myFQDN="$(uname -n).$(dnsdomainname)" myFQDN="$(uname -n).$(dnsdomainname)"
mySlesVersionId=$(grep PRETTY_NAME /etc/os-release) if [ -f /etc/os-release ];then
mySlesVersion=${mySlesVersionId#*=} myPrettyName=$(grep PRETTY_NAME /etc/os-release)
mySlesVersion=${mySlesVersion//\"}
# Debugging
if [ "$myFQDN" == "BUI-NB1207-GP.bui.materna.com" ]; then
log_info "env: $myFQDN ($myType) in $myEnv"
myType=$myFQDN
myEnv=STG
myNum=0
else
myType=$myFQDN
myEnv=unknown
myNum=0
fi fi
function fadeIn() {
START=$1
END=$2
for ((i=$START; i<=$END; i++)); do
FADE="$FADE\[\e[48;5;${i}m\] "
done
FADE="$FADE \[\e[0m"
}
function fadeOut() {
START=$1
END=$2
for ((i=$START; i<=$END; i--)); do
FADE="$FADE\[\e[48;5;${i}m\] "
echo -e "$FADE"
done
FADE="$FADE \[\e[0m"
}
# CPU function
function getCPULoad {
echo $(sar -u 1 1 | awk '/^Average:/{print 100-$8}')
}
# last exit code # last exit code
function lastExitCode { function lastExitCode {
local exit="$?" local exit="$?"
local VERSION_ID=$(grep VERSION_ID /etc/os-release)
local SLES_VERSION=${VERSION_ID#*=}
local SLES_VERSION=${SLES_VERSION//\"}
if [ $exit != 0 ];then if [ $exit != 0 ];then
# echo -e "${sol_red}!${bg_reset}"
# printf '\[\033[32m\]0_0\[\033\0m\]'
# printf '0_0 ✕'
printf '\e[38;5;160m%-5s' "✕ ❗ ($exit)" printf '\e[38;5;160m%-5s' "✕ ❗ ($exit)"
else else
# echo "OK" printf '✔'
# printf '^_^ ✔'
printf '✔'
fi fi
# printf "  $SLES_VERSION"
} }
# Solarized Theme # sourcing Solarized Theme
# and building PS1 prompt
source $HOME/.solarize_colors_base source $HOME/.solarize_colors_base
echo "mySystem: $mySystem"
echo "myFQDN: $myFQDN"
bg_system="\[\e[48;5;0m\]"
bg_type="\[\e[48;5;254m\]"
bg_reset="\[\e[49m\]" bg_reset="\[\e[49m\]"
fg_sytem="\[\e[38;5;15m\]"
fg_type="\[\e[1m\]"
fg_reset="\[\e[39m\]" fg_reset="\[\e[39m\]"
fg_arrow1="\[\e[38;5;18m\]" SYSTEM="<TODO>"
fg_arrow2="\[\e[38;5;254m\]" bg_system="${sol_bg_magenta}"
fg_system="${sol_magenta}"
# Background by ENV fg_type="${sol_magenta}"
dev="22"
prod="52"
sys="94"
case $myEnv in
DEV)
SYSTEM="Development System"
bg_system="${sol_bg_green}"
fg_system="${sol_green}"
fg_type="${sol_green}"
;;
TST)
SYSTEM="Test System"
bg_system="${sol_bg_blue}"
fg_system="${sol_blue}"
fg_type="${sol_blue}"
;;
PRD)
SYSTEM="Production System"
bg_system="${sol_bg_red}"
fg_system="${sol_red}"
fg_type="${sol_red}"
;;
STG|ST2)
SYSTEM="$myEnv"
bg_system="${sol_bg_yellow}"
fg_system="${sol_yellow}"
fg_type="${sol_yellow}"
;;
*)
echo "myEnv: $myEnv"
echo "myType: $myType"
SYSTEM="System of a Down"
bg_system="${sol_bg_magenta}"
fg_system="${sol_magenta}"
fg_type="${sol_magenta}"
;;
esac
bg_type="${sol_bg_base3}" bg_type="${sol_bg_base3}"
fg_arrow1="${fg_type}" fg_arrow1="${fg_type}"
@ -135,29 +56,13 @@ if [ "$myNum" != "0" ]; then
fi fi
echo "System Prompt: $SYSTEM_PROMPT" echo "System Prompt: $SYSTEM_PROMPT"
# SYSTEM_PROMPT="\n${bg_system}${fg_sytem}${SYSTEM} ${bg_type}${fg_arrow1}"
#  "
#                
SYSTEM_PROMPT="\n${fg_arrow1}░▒▓${bg_system} ${fg_sytem}${SYSTEM} ${bg_type}${fg_arrow1}▓▒░" SYSTEM_PROMPT="\n${fg_arrow1}░▒▓${bg_system} ${fg_sytem}${SYSTEM} ${bg_type}${fg_arrow1}▓▒░"
# fadeIn 64 230
#echo -e "$FADE"
# SYSTEM_PROMPT="\n${bg_system}${fg_sytem}${SYSTEM} $FADE"
# TYPE_PROMPT="$TYPE  [CPU: \$(getCPULoad) %] ${bg_reset}${fg_arrow2}"
# TYPE_PROMPT="$TYPE  [\$(if [ \$? = 0 ]; then echo ${sol_red}^_^; else echo 0_0; fi)] ${bg_reset}${fg_arrow2}▓▒░"
# TYPE_PROMPT="$TYPE  \$(lastExitCode) ${bg_reset}${fg_arrow2}▓▒░"
# TYPE_PROMPT="$TYPE  \$(lastExitCode) ${fg_arrow1}  $mySlesVersion ${sol_blue}\${STY#[0-9]*.} ${bg_reset}${fg_arrow2}▇▆▅▄▃▂▁"
TYPE_PROMPT="$TYPE  \$(lastExitCode) ${fg_arrow1}  $mySlesVersion ${sol_blue}\${STY#[0-9]*.} ${bg_reset}${fg_arrow2}▓▒░" TYPE_PROMPT="$TYPE  \$(lastExitCode) ${fg_arrow1}  $mySlesVersion ${sol_blue}\${STY#[0-9]*.} ${bg_reset}${fg_arrow2}▓▒░"
# With CPU Load
# TYPE_PROMPT="$TYPE  [CPU: \$(getCPULoad) %] ${bg_reset}${fg_arrow2}▓▒░"
# TYPE_PROMPT="\[\e[48;5;27;1;30m$TYPE ${bg_reset}\[\e[48;5;27m░▒▓"
PROMPT="${SYSTEM_PROMPT} ${TYPE_PROMPT}" PROMPT="${SYSTEM_PROMPT} ${TYPE_PROMPT}"
DATE="\[\e[0;32m\]\d \t" DATE="\[\e[0;32m\]\d \t"
if [ "$(whoami)" = "root" ]; then if [ "$(whoami)" = "root" ]; then
DIR="\[\e[97;49m\]\[\e[0;91;107m\] \u@\h \[\e[97;49m\]\[\e[39;49m\] in \[\e[0;32m\]\w" DIR="\[\e[97;49m\]\[\e[0;91;107m\] \u@\h \[\e[97;49m\]\[\e[39;49m\] in \[\e[0;32m\]\w"
# DIR="\[\e[97;49m\]▒\[\e[0;91;107m\] \u@\h \[\e[97;49m\]▒\[\e[39;49m\] in \[\e[0;32m\]\w"
else else
DIR="\[\e[0;32m\]\u@\h \[\e[31m\]☆ \[\e[0;32m\]\w" DIR="\[\e[0;32m\]\u@\h \[\e[31m\]☆ \[\e[0;32m\]\w"
fi fi
@ -166,10 +71,6 @@ fi
PS1="${PROMPT}\[\e[0m\] \n${DIR}\n${DATE} → \[\e[0m\]" PS1="${PROMPT}\[\e[0m\] \n${DIR}\n${DATE} → \[\e[0m\]"
echo '┌─────────────────────────────┐'
echo '│ Welcome to CISM │'
echo '└─────────────────────────────┘'
if [ $(whoami | grep root | wc -l) == 1 ]; then if [ $(whoami | grep root | wc -l) == 1 ]; then
echo -e "\e[31;107m┌─────────────────────────────┐\e[0m" echo -e "\e[31;107m┌─────────────────────────────┐\e[0m"
echo -e "\e[31;107m│ YOU ARE ROOT, BE CAREFUL! │\e[0m" echo -e "\e[31;107m│ YOU ARE ROOT, BE CAREFUL! │\e[0m"
@ -177,72 +78,16 @@ if [ $(whoami | grep root | wc -l) == 1 ]; then
# Test mintty # Test mintty
echo -ne '\e]11;44,10,10\a' echo -ne '\e]11;44,10,10\a'
else
# echo -ne '\e]11;0,30,60\a'
log_warn "TODO: background colors..."
fi fi
if [ $(hostname | grep solveig | wc -l) == 1 ]; then # TODO: background colors...
echo 'Welcome on solveig' # TODO: private history file for shared accounts
export PS1="\n\d \t ☆ \e[1;31m\]\u@\h \[\e[39m\]in \[\e[0;32m\]\w\n\[\e[0;32m\]$(git branch) → \[\e[39m\]" # TODO: vim
elif [ $(hostname | grep openwrt | wc -l) == 1 ]; then
PS1="\e[36m \t \e[31m- \e[32m\u@\h \e[0m in \w \n \e[0;32m \$ \e[39m"
fi
# taken from https://github.com/randomphrase/dotfiles/blob/master/sshrc
# modified to use own "HOME"
# Are we using a shared account?
# if [[ -z "$ENVIRONMENT" ]]; then
# Use my own shell history file
# export HISTFILE=$HOME/.bash_history.$SSH_INCOMING_USER
# elif [[ "$ENVIRONMENT" == "CISM" ]]; then
if [[ -d "/home/arsystem/HOME/sgaisel/bash_history" ]]; then
export HISTFILE=/home/arsystem/HOME/sgaisel/bash_history/${USER}_$(uname -n)
log_info "using bash history $HISTFILE"
else
echo "no 'HOME' found, using standard history file"
fi
# alias tree="find ./ -type d | sed -e 's/[^-][^\/]*\//--/g;s/--/ |-/'"
# fi
# use own vim parameters if available
# if [[ -f "$HOME/HOME/sgaisel/.vimrc" ]]; then
# echo 'using .vimrc from /home/arsystem/HOME/sgaisel'
# alias vi="vim --cmd 'set rtp^=/home/arsystem/HOME/sgaisel/.vim' -u /home/arsystem/HOME/sgaisel/.vimrc"
# fi
#fi
# avoid '^?' in vim
# see https://vim.fandom.com/wiki/Backspace_and_delete_problems
stty erase '^?'
# Set Title, see https://superuser.com/questions/249293/rename-tmux-window-name-to-prompt-command-ps1-or-remote-ssh-hostname
settitle() {
printf "\033k$1\033\\"
}
# settitle "$(uname -n)"
settitle "$myEnv ($(uname -n))"
export LS_OPTIONS='--color=auto' export LS_OPTIONS='--color=auto'
eval "$(dircolors -b)" eval "$(dircolors -b)"
alias ls='ls $LS_OPTIONS' alias ls='ls $LS_OPTIONS'
# Some aliases to tail logfiles
alias tailMisc='tail -f /srv/CISM/log-data/CONTEXT_misc/cism-misc.log'
alias tailWS='tail -f /srv/CISM/log-data/CONTEXT_ws/cism-ws.log'
alias tailGraph='tail -f /srv/CISM/log-data/CONTEXT_graph/cism-graph.log'
alias tailBB='tail -f /srv/CISM/log-data/CONTEXT_bb/cism-bb.log'
alias tailKM='tail -f /srv/CISM/log-data/CONTEXT_km/cism-km-main.log'
alias cs='/srv/CISM/sbin/ALLRC status | grep -B 2 -e active -e inactive'
alias dev='cd /srv/CISM/release-management/check-dev'
alias stg='cd /srv/CISM/release-management/rpm-stg'
# most used netcat alias
alias n='netcat -vz -w 10 '
alias psg='ps -aux | grep -v grep | grep ' alias psg='ps -aux | grep -v grep | grep '
# Some functions (some by c't magazine) # Some functions (some by c't magazine)
@ -259,14 +104,11 @@ backup() {
extract() { extract() {
case $1 in case $1 in
*.tar.bz2) tar xvjf $1 ;; *.tar.bz2) tar xvjf $1;;
*.tar.gz|*.tgz) tar xvfz $1 ;; *.tar.gz|*.tgz) tar xvfz $1;;
*.zip) unzip $1 ;; *.zip) unzip $1;;
*) echo "Not supported: $1" ;; *) echo "Not supported: $1";;
esac esac
} }
# extend Path PATH=$PATH:$HOME/bin
if [ "$(dnsdomainname)" = "emea.isn.corpintra.net" ];then
PATH=$PATH:/home/arsystem/HOME/sgaisel/bin
fi