|
|
@ -2,25 +2,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CURDIR=$(dirname $(readlink "$0"))
|
|
|
|
CONFHOME="~/.local/share/jssh/conf.d"
|
|
|
|
CONFHOME="~/.local/share/jssh/conf.d"
|
|
|
|
CONFALLBACK="$(dirname $(readlink "$0"))/conf.d"
|
|
|
|
CONFALLBACK="$CURDIR/conf.d"
|
|
|
|
[[ -d $CONFHOME ]] && CONFDIR=$CONFHOME || CONFDIR=$CONFALLBACK
|
|
|
|
[[ -d $CONFHOME ]] && CONFDIR=$CONFHOME || CONFDIR=$CONFALLBACK
|
|
|
|
|
|
|
|
|
|
|
|
[[ -r $CONFDIR/bashrc ]] || { echo "Confdir or bashrc missing or lack of permissions!"; exit 1; }
|
|
|
|
[[ -r $CONFDIR/bashrc ]] || { echo "Confdir or bashrc missing or lack of permissions!"; exit 1; }
|
|
|
|
DSTDIR=/tmp/conf.d
|
|
|
|
DSTDIR=/tmp/conf.d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[ -f $CURDIR/sshrc.conf ]] && source $CURDIR/sshrc.conf
|
|
|
|
|
|
|
|
|
|
|
|
TARGET=$1
|
|
|
|
TARGET=$1
|
|
|
|
|
|
|
|
|
|
|
|
arc=$(tar czf - -C $CONFDIR $(find $CONFDIR -type f -printf "%f ")| base64 -w0)
|
|
|
|
arc=$(tar czf - -C $CONFDIR $(find $CONFDIR -type f -printf "%f ")| base64 -w0)
|
|
|
|
[[ $(echo $arc | wc -c) -le 65535 ]] || { echo "Files size too large!"; exit 1; }
|
|
|
|
[[ $(echo $arc | wc -c) -le 65535 ]] || { echo "Files size too large!"; exit 1; }
|
|
|
|
|
|
|
|
|
|
|
|
COMMANDS="
|
|
|
|
COMMANDS="
|
|
|
|
mkdir $'"$DSTDIR"';
|
|
|
|
export JSSHHOME=$'"$DSTDIR"';
|
|
|
|
echo $'"$arc"' | base64 -di | tar -xzf - -C $'"$DSTDIR"';
|
|
|
|
mkdir \$JSSHHOME;
|
|
|
|
trap \"rm -rf /tmp/conf.d; exit\" 0;
|
|
|
|
echo $'"$arc"' | base64 -di | tar -xzf - -C \$JSSHHOME;
|
|
|
|
bash --rcfile /tmp/conf.d/bashrc -i
|
|
|
|
trap \"rm -rf \$JSSHHOME; exit\" 0;
|
|
|
|
|
|
|
|
bash --rcfile \$JSSHHOME/bashrc -i
|
|
|
|
"
|
|
|
|
"
|
|
|
|
sshrc() {
|
|
|
|
|
|
|
|
ssh -t $TARGET $COMMANDS
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sshrc $@
|
|
|
|
ssh -t $@ $COMMANDS
|
|
|
|