#!/bin/bash set -e set -x INSTALL_VERSION=dist_release FILESYSTEM=btrfs USAGE=$(cat < ./amazon-ebs-autoscale/VERSION } function release() { # retrieve the version of amazon-ebs-autoscale from the latest upstream disbribution # release of aws-genomics-workflows if [[ ! $ARTIFACT_ROOT_URL ]]; then echo "missing required argument: --artifact-root-url" exit 1 fi if [[ "$ARTIFACT_ROOT_URL" =~ ^http.* ]]; then curl -LO $ARTIFACT_ROOT_URL/amazon-ebs-autoscale.tgz elif [[ "$ARTIFACT_ROOT_URL" =~ ^s3.* ]]; then aws s3 cp --no-progress $ARTIFACT_ROOT_URL/amazon-ebs-autoscale.tgz . else echo "unrecognized protocol in $ARTIFACT_ROOT_URL for release()" exit 1 fi tar -xzvf amazon-ebs-autoscale.tgz } function dist_release() { # retrieve the version of amazon-ebs-autoscale installed as an artifact with # the GWF Core stack. # recommended for a fully self-contained deployment if [[ ! $ARTIFACT_ROOT_URL ]]; then echo "missing required argument: --artifact-root-url" exit 1 fi if [[ "$ARTIFACT_ROOT_URL" =~ ^s3.* ]]; then aws s3 cp --no-progress $ARTIFACT_ROOT_URL/amazon-ebs-autoscale.tgz . else echo "unrecognized protocol in $ARTIFACT_ROOT_URL for dist_release()" exit 1 fi tar -xzvf amazon-ebs-autoscale.tgz } function install() { # this function expects the following environment variables # EBS_AUTOSCALE_FILESYSTEM local filesystem=${1:-btrfs} local docker_storage_driver=btrfs case $filesystem in btrfs) docker_storage_driver=$filesystem ;; lvm.ext4) docker_storage_driver=overlay2 ;; *) echo "Unsupported filesystem - $filesystem" exit 1 esac local docker_storage_options="DOCKER_STORAGE_OPTIONS=\"--storage-driver $docker_storage_driver\"" cp -au /var/lib/docker /var/lib/docker.bk rm -rf /var/lib/docker/* sh /opt/amazon-ebs-autoscale/install.sh -d /dev/xvdba -f $filesystem -m /var/lib/docker > /var/log/ebs-autoscale-install.log 2>&1 awk -v docker_storage_options="$docker_storage_options" \ '{ sub(/DOCKER_STORAGE_OPTIONS=.*/, docker_storage_options); print }' \ /etc/sysconfig/docker-storage \ > /opt/amazon-ebs-autoscale/docker-storage mv -f /opt/amazon-ebs-autoscale/docker-storage /etc/sysconfig/docker-storage cp -au /var/lib/docker.bk/* /var/lib/docker } cd /opt $INSTALL_VERSION install $FILESYSTEM