reduce ssh-commands for sshs to 2
This commit is contained in:
parent
77fbe1af58
commit
c8c6922b1f
2 changed files with 28 additions and 50 deletions
|
@ -509,7 +509,7 @@ EOF
|
|||
|
||||
[ -e ${MSC_BASE}/sshs ] && source ${MSC_BASE}/sshs
|
||||
|
||||
VIMRC="${MSC_BASE}/vimrc"
|
||||
[ -z ${VIMRC+x} ] &&VIMRC="${MSC_BASE}/vimrc"
|
||||
|
||||
svi () {
|
||||
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 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
|
||||
if [ -r "$i" ];then
|
||||
if [ "$PS1" ]; then
|
||||
|
@ -61,61 +69,31 @@ EOF
|
|||
logdebug "SSH_OPTS: $SSH_OPTS"
|
||||
|
||||
local 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 " "
|
||||
_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"
|
||||
#!/bin/bash
|
||||
bashrctmp=\$(mktemp -p \${XDG_RUNTIME_DIR-~} -t bashrc.XXXXXXXX --suffix=.conf | tr -d '[:space:]')
|
||||
vimrctmp=\$(mktemp -p \${XDG_RUNTIME_DIR-~} -t vimrc.XXXXXXXX --suffix=.conf | tr -d '[:space:]')
|
||||
echo "\$bashrctmp \$vimrctmp"
|
||||
|
||||
# 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]}"
|
||||
echo "bashrctmp=\${bashrctmp}" > \${bashrctmp}
|
||||
echo "vimrctmp=\${vimrctmp}" >> \${bashrctmp}
|
||||
|
||||
cat <<- 'eof' >> \$bashrctmp
|
||||
$(cat ${TMPBASHCONFIG})
|
||||
title "\$USER@\$HOSTNAME: \$PWD"
|
||||
loginfo "This bash runs with temporary config from \$BASHRC"
|
||||
EOF
|
||||
eof
|
||||
|
||||
logdebug "create fill remote bashrc"
|
||||
|
||||
ssh -T ${SSH_OPTs} $@ << _remote_cmd
|
||||
cat <<- 'eof2' > ${REMOTETMPCONFIGS[0]}
|
||||
$(cat ${TMPBASHCONFIG})
|
||||
eof2
|
||||
cat <<- 'eof3' > ${REMOTETMPCONFIGS[1]}
|
||||
cat <<- 'eof3' > \${vimrctmp}
|
||||
$(cat ${MSC_BASE}/vimrc)
|
||||
eof3
|
||||
_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]} ${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}"
|
||||
_remote_commands
|
||||
)
|
||||
|
||||
local REMOTETMPCONFIGS=($(ssh -T ${SSH_OPTS} $@ "$sshcmd") )
|
||||
logdebug remote tmp bashrc ${REMOTETMPCONFIGS[0]}
|
||||
logdebug remote tmp vimrc ${REMOTETMPCONFIGS[1]}
|
||||
ssh -t ${SSH_OPTS} $@ "SSHS=true exec bash --rcfile ${REMOTETMPCONFIGS[0]} -i "
|
||||
rm "${TMPBASHCONFIG}"
|
||||
else
|
||||
logwarn "${TMPBASHCONFIG} does not exist. Using »ssh -t $@«"
|
||||
ssh -t "$@"
|
||||
|
|
Loading…
Reference in a new issue