reduce ssh-commands for sshs to 2
This commit is contained in:
parent
b4eb14cf17
commit
44d671e5a3
2 changed files with 28 additions and 50 deletions
|
@ -509,7 +509,7 @@ EOF
|
||||||
|
|
||||||
[ -e ${MSC_BASE}/sshs ] && source ${MSC_BASE}/sshs
|
[ -e ${MSC_BASE}/sshs ] && source ${MSC_BASE}/sshs
|
||||||
|
|
||||||
VIMRC="${MSC_BASE}/vimrc"
|
[ -z ${VIMRC+x} ] &&VIMRC="${MSC_BASE}/vimrc"
|
||||||
|
|
||||||
svi () {
|
svi () {
|
||||||
ENTRY
|
ENTRY
|
||||||
|
|
76
sshs
76
sshs
|
@ -36,6 +36,14 @@ export SCRIPT_LOG="\$(cat /proc/\$$/cmdline | xargs -0 echo|awk '{print \$3}' |s
|
||||||
export LOGLEVEL_DEFAULT="${LOGLEVEL_DEFAULT}"
|
export LOGLEVEL_DEFAULT="${LOGLEVEL_DEFAULT}"
|
||||||
export FILELOGLEVEL_DEFAULT="${FILELOGLEVEL_DEFAULT}"
|
export FILELOGLEVEL_DEFAULT="${FILELOGLEVEL_DEFAULT}"
|
||||||
|
|
||||||
|
trap "rm -f \${bashrctmp} \${vimrctmp} \${SCRIPT_LOG}" EXIT
|
||||||
|
alias vi='vim -u \${vimrctmp}'
|
||||||
|
alias vim='vim -u \${vimrctmp}'
|
||||||
|
alias vimdiff='vimdiff -u \${vimrctmp}'
|
||||||
|
export LS_OPTIONS="${LS_OPTIONS}"
|
||||||
|
export VIMRC="\${vimrctmp}"
|
||||||
|
export BASHRC="\${bashrctmp}"
|
||||||
|
|
||||||
for i in /etc/profile.d/*.sh; do
|
for i in /etc/profile.d/*.sh; do
|
||||||
if [ -r "$i" ];then
|
if [ -r "$i" ];then
|
||||||
if [ "$PS1" ]; then
|
if [ "$PS1" ]; then
|
||||||
|
@ -61,61 +69,31 @@ EOF
|
||||||
logdebug "SSH_OPTS: $SSH_OPTS"
|
logdebug "SSH_OPTS: $SSH_OPTS"
|
||||||
|
|
||||||
local sshcmd=$(cat << _remote_commands
|
local sshcmd=$(cat << _remote_commands
|
||||||
mktemp -p \${XDG_RUNTIME_DIR-~} -t bashrc.XXXXXXXX --suffix=.conf | tr -d '[:space:]'
|
#!/bin/bash
|
||||||
echo " "
|
bashrctmp=\$(mktemp -p \${XDG_RUNTIME_DIR-~} -t bashrc.XXXXXXXX --suffix=.conf | tr -d '[:space:]')
|
||||||
mktemp -p \${XDG_RUNTIME_DIR-~} -t vimrc.XXXXXXXX --suffix=.conf | tr -d '[:space:]'
|
vimrctmp=\$(mktemp -p \${XDG_RUNTIME_DIR-~} -t vimrc.XXXXXXXX --suffix=.conf | tr -d '[:space:]')
|
||||||
echo " "
|
echo "\$bashrctmp \$vimrctmp"
|
||||||
_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
|
echo "bashrctmp=\${bashrctmp}" > \${bashrctmp}
|
||||||
cat << EOF >> "${TMPBASHCONFIG}"
|
echo "vimrctmp=\${vimrctmp}" >> \${bashrctmp}
|
||||||
alias vi='vim -u ${REMOTETMPCONFIGS[1]}'
|
|
||||||
alias vim='vim -u ${REMOTETMPCONFIGS[1]}'
|
cat <<- 'eof' >> \$bashrctmp
|
||||||
alias vimdiff='vimdiff -u ${REMOTETMPCONFIGS[1]}'
|
$(cat ${TMPBASHCONFIG})
|
||||||
export LS_OPTIONS="${LS_OPTIONS}"
|
|
||||||
export VIMRC="${REMOTETMPCONFIGS[1]}"
|
|
||||||
export BASHRC="${REMOTETMPCONFIGS[0]}"
|
|
||||||
title "\$USER@\$HOSTNAME: \$PWD"
|
title "\$USER@\$HOSTNAME: \$PWD"
|
||||||
loginfo "This bash runs with temporary config from \$BASHRC"
|
loginfo "This bash runs with temporary config from \$BASHRC"
|
||||||
EOF
|
eof
|
||||||
|
|
||||||
logdebug "create fill remote bashrc"
|
cat <<- 'eof3' > \${vimrctmp}
|
||||||
|
|
||||||
ssh -T ${SSH_OPTs} $@ << _remote_cmd
|
|
||||||
cat <<- 'eof2' > ${REMOTETMPCONFIGS[0]}
|
|
||||||
$(cat ${TMPBASHCONFIG})
|
|
||||||
eof2
|
|
||||||
cat <<- 'eof3' > ${REMOTETMPCONFIGS[1]}
|
|
||||||
$(cat ${MSC_BASE}/vimrc)
|
$(cat ${MSC_BASE}/vimrc)
|
||||||
eof3
|
eof3
|
||||||
_remote_cmd
|
_remote_commands
|
||||||
#echo BLA3
|
)
|
||||||
#ssh -T ${SSH_OPTS} $@ "cat > ${REMOTETMPBASHCONFIG}" < "${TMPBASHCONFIG}"
|
|
||||||
#ssh -T ${SSH_OPTS} $@ "cat > ${REMOTETMPCONFIGS[0]}" < "${TMPBASHCONFIG}"
|
local REMOTETMPCONFIGS=($(ssh -T ${SSH_OPTS} $@ "$sshcmd") )
|
||||||
# logtrace $(ssh -T ${SSH_OPTS} $@ "stat ${REMOTETMPBASHCONFIG}")
|
logdebug remote tmp bashrc ${REMOTETMPCONFIGS[0]}
|
||||||
logdebug "create file remote vimrc"
|
logdebug remote tmp vimrc ${REMOTETMPCONFIGS[1]}
|
||||||
#ssh -T ${SSH_OPTS} $@ "cat > ${REMOTETMPVIMCONFIG}" < "${MSC_BASE}/vimrc"
|
ssh -t ${SSH_OPTS} $@ "SSHS=true exec bash --rcfile ${REMOTETMPCONFIGS[0]} -i "
|
||||||
#ssh -T ${SSH_OPTS} $@ "cat > ${REMOTETMPCONFIGS[1]}" < "${MSC_BASE}/vimrc"
|
rm "${TMPBASHCONFIG}"
|
||||||
#local RCMD="/bin/bash --noprofile --norc -c "
|
|
||||||
RCMD="
|
|
||||||
trap \"rm -f ${REMOTETMPCONFIGS[0]} ${REMOTETMPCONFIGS[1]} ${SCRIPT_LOG}\" 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 --noprofile --norc -c \"function bash () { /bin/bash --rcfile ${REMOTETMPCONFIGS[0]} -i ; } ; export -f bash; exec bash --rcfile ${REMOTETMPCONFIGS[0]}\""
|
|
||||||
ssh -t ${SSH_OPTS} $@ "$RCMD; SSHS=true exec bash --rcfile ${REMOTETMPCONFIGS[0]} -i "
|
|
||||||
rm "${TMPBASHCONFIG}"
|
|
||||||
else
|
else
|
||||||
logwarn "${TMPBASHCONFIG} does not exist. Using »ssh -t $@«"
|
logwarn "${TMPBASHCONFIG} does not exist. Using »ssh -t $@«"
|
||||||
ssh -t "$@"
|
ssh -t "$@"
|
||||||
|
|
Loading…
Reference in a new issue