You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
685 B
Bash

3 years ago
#!/usr/bin/env bash
set -eu
CONFHOME="~/.local/share/jssh/conf.d"
CONFALLBACK="$(dirname $(readlink "$0"))/conf.d"
[[ -d $CONFHOME ]] && CONFDIR=$CONFHOME || CONFDIR=$CONFALLBACK
[[ -r $CONFDIR/bashrc ]] || { echo "Confdir or bashrc missing or lack of permissions!"; exit 1; }
DSTDIR=/tmp/conf.d
TARGET=$1
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; }
3 years ago
COMMANDS="
mkdir $'"$DSTDIR"';
echo $'"$arc"' | base64 -di | tar -xzf - -C $'"$DSTDIR"';
trap \"rm -rf /tmp/conf.d; exit\" 0;
bash --rcfile /tmp/conf.d/bashrc -i
"
sshrc() {
ssh -t $TARGET $COMMANDS
}
3 years ago
sshrc $@