4
# inject.pl injects an executable or perl script into an image, then modifies the startup
5
# of that image such that the executable or perl script will start automatically when
8
# (c)2011, Eucalyptus Systems, Inc. All Rights Reserved.
16
die "Usage: inject.pl image_file executable_file";
19
my $image_file = shift;
20
my $executable_file = shift;
25
cmd("losetup /dev/loop6 $image_file");
26
cmd("mount /dev/loop6 /mnt/image");
27
cmd("cp $executable_file /mnt/image/etc/init.d");
28
chmod(755, "/mnt/image/etc/init.d/$executable_file");
29
cmd("chroot /mnt/image ln -s /usr/bin/$executable_file /etc/rc3.d/S99$executable_file");
30
cmd("umount /dev/loop6");
31
cmd("losetup -d /dev/loop6");
36
print "Running command:$_[0]:";
37
my $return_code = (system($_[0])/256);
38
if ($return_code==0) {