<commit_before>#!/usr/bin/env bash
set -e
set -x 

#
# verify Amazon auth codes are available
#
[[ -z 'AWS_ACCESS_KEY_ID' ]] && { echo 'Missing $AWS_ACCESS_KEY_ID variable'; exit 1; }
[[ -z 'AWS_SECRET_ACCESS_KEY' ]] && { echo 'Missing $AWS_SECRET_KEY variable'; exit 1; }

mkdir -p $HOME/bin
cat <<EOF >> $HOME/.bash_profile
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
EOF

#
# mount instance storage
#
if [[ $X_TYPE == r3.* && $X_DEVICE && $X_MOUNT ]]; then
sudo mkfs.ext4 -E nodiscard $X_DEVICE
sudo mkdir -p $X_MOUNT
sudo mount -o discard $X_DEVICE $X_MOUNT
sudo chown -R ec2-user:ec2-user $X_MOUNT
sudo chmod 775 $X_MOUNT
# set nextflow scratch path to the mounted storage
export NXF_TEMP=$X_MOUNT
echo "export NXF_TEMP=$X_MOUNT" >> $HOME/.bash_profile
fi

#
# Update docker
#
if [[ $DOCKER_VERSION ]]; then
sudo service docker stop
sudo wget https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION} -q -O /usr/bin/docker
sudo chmod +x /usr/bin/docker
sudo service docker start
fi<commit_msg>Added instance name tagging [ci skip]<commit_after>#!/usr/bin/env bash
set -e
set -x 

#
# verify Amazon auth codes are available
#
[[ -z 'AWS_ACCESS_KEY_ID' ]] && { echo 'Missing $AWS_ACCESS_KEY_ID variable'; exit 1; }
[[ -z 'AWS_SECRET_ACCESS_KEY' ]] && { echo 'Missing $AWS_SECRET_KEY variable'; exit 1; }

mkdir -p $HOME/bin
cat <<EOF >> $HOME/.bash_profile
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
EOF

#
# set instance name
#
instance="$(curl -s http://169.254.169.254/latest/meta-data/instance-id)"
zone="$(curl -s 169.254.169.254/latest/meta-data/placement/availability-zone)"
region="${zone::-1}"
aws ec2 --region "$region" create-tags --resources "$instance" --tags "Key=Name,Value=$NXF_ROLE"

#
# mount instance storage
#
if [[ $X_TYPE == r3.* && $X_DEVICE && $X_MOUNT ]]; then
sudo mkfs.ext4 -E nodiscard $X_DEVICE
sudo mkdir -p $X_MOUNT
sudo mount -o discard $X_DEVICE $X_MOUNT
sudo chown -R ec2-user:ec2-user $X_MOUNT
sudo chmod 775 $X_MOUNT
# set nextflow scratch path to the mounted storage
export NXF_TEMP=$X_MOUNT
echo "export NXF_TEMP=$X_MOUNT" >> $HOME/.bash_profile
fi

#
# Update docker
#
if [[ $DOCKER_VERSION ]]; then
sudo service docker stop
sudo wget https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION} -q -O /usr/bin/docker
sudo chmod +x /usr/bin/docker
# see https://github.com/docker/docker/issues/18113
sudo rm -rf /var/lib/docker/network/files/local-kv.db
sudo service docker start
fi
{'fraction_non_alphanumeric': 0.1394344069128044, 'fraction_numerical': 0.022388059701492536, 'mean_word_length': 4.723595505617977, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6136663', 'n_tokens_mistral': 1066, 'n_tokens_neox': 979, 'n_words': 251}