summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2014-10-08 15:49:37 +0200
committerDaniil Baturin <daniil@baturin.org>2014-10-08 15:49:37 +0200
commiteab58c6977285c7c7c1e262e79853a101dd4e07e (patch)
tree1584bf1ebac7b821fc328d555c56676b962357a6 /scripts
parent5c67f85f698b763ccae4a086ca7d185800eac60a (diff)
downloadvyatta-cfg-system-eab58c6977285c7c7c1e262e79853a101dd4e07e.tar.gz
vyatta-cfg-system-eab58c6977285c7c7c1e262e79853a101dd4e07e.zip
Add ex2-check script.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ec2-check.pl40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/ec2-check.pl b/scripts/ec2-check.pl
new file mode 100755
index 00000000..03448ff5
--- /dev/null
+++ b/scripts/ec2-check.pl
@@ -0,0 +1,40 @@
+#!/usr/bin/env perl
+# **** License ****
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# This code was originally developed by VyOS Development Group
+# All Rights Reserved.
+#
+# Author: Daniil Baturin <daniil@baturin.org>
+# Description: Check if we are running on an EC2 instance.
+# If both system UUID and system serial number start with "EC2",
+# most likely we are.
+#
+# **** End License ****
+
+
+use strict;
+use warnings;
+
+my $DMIDECODE = "/usr/sbin/dmidecode";
+
+my $UUID = `$DMIDECODE -s system-uuid`;
+my $SN = `$DMIDECODE -s system-serial-number`;
+
+if( ($UUID =~ /^ec2.*/i) &&
+ ($SN =~ /^ec2.*/i) )
+{
+ exit(0);
+}
+else
+{
+ exit(1);
+}
+