-
Notifications
You must be signed in to change notification settings - Fork 10
/
sshrc
executable file
·60 lines (54 loc) · 1.65 KB
/
sshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
ANYRC_ENV='ssh'
init() {
SSH_CMD="${ANYRC_SSH_CMD:-ssh}"
SSH_OPTS=''
while [[ -n "$1" ]]; do
case "$1" in
--ssh_cmd )
SSH_CMD="$2"
shift ;;
-b | -c | -D | -E | -e | -F | -I | -i | -J | -L | -l | -m | -O | -o | -p | -Q | -R | -S | -W | -w )
SSH_OPTS="${SSH_OPTS} $1 $2"; shift ;;
-* )
SSH_OPTS="${SSH_OPTS} $1" ;;
* )
if [ -z "${SSH_REMOTE:+_}" ]; then
SSH_REMOTE="$1"
fi; ;;
esac
shift
done
if [ -z "${SSH_REMOTE:+_}" ]; then
${SSH_CMD} ${SSH_OPTS}; exit 1;
fi
}
mk_tmp_dir() {
:
}
transfer() {
:
}
connect() {
local CMD_DIR="$(abs_dirname $0)"
${SSH_CMD} -t "${SSH_REMOTE}" ${SSH_OPTS} "\
export DANYRC_NAME=\"${DANYRC_NAME}\"
export DANYRCD_NAME=\"${DANYRCD_NAME}\"
export ANYRC_ROOT=\"\$(mktemp -d /tmp/anyrc.XXXXXX)\"
export ANYRC_DANYRC=\"\${ANYRC_ROOT}/\${DANYRC_NAME}\"
export ANYRC_DANYRCD=\"\${ANYRC_ROOT}/\${DANYRCD_NAME}\"
export ANYRC_HOME=\"\${ANYRC_DANYRCD}\"
export PATH=\"\${ANYRC_ROOT}:\${PATH}\"
trap \"rm -rf \${ANYRC_ROOT}; exit\" 0
mkdir -p \${ANYRC_DANYRCD}
echo '"$(cat "${ANYRC_DANYRC}" | base64)"' | tr -s ' ' '\n' | base64 -d > \${ANYRC_DANYRC}
echo '"$(tar czf - -h -C ${CMD_DIR} ${ANYRC_CMD} ${ANYRC_CMDS[@]} | base64)"' | tr -s ' ' $'\n' | base64 -d | tar mxzf - -C \${ANYRC_ROOT}
echo '"$(tar czf - -h -C ${DANYRCD_DIR} ${DANYRCD_BASE} | base64)"' | tr -s ' ' '\n' | base64 -d | tar mxzf - -C \${ANYRC_ROOT}
source \${ANYRC_DANYRC}
if [ \"\${SHELL##*/}\" = 'bash' ]; then
bash --rcfile \${ANYRC_DANYRC};
else
\${SHELL};
fi"
}
source anyrc