-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ssh.z-run
74 lines (64 loc) · 2.02 KB
/
ssh.z-run
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
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/dev/null
<< ssh / launch / simple
test "${#}" -ge 1
_target="${1}"
shift -- 1
"${ZRUN}" ':: ssh / sync' "${_target}"
exec -- "${ZRUN}" ssh "${_target}" ':: ssh / remote / main' "${@}"
!!
<< ssh / launch / extended
test "${#}" -ge 1
_target="${1}"
shift -- 1
"${ZRUN}" ':: ssh / sync' "${_target}"
export __TEST="${RANDOM}"
exec -- "${ZRUN}" --ssh --ssh-target="${_target}" --ssh-export=__TEST ':: ssh / remote / main' "${@}"
!!
--<< ssh / sync
test "${#}" -eq 1
_target="${1}"
shift -- 1
exec -- rsync -i -- "${ZRUN}" "${_target}":~/.bin/z-run
!!
--<< ssh / remote / main
printf -- '[ii] main:\n' >&2
printf -- '[ii] host: `%s`\n' "$( exec -- hostname )" >&2
printf -- '[ii] cwd: `%s`\n' "$( exec -- readlink -e -- . )" >&2
printf -- '[ii] arguments count: %d\n' "${#}" >&2
printf -- '[ii] test: `%s`\n' "${__TEST:-__none__}"
for _argument in "${@}" ; do
printf -- '[ii] argument: `%s`\n' "${_argument}" >&2
done
while read -r -d '' -- _environment ; do
printf -- '[ii] environment: `%s`\n' "${_environment}" >&2
done < /proc/self/environ
while read -r -- _output ; do
printf -- '[ii] lsof: `%s`\n' "${_output}" >&2
done < <( exec -- lsof -p "${$}" 2>/dev/null )
if false ; then
cd -- "${HOME}"
"${ZRUN}" ':: ssh / remote / delegate'
fi
_index=0
while test "${_index}" -lt 60 ; do
_index="$(( $_index + 1 ))"
printf '.' >&2
sleep -- 6s
done
!!
<< ssh / remote / delegate
printf -- '[ii] delegate:\n' >&2
printf -- '[ii] host: `%s`\n' "$( exec -- hostname )" >&2
printf -- '[ii] cwd: `%s`\n' "$( exec -- readlink -e -- . )" >&2
printf -- '[ii] arguments count: %d\n' "${#}" >&2
printf -- '[ii] test: `%s`\n' "${__TEST:-__none__}"
for _argument in "${@}" ; do
printf -- '[ii] argument: `%s`\n' "${_argument}" >&2
done
while read -r -d '' -- _environment ; do
printf -- '[ii] environment: `%s`\n' "${_environment}" >&2
done < /proc/self/environ
while read -r -- _output ; do
printf -- '[ii] lsof: `%s`\n' "${_output}" >&2
done < <( exec -- lsof -p "${$}" 2>/dev/null )
!!