add variables for git to sudo

This commit is contained in:
Jakobus Schürz 2020-07-06 10:28:14 +02:00
parent dff3f173ea
commit ca3302a528

35
functions.sh Normal file → Executable file
View file

@ -13,7 +13,15 @@ cpb() {
sudo() { sudo() {
local SUDO local SUDO
SUDO=$( if [ -e /bin/sudo ]; then echo /bin/sudo; else echo /usr/bin/sudo; fi ) SUDO=$( if [ -e /bin/sudo ]; then echo /bin/sudo; else echo /usr/bin/sudo; fi )
$SUDO TMUX=$TMUX SSHS=$SSHS SSH_TTY=$SSH_TTY "$@" $SUDO \
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" \
SSH_TTY="$SSH_TTY" \
"$@"
} }
create_symlinks() { create_symlinks() {
@ -590,6 +598,31 @@ reachable-default () {
return $res return $res
} }
reachableim () {
local SERVER=$1
local IP=$(dig +nocmd $SERVER a +noall +answer|tail -n 1 |awk '{print $5}')
local PORT=${2:-22}
local SEC=${3:-1}
local res=1
local i
echo -n "Try to connect to ${SERVER}:${PORT} " >&2
for i in $(seq 1 $SEC); do
echo -n "." >&2
if reachable-default ${IP} ${PORT} 2>/dev/null; then
res=0
break
fi
[ ${SEC} -gt 1 -a $i -lt ${SEC} ] && sleep 1
done
[ ${res} -gt 0 ] && echo " not reachable" >&2 || echo " success" >&2
return $res
}
#EOF
reachable () { reachable () {
local SERVER=$1 local SERVER=$1
local IP=$(dig +nocmd $SERVER a +noall +answer|tail -n 1 |awk '{print $5}') local IP=$(dig +nocmd $SERVER a +noall +answer|tail -n 1 |awk '{print $5}')