forked from koding/koding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli
More file actions
executable file
·61 lines (48 loc) · 1023 Bytes
/
Copy pathcli
File metadata and controls
executable file
·61 lines (48 loc) · 1023 Bytes
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
#!/bin/bash
cd $(dirname $0)
ENVIRONMENT=koding-$1
COMMAND=$2
COMMAND_OPTIONS=${@:3}
USER=ec2-user
HOSTS=$(./get-instance-addresses --environment $ENVIRONMENT)
if [ -z "$HOSTS" ]; then
echo 'error: no hosts found'
exit 1
fi
PSSH_PROGRAM=$(which pssh || which parallel-ssh)
BROWSER=$()
function run_i2cssh() {
MACHINES=$(echo $HOSTS | tr ' ' ',')
i2cssh --login $USER --machines $MACHINES $COMMAND_OPTIONS
}
function pssh_host_option() {
for HOST in $HOSTS; do
echo -n "--host $HOST "
done
}
function run_pssh() {
if [ -z $PSSH_PROGRAM ]; then
echo 'error: pssh not found'
exit 1
fi
$PSSH_PROGRAM --inline --user $USER $(pssh_host_option) $COMMAND_OPTIONS
}
function run_browse() {
PATH=${COMMAND_OPTIONS[0]}
for HOST in $HOSTS; do
URL=http://$HOST/$PATH
echo $URL
done
}
case $COMMAND in
i2cssh)
run_i2cssh
;;
pssh)
run_pssh
;;
browse)
run_browse
;;
esac
exit 0