Sha256: 953526f7ee8985951bc3cb914af48f11703dcfb8b9fbd364d1a95df6ff9c8691

Contents?: true

Size: 1.23 KB

Versions: 17

Compression:

Stored size: 1.23 KB

Contents

#!/bin/bash -eux

# Downloads and extract the scripts.
# The extracted folder from github looks like this:
#   branch-name.tar.gz => aws-ec2-branch-name
#   master.tar.gz => aws-ec2-master
#   v1.0.0.tar.gz => aws-ec2-1.0.0
function extract_aws_ec2_scripts() {
  local temp_folder
  local url
  local filename

  rm -rf /opt/aws-ec2   # clean start

  temp_folder="/opt/aws-ec2-temp"
  rm -rf "$temp_folder"
  mkdir -p "$temp_folder"

  (
    cd "$temp_folder"

  <%
    # Examples:
    #   AWS_EC2_CODE=v1.0.0
    #   AWS_EC2_CODE=master
    #   AWS_EC2_CODE=branch-name
    #
    #   https://github.com/tongueroo/aws-ec2/archive/v1.0.0.tar.gz
    #   https://github.com/tongueroo/aws-ec2/archive/master.tar.gz
    code_version = ENV['AWS_EC2_CODE']
    code_version ||= "v#{AwsEc2::VERSION}"
  %>
    url="https://github.com/tongueroo/aws-ec2/archive/<%= code_version %>.tar.gz"
    filename=$(basename "$url")
    folder="${filename%.tar.gz}" # remove extension
    folder="${folder#v}" # remove leading v character
    folder="aws-ec2-$folder" # IE: aws-ec2-1.0.0

    wget "$url"
    tar zxf "$filename"

    mv "$temp_folder/$folder/lib/aws_ec2/scripts" /opt/aws-ec2
    rm -rf "$temp_folder"
    chmod a+x -R /opt/aws-ec2
  )
}

extract_aws_ec2_scripts

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
aws-ec2-1.4.9 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.4.8 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.4.7 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.4.6 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.4.5 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.4.4 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.4.3 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.4.2 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.4.1 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.4.0 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.3.2 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.3.1 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.3.0 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.2.2 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.2.1 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.2.0 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh
aws-ec2-1.1.0 lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh