This file is indexed.

/usr/bin/ec2_remove_workers is in coop-computing-tools 4.0-1ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 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
74
75
76
77
78
79
80
81
82
#!/bin/bash

show_help() 
{
        echo "Use: ec2_remove_workers [options] <num_workers>"
        echo "where options are:"
        echo "  -a                      Remove all running workers (EC2 instances)."
        echo "  -i <image_id>           EC2 OS image ID of running workers. Default = ami-fa01f193."
        echo "  -r <reservation_id>     Restrict removed instances to this reservation ID."
        echo "  -h                      Show this help message."
        exit 1
}

remove_all=0
image=ami-fa01f193
reservation=

while getopts i:r:ah opt 
do
        case "$opt" in
                a)  remove_all=1;;
                i)  image="$OPTARG";;
                r)  reservation="$OPTARG";;
		h)  show_help;;
                \?) show_help;;
        esac
done

shift $(expr $OPTIND - 1)

if [ $remove_all = 0 ]; then
    if [ X$1 = X ]
    then
        show_help
    fi
    count=$1
fi

ec2remove=`which ec2kill 2>/dev/null`
if [ $? != 0 ]
then
        echo "$0: please add 'ec2kill' to your PATH."
        exit 1
fi

if [ $reservation ] 
then
	running_instances=$(ec2-describe-instances -F "reservation-id"=$reservation | grep running | wc -l)
else
	running_instances=$(ec2-describe-instances -F "image-id"=$image | grep running | wc -l)
fi

if [ ! -n "$running_instances" ];
then
	echo "No workers to remove."
	exit 1
fi

if [ $remove_all = 1 ]; 
then
	num_remove_instances=$running_instances
else
	num_remove_instances=$count
fi

for (( i=1; i<=$num_remove_instances; i++ ))
do
	if [ $reservation ]
	then
		instance=$(ec2-describe-instances -F "reservation-id"=$reservation | grep running | awk 'NR==1{print $2}')
	else
		instance=$(ec2-describe-instances -F "image-id"=$image | grep running | awk 'NR==1{print $2}')
	fi

	if [ -n "$instance" ]; 
	then
       	$ec2remove $instance
		return_status=$?
	fi
done

exit $return_status