-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-ec2-initialize
executable file
·47 lines (32 loc) · 1.01 KB
/
make-ec2-initialize
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
#!/usr/bin/perl
=begin
Generate an initialization file using the specified auth file
and stated requirements.
The resulting file can be run as a user-data script or manually.
=cut
use strict;
my $authkey = slurp(shift @ARGV);
my $runmode = shift @ARGV;
my %vars = (MODE => $runmode, AUTH => $authkey, PACKAGES => slurp('requirements.txt'));
# How many processor scripts to run concurrently?
# Increase this value if your EC2 instances are larger than c1.xlarge
# or you use real hardware
$vars{CONCURRENCY} = 1;
$vars{DO_NOT_EDIT_WARNING} = <<EOS;
# DO NOT EDIT -- GENERATED FILE
# Edit $0 and associated files instead and see the Makefile on how to re-generate this script.
# This script initializes an Amazon EC2 instance
# for use as a text extraction worker node.
EOS
my $template = slurp('ec2-initialize.txt');
while (my ($k, $v) = each %vars) {
$v =~ s/\s+$//;
$template =~ s/%${k}%/$v/;
}
print $template;
sub slurp {
my $f = shift;
local $/;
open(F, $f) or die "cannot open $f. $!\n";
<F>
}