Make EIC scripts compatible with macOS #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
#33
Description of changes:
Remove system UUID check as it is specific for Linux and Windows instances. Mac instances don't have the EC2 prefix on their UUID. A platform independent way of checking if the machine is indeed is an EC2 Instance is by Inspecting the instance identity document (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html#inspect-document), already used by the script on a latter step. It's important to notice I did not implement the signature verification of the document as I considered it would be overkill.
Change canonical paths of
grep
,mktemp
,sed
, andtouch
from/bin
to/usr/bin
. This change is also compatible with Linux.Change canonical paths of
test
/usr/binto
/bin`. This change is also compatible with Linux.Use
/tmp
instead of/dev/shm
, available on both Linux and macOS.Change regular expressions to make them compatible with macOS versions of
find
andsed
. New expressions are still compatible with Linux.When running on macOS, generate a CA bundle with
security find-certificate
and set is asca_path
instead of using/etc/ssl/certs
.Extract
sha256sum
anddate -ud
to functions that handle each operation in specific ways for Linux and macOS.Use existing
sha256
function when calculating hashes.Rewrite sed expressions to be compatible with BSD and GNU versions of sed.
Replace
timeout 5
with& /bin/sleep 5; /bin/kill -KILL $! 2> /dev/null || :
(http://blog.mediatribe.net/en/node/72/index.html) as macOS doesn't have it available. This can also be used on Linux.Replace
grep -oP
withsed -En
to getaccountId
from JSON, using the same expression used to getAccessKeyId
,SecretAccessKey
, andToken
from JSON.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.