annotate master/bin/internal/invoke.sh @ 30:9275e2a8b5e2

hacking to get id into wbash.sh, maybe buggy?
author Henry S. Thompson <ht@markup.co.uk>
date Mon, 19 Nov 2018 18:32:30 +0000
parents 2fbefb8d1a9e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
1 #!/bin/bash
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
2 # Helper for ../wrun, q.v.
30
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
3 # Usage: invoke.sh [-d] [-w] [-x] me cmd ifile id port ip [args...]
7
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
4 # Runs
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
5 # cmd [id] args...
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
6 # via ssh to ip:port
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
7 # If ifile is not /dev/null, feed in as stdin
30
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
8 # If -d, echo command line to stderr
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
9 # If -w, wrap command in nohup and wait for result
7
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
10 # Unless -x, worker id is passed as first arg
30
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
11 echo $@ 1>&2
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
12 echo "$@" 1>&2
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
13 if [ "$1" = "-d" ]
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
14 then
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
15 shift
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
16 debug=1
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
17 fi
9
55e953e5c66f wrun.sh, invoke.sh:
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
18 if [ "$1" = "-w" ]
55e953e5c66f wrun.sh, invoke.sh:
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
19 then
55e953e5c66f wrun.sh, invoke.sh:
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
20 shift
55e953e5c66f wrun.sh, invoke.sh:
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
21 wait=1
55e953e5c66f wrun.sh, invoke.sh:
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
22 fi
7
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
23 if [ "$1" = "-x" ]
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
24 then
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
25 shift
30
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
26 tellid=
7
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
27 me=
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
28 else
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
29 me=$1
30
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
30 tellid=$4
7
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
31 fi
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
32 cmd="$2"
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
33 ifile=$3
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
34 port=$5
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
35 ip=$6
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
36 shift 6
30
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
37 echo "#$(date)#$cmd#$ifile#$tellid#$port#$ip#$@#" 1>&2
7
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
38 if [ "$ifile" != "/dev/null" ]
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
39 then
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
40 echo "# from $ifile" 1>&2
9
55e953e5c66f wrun.sh, invoke.sh:
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
41 scp -P $port $ifile $ip:ifile.txt
55e953e5c66f wrun.sh, invoke.sh:
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
42 fi || echo scp failed, status=$? 1>&2
55e953e5c66f wrun.sh, invoke.sh:
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
43 if [ "$wait" ]
55e953e5c66f wrun.sh, invoke.sh:
Henry S. Thompson <ht@markup.co.uk>
parents: 7
diff changeset
44 then
30
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
45 cs="nohup $cmd $tellid $me "$@" > nohup.cc"
7
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
46 else
30
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
47 cs="$cmd $tellid $me ""$@"
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
48 fi
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
49 if [ "$debug" ]
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
50 then
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
51 echo ssh -tt -p $port $ip $cs 1>&2
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
52 fi
9275e2a8b5e2 hacking to get id into wbash.sh, maybe buggy?
Henry S. Thompson <ht@markup.co.uk>
parents: 10
diff changeset
53 ssh -tt -p $port $ip "$cs" || echo ssh failed, status=$? 1>&2
7
a7637c994964 cull_network.py, parse_load_balance.py, vmss_setup.sh x 2, vmss_create.sh:
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
54 echo "#$(date)#$id#" 1>&2