From 27f88ef5a1a9fad1dd7e21f800acfbb0e5202411 Mon Sep 17 00:00:00 2001 From: Dave Stern Date: Wed, 10 Apr 2013 15:06:05 -0400 Subject: [PATCH] Region Copy: Modified prerequisite_check for conditional usage --- ec2-automate-backup/Beta/ec2-automate-backup.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ec2-automate-backup/Beta/ec2-automate-backup.sh b/ec2-automate-backup/Beta/ec2-automate-backup.sh index 9e4f589..33d1721 100755 --- a/ec2-automate-backup/Beta/ec2-automate-backup.sh +++ b/ec2-automate-backup/Beta/ec2-automate-backup.sh @@ -7,7 +7,14 @@ #confirms that executables required for succesful script execution are available prerequisite_check() { - for prerequisite in basename ec2-create-snapshot ec2-create-tags ec2-describe-snapshots ec2-delete-snapshot date + check_values=$1 + + if [[ -z $check_values ]] + then + check_values='ec2-create-snapshot ec2-create-tags ec2-describe-snapshots ec2-delete-snapshot date' + fi + + for prerequisite in basename $check_values do #use of "hash" chosen as it is a shell builtin and will add programs to hash table, possibly speeding execution. Use of type also considered - open to suggestions. hash $prerequisite &> /dev/null @@ -292,6 +299,7 @@ fi #if region_copy_destinations is true, then run region_copy_EBS_Snapshots function if [[ -n $region_copy_destinations ]] then echo "Snapshot Copying to regions $region_copy_destinations is Starting Now." + prerequisite_check ec2-copy-snapshot region_copy_EBS_Snapshots fi