2020-01-14 10:11:36 +01:00
# Initialize variables, if not set
[ -z ${ TMUX_SESSION_DIRS +x } ] && TMUX_SESSION_DIRS = ( ~/.config/tmux/sessions ~/.local/share/tmux/sessions ~/.tmux/sessions)
[ -z ${ SETPROXY_CREDS_DIRS +x } ] && SETPROXY_CREDS_DIRS = ( ~/.config/proxycreds)
[ -z ${ KERBEROS_CONFIG_DIRS +x } ] && KERBEROS_CONFIG_DIRS = ( ~/.config/kinit)
[ -z ${ ENCFS_CONFIG_DIRS +x } ] && ENCFS_CONFIG_DIRS = ( ~/.config/encfs)
export TMUX_SESSION_DIRS SETPROXY_CREDS_DIRS KERBEROS_CONFIG_DIRS
2020-11-28 17:42:42 +01:00
promptcommandmunge ( ) {
ENTRY
2020-11-28 18:00:17 +01:00
case " ; ${ PROMPT_COMMAND } ; " in
" *; $1 ;* " )
2020-11-28 17:42:42 +01:00
; ;
*)
if [ " $2 " = "after" ] ; then
2020-11-28 18:00:17 +01:00
PROMPT_COMMAND = " ${ PROMPT_COMMAND } ; $1 "
2020-11-28 17:42:42 +01:00
else
2020-11-28 18:00:17 +01:00
PROMPT_COMMAND = " $1 ; ${ PROMPT_COMMAND } "
2020-11-28 17:42:42 +01:00
fi
esac
EXIT
}
2021-10-11 07:59:34 +02:00
## this function updates in combination with PROMPT_COMMAND the shell-environment-variables in tmux-sessions,
2020-09-23 09:53:37 +02:00
# every time prompt is called. It does it only, when called from tmux (Environment TMUX is set)
2020-11-28 18:00:17 +01:00
function _tmux_hook( ) {
2020-09-23 10:19:50 +02:00
# [ -z "${TMUX+x}" ] || eval "$(tmux show-environment -s)"
if [ -n " ${ TMUX } " ] ; then
eval " $( tmux show-environment -s) "
fi
2020-09-23 09:53:37 +02:00
}
2020-11-28 17:42:42 +01:00
# To make the code more reliable on detecting the default umask
function _umask_hook {
# Record the default umask value on the 1st run
[ [ -z $DEFAULT_UMASK ] ] && export DEFAULT_UMASK = " $( builtin umask ) "
if [ [ -n $UMASK ] ] ; then
umask " $UMASK "
else
umask " $DEFAULT_UMASK "
fi
}
2022-11-16 00:14:58 +01:00
function cpb( ) {
2020-02-12 12:46:50 +01:00
scp " $1 " ${ SSH_CLIENT %% * } :~/Work
}
2022-11-16 00:14:58 +01:00
function sudo( ) {
2020-01-14 10:11:36 +01:00
local SUDO
2022-11-16 11:36:09 +01:00
local BASH
2023-01-11 09:47:46 +01:00
local C
2022-12-24 06:12:55 +01:00
2022-11-16 00:14:58 +01:00
# SUDO=$( if [ -e /bin/sudo ]; then echo /bin/sudo; else echo /usr/bin/sudo; fi )
SUDO = $( which sudo)
2022-11-16 11:36:09 +01:00
2023-01-11 09:47:46 +01:00
2022-12-24 06:21:40 +01:00
if $SSHS ; then
2023-01-11 09:47:46 +01:00
logdebug "TEMPCONFIG"
logdebug " \$1: $1 "
[ -e " $( which $1 2>/dev/null) " ] && C = "x"
logdebug " C: $C "
[ getbashrcfile ] && BASH = " bash --rcfile $( getbashrcfile) ${ C : +-c } " || unset BASH
logdebug " BASH1: $BASH "
[ -z " ${ C :- x } " ] && unset BASH
logdebug " BASH2: $BASH "
2022-12-24 06:21:40 +01:00
else
2023-01-11 09:47:46 +01:00
logdebug "NO Tempconfig"
unset BASH
2022-12-24 06:21:40 +01:00
fi
2023-01-11 09:47:46 +01:00
logdebug " SUDO: $SUDO "
logdebug " BASH3: $BASH "
logdebug " SHLVL: $SHLVL "
logdebug " @: $@ "
[ -z " ${ C :- x } " ] && logwarn " run $1 -> $( which $1 ) "
2022-12-24 06:21:40 +01:00
2023-01-11 09:47:46 +01:00
logdebug $SUDO \
2022-12-24 06:32:57 +01:00
GIT_AUTHOR_EMAIL = " $GIT_AUTHOR_EMAIL " \
GIT_AUTHOR_NAME = " $GIT_AUTHOR_NAME " \
GIT_COMMITTER_EMAIL = " $GIT_COMMITTER_EMAIL " \
GIT_COMMITTER_NAME = " $GIT_COMMITTER_NAME " \
TMUX = " $TMUX " \
SSHS = " $SSHS " \
P11M = " $P11M " \
SSH_TTY = " $SSH_TTY " \
SSH_AUTH_SOCK = " $SSH_AUTH_SOCK " \
http_proxy = " $http_proxy " \
$BASH \
2023-01-11 09:47:46 +01:00
$@
2020-07-06 10:28:14 +02:00
$SUDO \
2020-07-17 00:58:45 +02:00
GIT_AUTHOR_EMAIL = " $GIT_AUTHOR_EMAIL " \
GIT_AUTHOR_NAME = " $GIT_AUTHOR_NAME " \
GIT_COMMITTER_EMAIL = " $GIT_COMMITTER_EMAIL " \
GIT_COMMITTER_NAME = " $GIT_COMMITTER_NAME " \
TMUX = " $TMUX " \
SSHS = " $SSHS " \
2021-05-06 00:57:20 +02:00
P11M = " $P11M " \
2020-07-17 00:58:45 +02:00
SSH_TTY = " $SSH_TTY " \
2020-09-23 09:53:37 +02:00
SSH_AUTH_SOCK = " $SSH_AUTH_SOCK " \
2021-02-04 09:02:54 +01:00
http_proxy = " $http_proxy " \
2022-11-16 11:36:09 +01:00
$BASH \
2023-01-11 09:47:46 +01:00
$@
2020-01-14 10:11:36 +01:00
}
2022-11-16 00:14:58 +01:00
2020-01-14 10:11:36 +01:00
create_symlinks( ) {
2020-12-10 09:31:38 +01:00
#echo MSC_BASE: $MSC_BASE
# MSC_BASEDIR="$1"
# DIR="$(basename ${MSC_BASEDIR})"
# cd "${MSC_BASEDIR}"
2022-11-13 07:29:03 +01:00
[ -z " ${ MSC_GIT +x } " ] && MSC_GIT = git
2020-12-10 09:31:38 +01:00
cd ${ MSC_BASE }
#echo "DIR MSC_BASEDIR $DIR $MSC_BASEDIR"
2020-01-14 10:11:36 +01:00
git config credential.helper 'cache --timeout=300'
#Anlegen von Symlinks
rm -rf ~/.vimrc ~/.vim ~/bashrc_add ~/.gitconfig ~/.tmux.conf ~/.tmux
2020-12-10 09:31:38 +01:00
ln -sf " ${ MSC_BASE } /vimrc " ~/.vimrc
ln -sf " ${ MSC_BASE } /vim " ~/.vim
ln -sf " ${ MSC_BASE } /.gitconfig " ~/.gitconfig
ln -sf " ${ MSC_BASE } /.gitignore_global " ~/.gitignore_global
#ln -sf "${MSC_BASE}/bashrc_add" ~/bashrc_add
ln -sf " ${ MSC_BASE } /tmux " ~/.tmux
ln -sf " ${ MSC_BASE } /tmux/tmux.conf " ~/.tmux.conf
2020-01-14 10:11:36 +01:00
# Configure to use githooks in .githooks, not in standardlocation .git/hooks
2022-10-21 10:49:35 +02:00
$MSC_GIT config core.hooksPath .githooks
2020-01-14 10:11:36 +01:00
# remove all old symlinks in .githooks and relink files from .githooks to .git/hooks
# don't know, why i do it here. TODO: Check it
find .git/hooks -type l -exec rm { } \; && find .githooks -type f -exec ln -sf ../../{ } .git/hooks/ \;
cd ~-
}
setproxy ( ) {
2021-11-12 12:05:01 +01:00
# https://gist.github.com/yougg/5d2b3353fc5e197a0917aae0b3287d64
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
local CONFIG
case $# in
0)
2022-09-14 14:43:45 +02:00
logwarning "too few arguments"
2020-01-14 10:11:36 +01:00
return
; ;
*)
if [ -z ${ SETPROXY_CREDS_DIRS +x } ] ; then
2022-09-14 14:43:45 +02:00
logwarning "are you sure, SETPROXY_CREDS_DIRS is defined?"
2020-01-14 10:11:36 +01:00
return 1
else
CONFIG = $( find ${ SETPROXY_CREDS_DIRS [*] } -mindepth 1 -name " $1 .conf " -print -quit 2>/dev/null )
2021-11-12 10:15:41 +01:00
NO_PROXY = $( find ${ SETPROXY_CREDS_DIRS [*] } -mindepth 1 -name "no_proxy.conf" -print -quit 2>/dev/null )
2020-01-14 10:11:36 +01:00
fi
; ;
esac
2021-01-15 08:21:50 +01:00
2022-09-14 14:43:45 +02:00
logwarning " CONFIG: ${ CONFIG } "
2020-01-14 10:11:36 +01:00
if [ -e ${ CONFIG } ] ; then
2021-11-12 10:15:41 +01:00
logdebug -n " ${ CONFIG } existing: "
2020-01-14 10:11:36 +01:00
source " ${ CONFIG } "
2021-11-12 10:15:41 +01:00
loginfo " read $CONFIG "
export PROXY_CREDS = " $( urlencode ${ PROXY_USER } ) ${ PROXY_PASS : + : } $( urlencode ${ PROXY_PASS } ) "
2020-01-14 10:11:36 +01:00
else
2020-09-22 01:28:29 +02:00
loginfo " ${ CONFIG } not existing "
2021-11-12 10:15:41 +01:00
# export PROXY_CREDS=""
2020-01-14 10:11:36 +01:00
fi
2021-11-12 12:05:01 +01:00
export { http,https,ftp,rsync,all} _proxy = " ${ PROXY_PROTO :- http } :// ${ PROXY_CREDS } ${ PROXY_CREDS : +@ } ${ PROXY_SERVER } ${ PROXY_PORT : + : } ${ PROXY_PORT } "
export { HTTP,HTTPS,FTP,RSYNC,ALL} _PROXY = " ${ PROXY_PROTO :- http } :// ${ PROXY_CREDS } ${ PROXY_CREDS : +@ } ${ PROXY_SERVER } ${ PROXY_PORT : + : } ${ PROXY_PORT } "
2021-11-12 10:15:41 +01:00
no_proxy = "127.0.0.1,localhost"
#no_proxy=$no_proxy,$(echo 10.{0..255}.{0..255}.{0..255}|tr ' ' ',')
#no_proxy=$no_proxy,$(echo 172.{16..31}.{0..255}.{0..255}|tr ' ' ',')
#no_proxy=$no_proxy,$(echo 192.168.{0..255}.{0..255}|tr ' ' ',')
2021-11-23 12:36:18 +01:00
# no_proxy=${no_proxy}${PROXY_IGNORE:+,}${PROXY_IGNORE}
# . $NO_PROXY
2021-11-12 10:15:41 +01:00
export no_proxy
2021-11-12 12:05:01 +01:00
git config -f ~/.gitconfig_local http.sslverify false
git config -f ~/.gitconfig_local http.proxy $http_proxy
git config -f ~/.gitconfig_local https.proxy $http_proxy
# only for 'github.com'
git config -f ~/.gitconfig_local http.https://github.com.proxy $http_proxy
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
2021-11-12 12:05:01 +01:00
unsetproxy ( ) {
ENTRY
unset { HTTP,HTTPS,FTP,RSYNC,ALL} _PROXY
unset PROXY_{ CREDS,USER,PASS,SERVER,PORT,PROTO,IGNORE}
unset { http,https,ftp,rsync,all} _proxy
unset proxy_{ creds,user,pass,server,port}
unset no_proxy NO_PROXY
git config -f ~/.gitconfig_local --unset http.proxy
2021-11-12 12:59:48 +01:00
git config -f ~/.gitconfig_local --unset http.sslverify false
2021-11-12 12:05:01 +01:00
git config -f ~/.gitconfig_local --unset https.proxy
# git config -f ~/.gitconfig_local --unset core.sshCommand
git config -f ~/.gitconfig_local --unset http.https://github.com.proxy
EXIT
}
2020-01-14 10:11:36 +01:00
mencfs ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2022-09-14 14:43:45 +02:00
[ $# -eq 0 ] && { logwarning "too few arguments" >& 2; return 1; }
2020-01-14 10:11:36 +01:00
local PKEY
local ENCDIR
local DESTDIR
local PASS = $( which pass 2>/dev/null || exit 127 )
local ENCFS = $( which encfs 2>/dev/null || exit 127 )
local CONFIG
if [ -z ${ ENCFS_CONFIG_DIRS +x } ] ; then
2022-09-14 14:43:45 +02:00
logwarning "are you sure, ENCFS_CONFIG_DIRS is defined?"
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
return 1
else
CONFIG = $( find ${ ENCFS_CONFIG_DIRS [*] } -mindepth 1 -name " $1 .conf " -print -quit 2>/dev/null )
fi
if [ -e ${ CONFIG } ] ; then
2020-09-22 01:28:29 +02:00
loginfo -n " ${ CONFIG } existing: "
2020-01-14 10:11:36 +01:00
source " ${ CONFIG } "
2020-09-22 01:28:29 +02:00
loginfo "sourced"
2020-01-14 10:11:36 +01:00
else
2020-09-22 01:28:29 +02:00
loginfo " ${ CONFIG } not existing "
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
return 2
fi
2020-11-28 16:12:37 +01:00
logdebug " ENCDIR: $ENCDIR "
2020-09-22 01:42:10 +02:00
[ -z ${ PKEY +x } ] && { EXIT; return 3; }
[ -z ${ ENCDIR +x } ] && { EXIT; return 4; }
2020-11-28 16:12:37 +01:00
[ -z " ${ DESTDIR +x } " ] && [ -n " ${ XDG_RUNTIME_DIR } " ] && DESTDIR = " ${ XDG_RUNTIME_DIR } /decrypted/ $( basename $ENCDIR | tr '[:lower:]' '[:upper:]' | sed -e 's/^\.//' ) "
2020-01-14 10:11:36 +01:00
[ -z ${ DESTDIR +x } ] && DESTDIR = " $( dirname $ENCDIR ) / $( basename $ENCDIR | tr '[:lower:]' '[:upper:]' | sed -e 's/^\.//' ) "
2020-11-28 16:12:37 +01:00
logdebug " DESTDIR: $DESTDIR "
2020-11-19 20:35:00 +01:00
[ -d " $DESTDIR " ] || mkdir -p " $DESTDIR "
2022-09-28 01:28:12 +02:00
$PASS " ${ PKEY } " 1>/dev/null 2>& 1 || { logerr " entry $PKEY does not exist in passwordsotre " ; return 5; }
2022-03-15 09:28:57 +01:00
local ENCFS_PASSWORD = $( $PASS show " ${ PKEY } " | head -n1)
2020-01-14 10:11:36 +01:00
if [ -z ${ ENCDIR +x } -a -d ${ ENCDIR } ] ; then
2022-09-28 01:28:12 +02:00
logerr "no encrypted directory found -> exit"
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
return 4
else
2020-09-22 01:28:29 +02:00
loginfo " mount encrypted directory $ENCDIR on $DESTDIR "
2020-01-14 10:11:36 +01:00
$ENCFS -S $ENCDIR $DESTDIR <<!
$ENCFS_PASSWORD
!
if [ $? ] ; then
2020-09-22 01:28:29 +02:00
loginfo " open $DESTDIR "
2020-01-14 10:11:36 +01:00
xdg-open $DESTDIR
fi
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
uencfs ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
local FUSERMOUNT = $( which fusermount 2>/dev/null || exit 127 )
2020-04-09 21:26:24 +02:00
local i
2020-01-14 10:11:36 +01:00
[ -z ${ FUSERMOUNT +x } ] && return 127
if [ $# -eq 1 ] ; then
if [ ! -d ${ 1 } ] ; then
2022-09-14 14:43:45 +02:00
logwarning " encrypted directory ${ 1 } not found -> exit " >& 2
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
return 128
else
2020-09-22 01:28:29 +02:00
loginfo "umount encrypted directory" $1 >& 2
2020-04-09 21:26:24 +02:00
sync
2020-11-28 16:12:37 +01:00
$FUSERMOUNT -z -u " $1 "
2020-01-14 10:11:36 +01:00
fi
else
2020-09-22 01:28:29 +02:00
loginfo "no arguments given. Umount all mounted encfs-dirs" >& 2
2020-01-14 10:11:36 +01:00
for i in $( mount| grep encfs| sed -e 's/^encfs on \(.*\)\ type.*$/\1/' ) ; do
2020-09-22 01:28:29 +02:00
loginfo " $FUSERMOUNT -u $i "
2020-04-09 21:26:24 +02:00
sync
2020-11-28 16:12:37 +01:00
$FUSERMOUNT -z -u " $i "
2020-01-14 10:11:36 +01:00
done
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
return 1
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
kinit-custom ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
local PKEY
local REALM
local PASS = $( which pass 2>/dev/null || exit 127 )
local KINIT = $( which kinit 2>/dev/null || exit 127 )
local CONFIG
if [ -z ${ KERBEROS_CONFIG_DIRS +x } ] ; then
2022-09-14 14:43:45 +02:00
logwarning "are you sure, KERBEROS_CONFIG_DIRS is defined?"
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
return 1
else
CONFIG = $( find ${ KERBEROS_CONFIG_DIRS [*] } -mindepth 1 -name " $1 .conf " -print -quit 2>/dev/null )
fi
if [ -e ${ CONFIG } ] ; then
2020-09-22 01:42:10 +02:00
logdebug -n " ${ CONFIG } existing: "
2020-01-14 10:11:36 +01:00
source " ${ CONFIG } "
2020-09-22 01:42:10 +02:00
logdebug "sourced"
2020-01-14 10:11:36 +01:00
else
2022-09-14 14:43:45 +02:00
logwarning " ${ CONFIG } not existing "
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
return 2
fi
[ -z ${ PKEY +x } ] && return 3
$PASS " ${ PKEY } " 1>/dev/null 2>& 1 || return 3
2022-03-15 09:28:57 +01:00
logtrace " PKEY: ${ PKEY } "
local KERBEROS_PASSWORD = " $( $PASS show " ${ PKEY } " | head -n1) "
local KERBEROS_USER = " $( $PASS " ${ PKEY } " | grep login | sed -e 's/^login: //' ) "
logdebug " $( $PASS " ${ PKEY } " | grep login | sed -e 's/^login: //' ) "
logtrace " KERBEROS_PASSWORD: ${ KERBEROS_PASSWORD } "
logdebug " KERBEROS_USER: ${ KERBEROS_USER } "
2020-09-22 01:42:10 +02:00
loginfo " Get kerberos-ticket for: $KERBEROS_USER @ $REALM "
2020-01-14 10:11:36 +01:00
2022-03-15 09:28:57 +01:00
if [ -z ${ KERBEROS_USER : +x } ] ; then
2022-09-14 14:43:45 +02:00
logwarning "no kerberos user found -> exit"
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
return 4
else
$KINIT -R " ${ KERBEROS_USER } @ ${ REALM } " <<!
${ KERBEROS_PASSWORD }
!
if [ $? -gt 0 ] ; then
2020-09-22 01:42:10 +02:00
loginfo renew kerberos-ticket failed. try to get a new one
2020-01-14 10:11:36 +01:00
$KINIT " ${ KERBEROS_USER } @ ${ REALM } " <<!
${ KERBEROS_PASSWORD }
!
fi
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
2021-09-15 13:55:20 +02:00
# transfered to bin
#git-mergedetachedheadtomaster () {
# ENTRY
# git checkout -b tmp
# git branch -f master tmp
# git checkout master
# git branch -d tmp
# git commit -m "Merged detached head into master" .
# #git push origin master
# EXIT
#}
2020-01-14 10:11:36 +01:00
pathmunge ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
case " : ${ PATH } : " in
*:" $1 " :*)
; ;
*)
if [ " $2 " = "after" ] ; then
PATH = $PATH :$1
else
PATH = $1 :$PATH
fi
esac
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
mkcd ( ) {
mkdir -p " $1 "
cd " $1 "
}
2020-01-14 11:37:02 +01:00
sshmyshellconfig( ) {
2020-01-14 10:11:36 +01:00
2020-09-22 01:42:10 +02:00
ENTRY
2022-11-16 11:36:09 +01:00
2020-12-10 09:31:38 +01:00
[ -z " ${ MSC_SUBPATH +x } " ] && MSC_SUBPATH = ".local/myshellconfig"
[ -z " ${ MSC_BASE +x } " ] && MSC_BASE = " ${ HOME } / ${ MSC_SUBPATH } "
2022-11-16 11:36:09 +01:00
echo MSC_GIT_REMOTE_NAME: $MSC_GIT_REMOTE_NAME
MSC_GIT_REMOTE_NAME = $( $MSC_GIT rev-parse --abbrev-ref @{ u} 2>/dev/null | cut -d'/' -f1)
echo MSC_GIT_REMOTE_NAME: $MSC_GIT_REMOTE_NAME
2020-12-10 09:31:38 +01:00
MSC_BASE_PARENT = " $( dirname $MSC_BASE ) "
2020-04-04 12:21:50 +02:00
2020-01-14 14:44:36 +01:00
if [ $1 = = "localhost" ] ; then
2020-01-14 14:32:07 +01:00
CMD = ""
else
local SSH = "/usr/bin/ssh"
2020-12-10 09:31:38 +01:00
[ -e ${ MSC_BASE } /bashrc_add ] && $SSH -T -o VisualHostKey = no $@ "mkdir -p ~/\$MSC_BASE_PARENT; cat > ~/bashrc_add" < " ${ MSC_BASE } /bashrc_add "
2020-01-14 14:32:07 +01:00
local CMD = " $SSH -T $@ "
fi
2020-01-14 10:11:36 +01:00
$CMD /bin/bash << EOF
2022-11-16 11:36:09 +01:00
set -x
2020-01-14 10:11:36 +01:00
[ -e /etc/bashrc ] && . /etc/bashrc
[ -e /etc/bash.bashrc ] && . /etc/bash.bashrc
2020-12-14 14:05:18 +01:00
echo "modify ~/.bashrc"
2020-01-14 21:37:53 +01:00
sed -i -e '/^\[ -f bashrc_add \] /d' ~/.bashrc
2020-01-14 14:01:05 +01:00
sed -i -e '/#MYSHELLCONFIG-start/,/#MYSHELLCONFIG-end/d' ~/.bashrc
2020-01-14 10:11:36 +01:00
echo
2020-12-10 09:31:38 +01:00
printf "%s\n" "#MYSHELLCONFIG-start" " [ -f \"\${HOME}/ ${ MSC_SUBPATH } /bashrc_add\" ] && . \"\${HOME}/ ${ MSC_SUBPATH } /bashrc_add\" " "#MYSHELLCONFIG-end" | tee -a ~/.bashrc
#printf "%s\n" "#MYSHELLCONFIG-start" "if [ -e \${HOME}/${MSC_SUBPATH}/bashrc_add ]; then" " . \${HOME}/${MSC_SUBPATH}/bashrc_add;" "else" " if [ -f ~/bashrc_add ] ;then" " . ~/bashrc_add;" " fi;" "fi" "#MYSHELLCONFIG-end" |tee -a ~/.bashrc
2020-01-14 10:11:36 +01:00
echo
2020-12-14 14:05:18 +01:00
echo cleanup from old config
2020-01-15 01:46:55 +01:00
rm -rf ~/server-config && echo rm -rf ~/server-config
2021-02-02 09:49:05 +01:00
echo mkdir -p ~/.local
mkdir -p ~/.local
2022-11-16 11:36:09 +01:00
echo git clone --recurse-submodules $( git remote get-url $MSC_GIT_REMOTE_NAME ) \$ { HOME} /${ MSC_SUBPATH }
git clone --recurse-submodules $( git remote get-url $MSC_GIT_REMOTE_NAME ) \$ { HOME} /${ MSC_SUBPATH }
2020-12-14 14:02:31 +01:00
date "+%s" > \$ { HOME} /${ MSC_SUBPATH } /.last_update_submodules
2021-02-14 02:16:54 +01:00
# date "+%s" > \${HOME}/${MSC_SUBPATH}/.last_update_repo
2020-01-14 10:11:36 +01:00
EOF
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
2020-01-14 14:53:38 +01:00
2022-05-19 14:22:38 +02:00
#sshs() {
# ENTRY
#
#
# local LOGLEVEL="WARN"
## MKTMPCMD='mktemp $(echo ${XDG_RUNTIME_DIR}/bashrc.XXXXXXXX.conf)'
## VIMMKTMPCMD="mktemp ${XDG_RUNTIME_DIR}/vimrc.XXXXXXXX.conf"
#
# local f
# local TMPBASHCONFIG=$(mktemp -p ${XDG_RUNTIME_DIR} -t bashrc.XXXXXXXX --suffix=.conf)
# local FILELIST=( "${MSC_BASE}/functions.sh" "${MSC_BASE}/logging" "${MSC_BASE}/myshell_load_fortmpconfig" $(getbashrcfile) ~/.aliases "${MSC_BASE}/aliases" "${MSC_BASE}/PS1" "${MSC_BASE}/bash_completion.d/*" )
#
# logdebug "FILELIST: ${FILELIST[@]}"
# if [ -e "${HOME}/.config/myshellconfig/sshs_addfiles.conf" ] ; then
# for f in $(cat "${HOME}/.config/myshellconfig/sshs_addfiles.conf");do
# [ -e "$f" ] && {\
# logdebug "add $f to FILELIST"; \
# FILELIST+=("$f"); }
# done
# fi
# logdebug "FILELIST1: ${FILELIST[@]}"
# local SSH_OPTS="-o VisualHostKey=no -o ControlMaster=auto -o ControlPersist=20s -o ControlPath=~/.ssh/master-%C"
# #local SSH_OPTS="-o VisualHostKey=no -o ControlMaster=yes -o ControlPersist=10s -o ControlPath=~/.ssh/ssh-%C"
# # Read /etc/bashrc or /etc/bash.bashrc (depending on distribution) and /etc/profile.d/*.sh first
2022-09-28 01:28:12 +02:00
# #ssh -T ${SSH_OPTS} $@ "pwd" >/dev/null 2>/dev/null || { logerr "Server $@ not reachable -> exit"; return 1; }
2022-05-19 14:22:38 +02:00
# cat << EOF >> "${TMPBASHCONFIG}"
#[ -e /etc/bashrc ] && BASHRC=/etc/bashrc
#[ -e /etc/bash.bashrc ] && BASHRC=/etc/bash.bashrc
#. \$BASHRC
#
#export USERNAME="${USERNAME}"
#export FULLNAME="${FULLNAME}"
#export USEREMAIL="${USEREMAIL}"
#export SCRIPT_LOG="\$(cat /proc/\$$/cmdline | xargs -0 echo|awk '{print \$3}' |sed 's/.conf$/.log/')"
#export LOGLEVEL_DEFAULT="${LOGLEVEL_DEFAULT}"
#export FILELOGLEVEL_DEFAULT="${FILELOGLEVEL_DEFAULT}"
#
#for i in /etc/profile.d/*.sh; do
# if [ -r "$i" ];then
# if [ "$PS1" ]; then
# . "$i"
# else
# . "$i" >/dev/null
# fi
# fi
#done
#unset i
#EOF
#
# for f in ${FILELIST[*]}; do
# if [ -e $f ]; then
# logdebug "add $f to tmpconfig"
# cat "$f" >> "${TMPBASHCONFIG}";
# fi
# done
#
# if [ $# -ge 1 ]; then
# if [ -e "${TMPBASHCONFIG}" ] ; then
# logdebug "create remote bashrc"
# logdebug "SSH_OPTS: $SSH_OPTS"
#
# sshcmd=$(cat << _remote_commands
#mktemp -p \${XDG_RUNTIME_DIR-~} -t bashrc.XXXXXXXX --suffix=.conf | tr -d '[:space:]'
#echo " "
#mktemp -p \${XDG_RUNTIME_DIR-~} -t vimrc.XXXXXXXX --suffix=.conf | tr -d '[:space:]'
#echo " "
#mktemp -p \${XDG_RUNTIME_DIR-~} -t tst.XXXXXXXX --suffix=.conf | tr -d '[:space:]'
#echo " "
#_remote_commands
#)
# local REMOTETMPCONFIGS=($(ssh -T ${SSH_OPTS} $@ "$sshcmd") )
## local REMOTETMPCONFIGS=($(ssh -T ${SSH_OPTS} $@ "mktemp -p \${XDG_RUNTIME_DIR-~} -t bashrc.XXXXXXXX --suffix=.conf" | tr -d '[:space:]' ) $(ssh -T ${SSH_OPTS} $@ "mktemp -p \${XDG_RUNTIME_DIR-~} -t vimrc.XXXXXXXX --suffix=.conf" | tr -d '[:space:]' ))
# logdebug remote tmp bashrc ${REMOTETMPCONFIGS[0]}
# logdebug remote tmp vimrc ${REMOTETMPCONFIGS[1]}
# #local REMOTETMPBASHCONFIG=$(ssh -T ${SSH_OPTS} $@ "mktemp -p \${XDG_RUNTIME_DIR-~} -t bashrc.XXXXXXXX --suffix=.conf" | tr -d '[:space:]' )
# #logdebug "REMOTETMPBASHCONFIG: $REMOTETMPBASHCONFIG"
## logdebug $(ssh -T ${SSH_OPTS} $@ "stat ${REMOTETMPBASHCONFIG}")
## logdebug $(ssh -T ${SSH_OPTS} $@ "hostnamectl")
# #logdebug "create remote vimrc"
# #local REMOTETMPVIMCONFIG=$(ssh -T ${SSH_OPTS} $@ "mktemp -p \${XDG_RUNTIME_DIR-~} -t vimrc.XXXXXXXX --suffix=.conf" | tr -d '[:space:]' )
# #logdebug "REMOTETMPVIMCONFIG: $REMOTETMPVIMCONFIG"
#
# # Add additional aliases to bashrc for remote-machine
# cat << EOF >> "${TMPBASHCONFIG}"
#alias vi='vim -u ${REMOTETMPCONFIGS[1]}'
#alias vim='vim -u ${REMOTETMPCONFIGS[1]}'
#alias vimdiff='vimdiff -u ${REMOTETMPCONFIGS[1]}'
#export LS_OPTIONS="${LS_OPTIONS}"
#export VIMRC="${REMOTETMPCONFIGS[1]}"
#export BASHRC="${REMOTETMPCONFIGS[0]}"
#title "\$USER@\$HOSTNAME: \$PWD"
#loginfo "This bash runs with temporary config from \$BASHRC"
#EOF
#
# logdebug "create fill remote bashrc"
# local TESTFILE=/tmp/bla
# cat << EOF3 > "${TESTFILE}"
#ich bin ein testfile
#zweite zeile
#EOF3
#
#ssh -T ${SSH_OPTs} $@ << _remote_cmd
#stat "${REMOTETMPCONFIGS[2]}"
#echo BLA
#cat <<- 'eof2' > ${REMOTETMPCONFIGS[2]}
#$(cat ${TMPBASHCONFIG})
#eof2
#echo BLA2
#_remote_cmd
#echo BLA3
# #ssh -T ${SSH_OPTS} $@ "cat > ${REMOTETMPBASHCONFIG}" < "${TMPBASHCONFIG}"
# #ssh -T ${SSH_OPTS} $@ "cat > ${REMOTETMPCONFIGS[0]}" < "${TMPBASHCONFIG}"
# # logtrace $(ssh -T ${SSH_OPTS} $@ "stat ${REMOTETMPBASHCONFIG}")
# logdebug "create file remote vimrc"
# #ssh -T ${SSH_OPTS} $@ "cat > ${REMOTETMPVIMCONFIG}" < "${MSC_BASE}/vimrc"
# ssh -T ${SSH_OPTS} $@ "cat > ${REMOTETMPCONFIGS[1]}" < "${MSC_BASE}/vimrc"
# local RCMD="/bin/bash --noprofile --norc -c "
# RCMD="
# trap \"rm -f ${REMOTETMPCONFIGS[0]} ${REMOTETMPCONFIGS[1]}\" EXIT " ;
# logdebug "run remote shell with temporary config"
# #ssh -t ${SSH_OPTS} $@ "$RCMD; SSHS=true bash -c \"function bash () { /bin/bash --rcfile ${REMOTETMPBASHCONFIG} -i ; } ; export -f bash; exec bash --rcfile ${REMOTETMPBASHCONFIG}\""
# ssh -t ${SSH_OPTS} $@ "$RCMD; SSHS=true bash -c \"function bash () { /bin/bash --rcfile ${REMOTETMPCONFIGS[0]} -i ; } ; export -f bash; exec bash --rcfile ${REMOTETMPCONFIGS[0]}\""
# rm "${TMPBASHCONFIG}"
# else
2022-09-14 14:43:45 +02:00
# logwarning "${TMPBASHCONFIG} does not exist. Using »ssh -t $@«"
2022-05-19 14:22:38 +02:00
# ssh -t "$@"
# fi
# else
2022-09-14 14:43:45 +02:00
# logwarning "too few arguments for sshs" >&2
2022-05-19 14:22:38 +02:00
# ssh
# fi
#
# EXIT
#}
2020-01-14 10:11:36 +01:00
2022-05-19 14:22:38 +02:00
[ -e ${ MSC_BASE } /sshs ] && source ${ MSC_BASE } /sshs
2020-02-17 20:03:22 +01:00
2022-06-27 02:39:41 +02:00
[ -z ${ VIMRC +x } ] && VIMRC = " ${ MSC_BASE } /vimrc "
2020-01-14 10:11:36 +01:00
svi ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
if [ -f ${ VIMRC } ] ; then
sudo vim -u " ${ VIMRC } " $@ ;
else
sudo vim $@
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
2020-10-30 01:12:54 +01:00
#vim-plugins-update () {
# ENTRY
# vim -c "PluginUpdate" -c ":qa!"
# EXIT
#
#}
#
#vim-plugins-install () {
# ENTRY
# vim -c "PluginInstall" -c ":qa!"
# EXIT
#
#}
2020-01-14 10:11:36 +01:00
vim-repair-vundle ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-12-10 09:31:38 +01:00
if [ -z ${ MSC_BASE +x } ] ; then
echo "MSC_BASE nicht gesetzt. Eventuell noch einmal ausloggen und wieder einloggen"
2020-01-14 10:11:36 +01:00
else
2020-12-10 09:31:38 +01:00
cd $MSC_BASE
2020-01-14 10:11:36 +01:00
cd vim/bundle
rm -rf Vundle.vim
2020-12-10 09:31:38 +01:00
echo git clone " ${ MSC_GIT_SUBMODULES_SERVER - $MSC_GIT_SUBMODULES_SERVER_DEFAULT } gmarik/Vundle.vim.git "
git clone " ${ MSC_GIT_SUBMODULES_SERVER - $MSC_GIT_SUBMODULES_SERVER_DEFAULT } gmarik/Vundle.vim.git "
2020-01-14 10:11:36 +01:00
cd ~-
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
getbashrcfile ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
if [ -z ${ BASHRC +x } ] ; then
2021-10-29 14:57:58 +02:00
loginfo "bash uses default"
2022-11-16 11:36:09 +01:00
return 1
2020-01-14 10:11:36 +01:00
else
cat /proc/$$ /cmdline | xargs -0 echo| awk '{print $3}'
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
catbashrcfile ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
if [ -z ${ BASHRC +x } ] ; then
2021-10-29 14:57:58 +02:00
loginfo "bash uses default"
2022-11-16 11:36:09 +01:00
return 1
2020-01-14 10:11:36 +01:00
else
#cat $(cat /proc/$$/cmdline | xargs -0 echo|awk '{print $3}')
cat $( getbashrcfile)
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
getvimrcfile ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
if [ -z ${ VIMRC +x } ] ; then
2020-04-23 22:23:40 +02:00
echo "vim uses default" >& 2
2020-01-14 10:11:36 +01:00
else
echo $VIMRC
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
catvimrcfile ( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
if [ -z ${ VIMRC +x } ] ; then
2020-04-23 22:23:40 +02:00
echo "vim uses default" >& 2
2020-01-14 10:11:36 +01:00
else
#cat $VIMRC
cat $( getvimrcfile)
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
# Functions to set the correct title of the terminal
function title( )
{
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
# change the title of the current window or tab
echo -ne " \033]0; $* \007 "
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
function sshx( )
{
/usr/bin/ssh " $@ "
# revert the window title after the ssh command
title $USER @$HOST
}
function su( )
{
/bin/su " $@ "
# revert the window title after the su command
title $USER @$HOST
}
function usage( )
{
cat << EOF
Keyboard-shortcuts:
# tmux:
C+Cursor tmux window change size
M+[ hjkl] tmux change splitted windows
# vim:
C+[ hjkl] vim change splitted windows
EOF
}
2021-09-20 08:49:25 +02:00
function update-hetzner-serverlist( )
2020-01-14 10:11:36 +01:00
{
2021-09-20 08:49:25 +02:00
for i in basic-services sc xe tu; do
curl -s -H " Authorization: Bearer $( pass show hetzner.com/projects/${ i } /api-token) " \
https://api.hetzner.cloud/v1/servers \
| /usr/bin/jq '.servers[].public_net.ipv4.ip' | sed -e 's/\"//g' \
| while read i; do
dig -x $i | awk '$0 !~ /^;/ && $4 == "PTR" {print $5}'
done | sed -s -e 's/\.$//' > ~/.dsh/group/hetzner-servers-${ i }
done
cat ~/.dsh/group/hetzner-servers-* > ~/.dsh/group/hetzner-servers
2020-01-14 10:11:36 +01:00
}
function tmuxx( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-01-14 10:11:36 +01:00
case $# in
1)
SESS = ( $( find ${ TMUX_SESSION_DIRS [*] } -mindepth 1 -name " $1 .session " 2>/dev/null ) )
; ;
*)
2022-09-14 14:43:45 +02:00
logwarning no session specified return
2020-01-14 10:11:36 +01:00
; ;
esac
2020-05-26 10:47:22 +02:00
TMUX_BIN = '/usr/bin/tmux'
$TMUX_BIN -f ~/.tmux.conf new-session -d
[ -e ${ SESS [0] } ] && $TMUX_BIN source-file ${ SESS [0] }
$TMUX_BIN attach-session -d
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
2020-02-05 12:03:32 +01:00
function checkbkp( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-02-05 11:57:10 +01:00
if ping -c 3 backup.vpn >/dev/null 2>& 1 ; then
local SSH = "/usr/bin/ssh"
2022-10-21 10:49:35 +02:00
local CMD = " $SSH -T root@backup.vpn "
2020-02-05 11:57:10 +01:00
$CMD /bin/bash << EOF
sudo find /srv/nfs/backup -mindepth 1 -maxdepth 1| grep -v -e " git $\|git-backup-repos " | while read i; do printf "%-30s%s\\n" "\$i" \$ ( ls \$ i| tail -n1) ; done | sort -k 2.1 -r
EOF
else
echo "backup.vpn is not reachable -> exit"
return 1
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-02-05 11:57:10 +01:00
}
2020-02-05 12:03:32 +01:00
function checkbkp-full( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-02-05 11:57:10 +01:00
if ping -c 3 backup.vpn >/dev/null 2>& 1 ; then
2020-01-14 10:11:36 +01:00
local SSH = "/usr/bin/ssh"
2022-10-21 10:49:35 +02:00
local CMD = " $SSH -T root@backup.vpn "
2020-01-14 10:11:36 +01:00
$CMD /bin/bash << EOF
2020-01-20 12:06:22 +01:00
sudo find /srv/nfs/backup -mindepth 1 -maxdepth 1| grep -v -e " git $\|git-backup-repos " | while read i; do printf "%-30s%s\\n" "\$i" \$ ( ls \$ i| tail -n1) ; done | sort -k 2.1 -r
2020-01-14 10:11:36 +01:00
EOF
2020-01-16 17:36:36 +01:00
which pdsh 1>/dev/null 2>& 1 && pdsh -g vpn sudo systemctl status backup.service
2020-01-14 10:11:36 +01:00
else
2022-09-14 14:43:45 +02:00
logwarning "backup.vpn is not reachable -> exit"
2020-01-14 10:11:36 +01:00
return 1
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-01-14 10:11:36 +01:00
}
2020-03-04 10:27:13 +01:00
turnoffbeep( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-03-04 11:45:14 +01:00
changebeep none
2020-09-22 01:42:10 +02:00
EXIT
2020-03-04 11:45:14 +01:00
}
changebeep( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-03-05 11:48:00 +01:00
local style
2020-03-04 11:45:14 +01:00
case $1 in
none)
2020-03-04 11:47:11 +01:00
style = none
2020-03-04 11:45:14 +01:00
; ;
visible)
style = visible
; ;
audible)
style = audible
; ;
*)
2022-09-14 14:43:45 +02:00
logwarning "usage: changebeep [none|visible|audible]"
2020-09-22 01:42:10 +02:00
EXIT
2020-03-04 11:45:14 +01:00
return 1
; ;
esac
2020-03-05 11:48:00 +01:00
local line = 'set bell-style'
local file = ~/.inputrc
2020-03-04 11:45:14 +01:00
if [ -e " ${ file } " ] ; then
sed -i -e " / $line /d " " ${ file } "
fi
echo " ${ line } ${ style } " >> " ${ file } "
return 0
2020-09-22 01:42:10 +02:00
EXIT
2020-03-04 10:27:13 +01:00
}
2020-03-04 11:23:44 +01:00
turnoffconfigsync( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-12-10 09:31:38 +01:00
local line = 'MSC_GIT_SYNC='
2020-03-05 11:48:00 +01:00
local file = ~/.bashrc
2020-03-04 11:45:14 +01:00
if [ -e " ${ file } " ] ; then
sed -i -e " / ${ line } /d " " ${ file } "
2020-03-04 11:23:44 +01:00
fi
2020-03-04 11:45:14 +01:00
sed -i -e " /#MYSHELLCONFIG-start/i ${ line } false " " ${ file } "
2020-09-22 01:42:10 +02:00
EXIT
2020-03-04 11:23:44 +01:00
}
turnonconfigsync( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-12-10 09:31:38 +01:00
local line = 'MSC_GIT_SYNC='
2020-03-05 11:48:00 +01:00
local file = ~/.bashrc
2020-03-04 11:45:14 +01:00
if [ -e " ${ file } " ] ; then
sed -i -e " / ${ line } /d " " ${ file } "
2020-03-04 11:23:44 +01:00
fi
2020-03-04 11:45:14 +01:00
sed -i " /#MYSHELLCONFIG-start/i ${ line } true " " ${ file } "
2020-09-22 01:42:10 +02:00
EXIT
2020-03-04 11:23:44 +01:00
}
2020-03-05 11:52:01 +01:00
function gnome-shell-extensions-enable-defaults( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-04-09 21:26:24 +02:00
local i
2020-03-05 11:52:01 +01:00
if [ -f ~/.config/gnome-shell-extensions-default.list ] ; then
for i in $( cat ~/.config/gnome-shell-extensions-default.list) ; do
#gnome-shell-extension-tool -e $i;
gnome-extensions enable $i ;
done ;
fi
2020-09-22 01:42:10 +02:00
EXIT
2020-03-05 11:52:01 +01:00
}
2020-12-09 15:56:05 +01:00
gnome-shell-extensions-make-actual-permanent( ) {
ENTRY
file = " ${ HOME } /.config/gnome-shell-extensions-default.list "
local EXTENSIONS = $( gsettings get org.gnome.shell enabled-extensions)
line = "[org/gnome/shell]"
for line in ${ EXTENSIONS [@] } ; do
loginfo " add $line to $file "
grep -xqF -- ${ line } ${ file } || echo $line >> $file
done
EXIT
}
2020-03-05 11:48:00 +01:00
gnome-shell-extensions-make-actual-permanent-systemwide( ) {
2020-09-22 01:42:10 +02:00
ENTRY
2020-03-05 11:48:00 +01:00
# https://people.gnome.org/~pmkovar/system-admin-guide/extensions-enable.html
# https://askubuntu.com/questions/359958/extensions-are-turned-off-after-reboot
local file = "/etc/dconf/profile/user"
2020-03-05 11:52:01 +01:00
sudo mkdir -p "/etc/dconf/profile/"
2020-03-05 11:48:00 +01:00
local line = 'user-db:user'
if [ -e " ${ file } " ] ; then
2021-09-20 08:49:25 +02:00
command = " grep -xqF -- ${ line } ${ file } || echo $line >> $file "
2020-09-22 01:42:10 +02:00
logtrace " $command "
2020-03-05 11:48:00 +01:00
sudo sh -c " $command "
fi
local line = 'system-db:local'
if [ -e " ${ file } " ] ; then
command = " grep -xqF -- ${ line } ${ file } || echo $line >> $file "
2021-09-20 08:49:25 +02:00
logtrace " $command "
2020-03-05 11:48:00 +01:00
sudo sh -c " $command "
fi
local line = 'enabled-extensions='
local file = '/etc/dconf/db/local.d/00-extensions'
2020-03-05 11:52:01 +01:00
sudo mkdir -p '/etc/dconf/db/local.d'
2020-03-05 11:48:00 +01:00
if [ -e " ${ file } " ] ; then
sudo sed -i -e " / ${ line } /d " " ${ file } "
2020-03-05 12:53:58 +01:00
#sudo sed -i -e "/\[org\/gnome\/shell\]/d" "${file}"
2020-03-05 11:48:00 +01:00
fi
local EXTENSIONS = $( gsettings get org.gnome.shell enabled-extensions)
2020-03-05 12:53:58 +01:00
line = "[org/gnome/shell]"
command = " grep -xqF -- ${ line } ${ file } || echo $line >> $file "
sudo sh -c " $command "
local line = 'enabled-extensions='
2020-09-22 01:42:10 +02:00
loginfo "Update or add extensions"
2020-03-05 12:53:58 +01:00
#echo "${line}${EXTENSIONS}" | sudo tee -a "${file}"
sudo sed -i " /\[org\/gnome\/shell\]/a ${ line } ${ EXTENSIONS } " " ${ file } "
sudo dconf update
2020-09-22 01:42:10 +02:00
EXIT
2020-03-05 11:48:00 +01:00
}
2020-04-22 01:08:40 +02:00
2020-04-27 15:45:19 +02:00
reachable-default ( ) {
2020-04-22 01:08:40 +02:00
local SERVER = $1
local PORT = ${ 2 :- 22 }
2020-09-11 09:47:52 +02:00
local res = 3
2020-10-19 14:35:07 +02:00
if which nc >/dev/null; then
if nc -w 2 -z $SERVER $PORT 2>/dev/null; then
res = 0
fi
else
res = 2
2020-04-22 01:08:40 +02:00
fi
2020-04-26 09:10:41 +02:00
return $res
}
2020-04-27 15:45:19 +02:00
reachable ( ) {
2020-09-22 01:28:29 +02:00
ENTRY
2020-09-11 09:47:52 +02:00
# returncodes:
# 1: servername not resolveable
2020-10-19 14:35:07 +02:00
# 2: command nc not found
2020-09-11 09:47:52 +02:00
# 3: server:port not reachable
# 999999: something went wrong
# 0: server was resolve- and reachable
2020-09-11 16:26:47 +02:00
GETENTHOSTS = ahosts
2020-04-26 09:10:41 +02:00
local SERVER = $1
2020-09-11 09:10:18 +02:00
# dig does not consult /etc/hosts, so use getent hosts instead
#local IP=$(dig +nocmd $SERVER a +noall +answer|tail -n 1 |awk '{print $5}')
2020-09-11 09:37:47 +02:00
# getent ahostsv4 returns only ipv4 addresses
2020-09-21 23:24:43 +02:00
loginfo -n " Try to resolve $SERVER : "
2020-09-11 16:26:47 +02:00
local IP = $( getent $GETENTHOSTS $SERVER | awk '$0 ~ /STREAM/ {print $1}' | uniq| head -n1)
2020-09-11 09:37:47 +02:00
if [ -z ${ IP -x } ] ; then
2022-09-14 14:43:45 +02:00
logwarning "not resolvable -> exit"
2020-09-11 09:37:47 +02:00
return 1
else
2020-10-06 14:32:25 +02:00
loginfo $IP
2020-09-11 09:37:47 +02:00
fi
2020-04-26 09:10:41 +02:00
local PORT = ${ 2 :- 22 }
2020-04-27 15:45:19 +02:00
local SEC = ${ 3 :- 1 }
2020-09-11 09:52:43 +02:00
local res = 999
2020-04-26 09:10:41 +02:00
local i
2020-09-21 23:24:43 +02:00
loginfo -n " Try to connect to ${ SERVER } ( ${ IP } ): ${ PORT } " >& 2
2020-04-27 15:45:19 +02:00
for i in $( seq 1 $SEC ) ; do
2021-04-28 09:14:20 +02:00
loginfo -n "." >& 2
2020-05-01 11:28:28 +02:00
if reachable-default ${ IP } ${ PORT } 2>/dev/null; then
2020-09-11 09:52:43 +02:00
res = 0
2020-04-26 09:10:41 +02:00
break
2020-09-11 09:47:52 +02:00
else
res = $?
2020-04-26 09:10:41 +02:00
fi
2020-04-27 15:45:19 +02:00
[ ${ SEC } -gt 1 -a $i -lt ${ SEC } ] && sleep 1
2020-04-26 09:10:41 +02:00
done
2020-10-06 14:32:25 +02:00
[ ${ res } -gt 0 ] && loginfo " not reachable" >& 2 || loginfo " success" >& 2;
2020-04-26 09:10:41 +02:00
2020-09-22 01:28:29 +02:00
EXIT
2020-04-26 09:10:41 +02:00
return $res
2020-04-22 01:08:40 +02:00
}
2020-07-10 12:34:50 +02:00
2020-08-13 22:29:39 +02:00
utoken ( ) {
2020-09-20 11:23:40 +02:00
2020-09-22 01:28:29 +02:00
ENTRY
2020-09-20 11:23:40 +02:00
ssh_identity = $1
2021-07-07 16:38:20 +02:00
[ -z " ${ P11M +x } " ] && { P11M = $PKCS11_MODULE ; export P11M; }
2020-09-21 12:39:58 +02:00
2020-09-20 11:23:40 +02:00
if [ -n " ${ ssh_identity +x } " ] ; then
agentfile = " ${ HOME } /.ssh/agents/agent- ${ ssh_identity } - $( hostname) "
if [ -e " $agentfile " ] ; then
local SSH_AUTH_SOCK
local SSH_AGENT_PID
2021-05-06 00:56:01 +02:00
/bin/sh -c " . $agentfile >/dev/null 2>/dev/null; ssh-add -l; ssh-add -e $P11M ; ssh-add -l "
2020-09-20 11:23:40 +02:00
fi
fi
2020-09-22 01:28:29 +02:00
EXIT
2020-08-13 22:29:39 +02:00
}
2020-09-20 11:23:40 +02:00
2020-09-22 09:47:15 +02:00
token( ) {
2020-07-10 12:34:50 +02:00
2021-07-07 17:03:12 +02:00
[ -z " ${ P11M : +x } " ] && { P11M = $PKCS11_MODULE ; export P11M; }
2020-09-22 09:47:15 +02:00
2021-12-02 12:06:26 +01:00
# If DISPLAY is set, ssh-add calls ssh-askpass, and if its in remote-terminal, it wont work
# So remember and unset DISPLAY, and set it at the end again, if it was set before
[ $DISPLAY ] && local DISPLAY_ORIG = $DISPLAY
2021-12-03 09:36:38 +01:00
[ $DISPLAY ] && logtrace " unset DISPLAY: $DISPLAY "
[ $DISPLAY ] && unset DISPLAY
2021-12-02 12:06:26 +01:00
2021-09-15 13:55:20 +02:00
# Write public keys of all in agent stored keys to a temporary file
2021-12-03 09:36:38 +01:00
local tmppubkey = " $( mktemp -p ${ XDG_RUNTIME_DIR } pubkey.XXXXXX.pub) "
logtrace " tmppubkey: $tmppubkey "
2021-07-07 17:03:12 +02:00
loginfo " $( ssh-add -L > $tmppubkey ) "
2021-09-15 13:55:20 +02:00
# Check if public-keys in tmppubkey are working. They are not working, if you removed and add back hardware-token.
2021-12-03 09:36:38 +01:00
loginfo " $( ssh-add -T ${ tmppubkey } || { ssh-add -e $P11M ; ssh-add -s $P11M ; } ) "
logdebug " $( rm " ${ tmppubkey } " ) "
logdebug " $( ssh-add -l ) "
[ $DISPLAY_ORIG ] && logtrace " reset DISPLAY= $DISPLAY_ORIG "
2021-12-02 12:06:26 +01:00
[ $DISPLAY_ORIG ] && export DISPLAY = $DISPLAY_ORIG
2020-09-20 11:23:40 +02:00
2020-07-10 12:34:50 +02:00
}
2020-09-26 07:29:38 +02:00
2020-09-16 08:55:31 +02:00
token-extract-pubkey( ) {
2021-05-06 00:56:01 +02:00
if pkcs11-tool --module $P11M --list-token-slots >& 2 ; then
2021-10-04 14:16:37 +02:00
ssh-keygen -i -m pkcs8 -f <( pkcs11-tool --module $P11M -r --type pubkey ${ 1 : +--label } ${ 1 } | openssl rsa -pubin -inform DER )
2020-09-16 11:25:27 +02:00
if [ $? -gt 0 ] ; then
2021-10-04 14:16:37 +02:00
token-list-objects >& 2
2020-09-16 11:25:27 +02:00
fi
else
2021-10-04 14:16:37 +02:00
echo "Please insert token. Exit" >& 2
2020-09-16 11:25:27 +02:00
return 1
fi
}
token-list-objects( ) {
2020-09-16 08:55:31 +02:00
case $1 in
--login| -l)
2021-05-06 00:56:01 +02:00
pkcs11-tool --module $P11M --login --list-objects
2020-09-16 08:55:31 +02:00
; ;
*)
2021-05-06 00:56:01 +02:00
pkcs11-tool --module $P11M --list-objects
2020-09-16 08:55:31 +02:00
; ;
esac
2020-09-16 11:25:27 +02:00
2020-09-16 08:55:31 +02:00
}
2020-09-20 11:23:40 +02:00
2020-09-21 12:39:58 +02:00
loadagent( ) {
2020-09-22 01:28:29 +02:00
ENTRY
2020-09-21 12:39:58 +02:00
local af
2020-09-24 13:05:26 +02:00
af = $( startagent --create-only $1 )
2020-09-22 09:08:16 +02:00
loginfo " Load agent from $af "
2020-09-26 07:29:38 +02:00
unset SSH_AUTH_SOCKET SSH_AGENT_PID
2021-10-29 14:57:58 +02:00
[ -n " ${ af +x } " ] && eval $( <$af )
2020-09-26 07:29:38 +02:00
logdebug " SSH_AUTH_SOCK: ${ SSH_AUTH_SOCK -not set } "
logdebug " SSH_AGENT_PID: ${ SSH_AGENT_PID -not set } "
loginfo " currently loaded keys in agent:
$( ssh-add -l) "
2020-09-22 12:13:19 +02:00
EXIT
2020-09-21 12:39:58 +02:00
}
2020-09-21 13:00:56 +02:00
2020-09-21 21:59:44 +02:00
setloglevel ( ) {
2020-09-22 01:28:29 +02:00
ENTRY
2020-09-21 21:52:34 +02:00
local loglevels
2020-09-22 09:12:19 +02:00
local oldloglevel = ${ LOGLEVEL - $LOGLEVEL_DEFAULT }
2020-09-21 21:52:34 +02:00
declare -a loglevels
loglevels = ( "ERROR" "WARN" "INFO" "DEBUG" "TRACE" )
2020-10-08 06:28:19 +02:00
if [ [ ${ loglevels [*] } = ~ " ${ 1 ^^ } " ] ] ; then
export LOGLEVEL = ${ 1 ^^ }
2020-09-21 21:52:34 +02:00
else
2022-09-28 01:28:12 +02:00
logerr "LOGLEVEL must be one of ERROR, WARN, INFO, DEBUG or TRACE"
2020-09-21 21:52:34 +02:00
fi
2022-09-28 01:28:12 +02:00
logerr " change LOGLEVEL from $oldloglevel -> $LOGLEVEL "
2020-09-22 01:28:29 +02:00
EXIT
2020-09-21 21:52:34 +02:00
}
2020-09-21 22:02:58 +02:00
setfileloglevel ( ) {
2020-09-22 01:28:29 +02:00
ENTRY
2020-09-21 22:02:58 +02:00
local loglevels
2020-09-22 09:12:19 +02:00
local oldloglevel = ${ FILELOGLEVEL - ${ FILELOGLEVEL_DEFAULT } }
2020-09-21 22:02:58 +02:00
declare -a loglevels
loglevels = ( "ERROR" "WARN" "INFO" "DEBUG" "TRACE" )
if [ [ ${ loglevels [*] } = ~ " $1 " ] ] ; then
export FILELOGLEVEL = $1
else
2022-09-28 01:28:12 +02:00
logerr "FILELOGLEVEL must be one of ERROR, WARN, INFO, DEBUG or TRACE"
2020-09-21 22:02:58 +02:00
fi
2022-09-28 01:28:12 +02:00
logerr " change FILELOGLEVEL from $oldloglevel -> $FILELOGLEVEL "
2020-09-22 01:28:29 +02:00
EXIT
2020-09-21 22:02:58 +02:00
}
2020-10-08 06:28:19 +02:00
getloglevels ( ) {
ENTRY
2020-10-08 06:32:44 +02:00
cat << EOF | tee -a $SCRIPT_LOG
2020-10-08 06:28:19 +02:00
LOGLEVEL: ${ LOGLEVEL - ${ LOGLEVEL_DEFAULT } }
FILELOGLEVEL: ${ FILELOGLEVEL - ${ FILELOGLEVEL_DEFAULT } }
change LOGLEVEL: \$ setloglevel [ ERROR| WARN| INFO| DEBUG| TRACE]
change FILELOGLEVEL: \$ setfileloglevel [ ERROR| WARN| INFO| DEBUG| TRACE]
EOF
}
2020-11-04 06:45:58 +01:00
rescan_scsi ( ) {
echo "- - -" > /sys/class/scsi_host/host0/scan
}
2020-12-05 19:01:17 +01:00
get_crtime( ) {
for target in " ${ @ } " ; do
inode = $( stat -c %i " ${ target } " )
fs = $( df --output= source " ${ target } " | tail -1)
crtime = $( sudo debugfs -R 'stat <' " ${ inode } " '>' " ${ fs } " 2>/dev/null |
grep -oP 'crtime.*--\s*\K.*' )
printf "%s\t%s\n" " ${ target } " " ${ crtime } "
done
}
2020-12-15 12:49:58 +01:00
2020-12-19 21:01:15 +01:00
is_btrfs_subvolume( ) {
2020-12-19 22:39:31 +01:00
sudo btrfs subvolume show " $1 " >/dev/null
2020-12-19 21:01:15 +01:00
}
2020-12-19 22:39:31 +01:00
convert_to_subvolume ( ) {
local XSUDO
local DIR
case $1 in
--sudo| -s)
XSUDO = sudo
shift
; ;
esac
DIR = " ${ 1 } "
[ -d " ${ DIR } " ] || return 1
is_btrfs_subvolume " ${ DIR } " && return 0
set -x
#btrfs subvolume create "${DIR}".new && \
${ XSUDO : +sudo } btrfs subvolume create " ${ DIR } .new " && \
2020-12-19 22:46:56 +01:00
/bin/cp -aTr --reflink= always " ${ DIR } " " ${ DIR } " .new && \
2020-12-19 22:39:31 +01:00
mv " ${ DIR } " " ${ DIR } " .orig && \
mv " ${ DIR } " .new " ${ DIR } " || return 2
set +x
return 0
2021-09-20 08:49:25 +02:00
2021-09-10 13:58:40 +02:00
}
cporig ( ) {
cp -b -i " ${ 1 } " " ${ 1 } .orig "
2020-12-19 22:39:31 +01:00
}
2021-10-19 10:27:12 +02:00
vgrename_full ( ) {
altevolumegroup = " $1 "
neuevolumegroup = " $2 "
vgrename ${ altevolumegroup } ${ neuevolumegroup }
sed -i " s/ ${ altevolumegroup } / ${ neuevolumegroup } /g " /etc/fstab
sed -i " s/ ${ altevolumegroup } / ${ neuevolumegroup } /g " /boot/grub/grub.cfg
sed -i " s/ ${ altevolumegroup } / ${ neuevolumegroup } /g " /boot/grub/menu.lst
sed -i " s/ ${ altevolumegroup } / ${ neuevolumegroup } /g " /etc/initramfs-tools/conf.d/resume
update-initramfs -c -k all
}
2021-10-19 11:49:51 +02:00
getfreeip ( ) {
local N = $1
sudo nmap -v -sn -n $1 -oG - | awk '/Status: Down/{print $2}'
}
getusedip ( ) {
local N = $1
local DNS = $2
sudo nmap -v -sn -n $1 -oG - | awk '!/Status: Down/{print $2}' | while read i; do
echo " $i : $( dig " ${ DNS : +@ } ${ DNS } " -x $i +short +search) "
done
}
2021-10-22 08:25:01 +02:00
function getdbcreds_jra ( ) {
2022-07-04 15:42:39 +02:00
local APP_INST = /opt/atlassian/jira
local JRA_HOME = $( awk -F "=" '/jira.home/ {gsub(/ /, "", $0); print $2}' " ${ APP_INST } /atlassian-jira/WEB-INF/classes/jira-application.properties " )
local DB_FILE = " ${ JRA_HOME } /dbconfig.xml "
2022-07-08 20:49:23 +02:00
if xmllint --version >/dev/null 2>& 1; then
2022-07-04 15:42:39 +02:00
DB_URL = " $( xmllint --xpath "jira-database-config/jdbc-datasource/url/text()" ${ DB_FILE } ) "
DB_USER = " $( xmllint --xpath "jira-database-config/jdbc-datasource/username/text()" ${ DB_FILE } ) "
DB_PWD = " $( xmllint --xpath "jira-database-config/jdbc-datasource/password/text()" ${ DB_FILE } ) "
else
echo "please install xmllint »apt install libxml2-utils«"
DB_URL = " $( grep -oPm1 "(?<=<url>)[^<]+" ${ DB_FILE } ) "
DB_USER = " $( grep -oPm1 "(?<=<username>)[^<]+" ${ DB_FILE } ) "
DB_PWD = " $( grep -oPm1 "(?<=<password>)[^<]+" ${ DB_FILE } ) "
fi
2021-10-22 08:25:01 +02:00
DB_HOST = " $( echo $DB_URL | sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\1@' ) "
DB_PORT = " $( echo $DB_URL | sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\2@' ) "
DB_NAME = " $( echo $DB_URL | sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\3@' ) "
return 0
}
function getdbcreds_cnf ( ) {
2022-07-08 20:49:23 +02:00
local APP_INST = /opt/atlassian/confluence
2022-07-26 18:17:45 +02:00
local CNF_HOME = $( awk -F "=" '/confluence.home/ {gsub(/ /, "", $0); print $2}' " ${ APP_INST } /confluence/WEB-INF/classes/confluence-init.properties " )
2022-07-04 15:42:39 +02:00
local DB_FILE = " ${ CNF_HOME } /confluence.cfg.xml "
2022-07-08 20:49:23 +02:00
if xmllint --version >/dev/null 2>& 1; then
2022-07-04 15:42:39 +02:00
DB_URL = " $( xmllint --xpath "confluence-configuration/properties/property[@name='hibernate.connection.url']/text()" ${ DB_FILE } ) "
DB_USER = " $( xmllint --xpath "confluence-configuration/properties/property[@name='hibernate.connection.username']/text()" ${ DB_FILE } ) "
DB_PWD = " $( xmllint --xpath "confluence-configuration/properties/property[@name='hibernate.connection.password']/text()" ${ DB_FILE } ) "
else
echo "please install xmllint »apt install libxml2-utils«"
DB_URL = " $( grep -oPm1 "(?<=<property name=\"hibernate.connection.url\">)[^<]+" ${ DB_FILE } ) "
DB_USER = " $( grep -oPm1 "(?<=<property name=\"hibernate.connection.username\">)[^<]+" ${ DB_FILE } ) "
DB_PWD = " $( grep -oPm1 "(?<=<property name=\"hibernate.connection.password\">)[^<]+" ${ DB_FILE } ) "
fi
2021-10-22 08:25:01 +02:00
DB_HOST = " $( echo $DB_URL | sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\1@' ) "
DB_PORT = " $( echo $DB_URL | sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\2@' ) "
DB_NAME = " $( echo $DB_URL | sed 's@^.*//@@;s@\(^.*\):\(.*\)/\(.*\)$@\3@' ) "
2022-06-08 18:33:53 +02:00
#cd -
2021-10-22 08:25:01 +02:00
return 0
}
2022-07-04 15:42:39 +02:00
2021-10-22 08:25:01 +02:00
function connectdb ( ) {
2022-07-26 18:17:45 +02:00
case $HOSTNAME in
*jra*| *jira*)
2021-11-11 08:32:27 +01:00
getdbcreds_jra $2
2021-10-22 08:25:01 +02:00
; ;
2022-07-26 18:17:45 +02:00
*cnf*| *confapp*)
2021-11-11 08:32:27 +01:00
getdbcreds_cnf $2
2021-10-22 08:25:01 +02:00
; ;
2022-07-26 18:17:45 +02:00
# case $1 in
# jra|jira)
# getdbcreds_jra $2
# ;;
# cnf|conf|confluence)
# getdbcreds_cnf $2
# ;;
2021-10-22 08:25:01 +02:00
*)
echo "wrong argument"
return 1
; ;
esac
2022-03-15 09:28:57 +01:00
cat << EOF
connect to ${ DB_HOST } :${ DB_PORT } /${ DB_NAME }
with user: ${ DB_USER }
and passwd: ${ DB_PWD }
EOF
2021-10-22 08:25:01 +02:00
PGPASSWORD = $DB_PWD psql -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME
}
2021-11-12 10:15:41 +01:00
urlencode( ) {
# urlencode <string>
local LANG = C
local length = " ${# 1 } "
for ( ( i = 0; i < length; i++ ) ) ; do
local c = " ${ 1 : i : 1 } "
case $c in
[ a-zA-Z0-9.~_-] ) printf " $c " ; ;
*) printf '%%%02X' " ' $c " ; ;
esac
done
}
urldecode( ) {
# urldecode <string>
local url_encoded = " ${ 1 //+/ } "
printf '%b' " ${ url_encoded //%/ \\ x } "
}
2022-06-08 18:33:53 +02:00
findlocallogins( ) {
last -F -a $( for i in $( find /var/log -maxdepth 1 -name "wtmp*" | sort -h) ; do echo -n " -f $i " ; done ) | grep -v "pts/\|reboot\|wtmp" | awk '{print $4,$5,$7}' | uniq
}
2022-07-04 15:27:49 +02:00
2022-07-08 20:49:23 +02:00
getjrahomes( ) {
2022-07-04 15:27:49 +02:00
local APP_INST = /opt/atlassian/jira
2022-07-08 20:49:23 +02:00
APP_HOME = $( awk -F "=" '/^jira.home/ {gsub(/ /, "", $0); print $2}' " ${ APP_INST } /atlassian-jira/WEB-INF/classes/jira-application.properties " )
[ -e " ${ APP_HOME } /cluster.properties " ] \
&& APP_SHARED_HOME = $( awk -F "=" '/^jira.shared.home/ {gsub(/ /, "", $0); print $2}' " ${ APP_HOME } /cluster.properties " )
}
getcnfhomes( ) {
xmllint --version >/dev/null 2>& 1 || { echo "please install xmllint »apt install libxml2-utils«" >& 2; return 1; }
local APP_INST = /opt/atlassian/confluence
APP_HOME = " $( awk -F "=" '/^confluence.home/ {gsub(/ /, "", $0); print $2}' " ${ APP_INST } /confluence/WEB-INF/classes/confluence-init.properties " ) "
[ -e " ${ APP_HOME } /confluence.cfg.xml " ] \
&& APP_SHARED_HOME = " $( xmllint --xpath "confluence-configuration/properties/property[@name='confluence.cluster.home']/text()" " ${ APP_HOME } /confluence.cfg.xml " 2>/dev/null) "
}
getatsvc( ) {
case $HOSTNAME in
*jra*| *jira*)
export SVC = jra;
export APP_NAME = jira
export APP_INST_NAME = atlassian-jira
export APP_LOG_DIR = log
getjrahomes
; ;
*cnf*| *confapp*)
export SVC = cnf;
export APP_NAME = confluence
export APP_INST_NAME = confluence
export APP_LOG_DIR = logs
getcnfhomes
; ;
esac
case ${ HOSTNAME } in
sl[ etp] *)
export PTE = ${ HOSTNAME : 2 : 1 }
; ;
esac
}
goathome( ) {
getatsvc
[ " ${ APP_HOME :- x } " = = "x" ] && { echo no $SVC home configured >& 2; return 127; }
cd " ${ APP_HOME } "
}
goatshome( ) {
getatsvc
[ " ${ APP_SHARED_HOME :- x } " = = "x" ] && { echo no $SVC home configured >& 2; return 127; }
cd " ${ APP_SHARED_HOME } "
}
gojrahome( ) {
getjrahomes
[ " ${ APP_HOME :- x } " = = "x" ] && { echo no jira home configured >& 2; return 127; }
cd " ${ APP_HOME } "
2022-07-04 15:27:49 +02:00
}
gojrashome( ) {
2022-07-08 20:49:23 +02:00
getjrahomes
[ " ${ APP_SHARED_HOME :- x } " = = "x" ] && { echo no jira shared-home configured >& 2; return 127; }
cd " ${ APP_SHARED_HOME } "
}
gocnfhome( ) {
getcnfhomes
[ " ${ APP_HOME :- x } " = = "x" ] && { echo no confluence home configured >& 2; return 127; }
cd " ${ APP_HOME } "
2022-07-04 15:27:49 +02:00
}
2022-07-08 20:49:23 +02:00
gocnfshome( ) {
getcnfhomes
[ " ${ APP_SHARED_HOME :- x } " = = "x" ] && { echo no confluence shared-home configured >& 2; return 127; }
cd " ${ APP_SHARED_HOME } "
}
2022-09-21 15:51:44 +02:00
setserver( ) {
export sshcon = " $@ "
if [ -n " ${ TMUX } " ] ; then
tmux set-environment sshcon " $@ "
fi
}
2022-11-15 23:52:51 +01:00
setgitremote( ) {
cd ~/.local/myshellconfig
git checkout master
2022-11-22 03:01:07 +01:00
git remote set-url origin https://git.schuerz.at/jakob/myshellconfig.git
git remote set-url origin --push git@git.schuerz.at:jakob/myshellconfig.git
2022-12-05 00:12:17 +01:00
loginfo "new remote set to"
git remote -v
2022-11-15 23:52:51 +01:00
git fetch -p
git merge FETCH_HEAD
git submodule sync
git submodule update --init --recursive
}
2020-09-26 07:29:38 +02:00
#EOF
2022-07-08 20:49:23 +02:00