First-boot Script Examples

To modify the default cluster node images provided by Aspera, enter a first-boot script into the Firstboot Script field when launching a node. For more information on first-boot scripts, see Customizing Cluster Nodes Using the Custom First-boot Scripts.

For examples of common first-boot scripts, see the examples below.

Print a Test Message

The following script prints a test message to check that the first-boot scripts are running:

#!/bin/bash

echo "Cluster Manager first-boot scripts are running."

Remove the Region Check from your S3 Bucket

Modify the default properties of the trapd service and remove the region check for your S3 bucket. This is mostly discouraged, but it can be useful if you are downloading data from public S3 buckets, where you are not permitted to verify the region of the bucket through the API. The following script can modifies the properties of trapd:

#!/bin/bash

sed -i 's/#aspera.session.check-bucket.transfer=true/aspera.session.check-bucket.transfer=false/' /opt/aspera/etc/trapd/s3.properties

Create Node API User

Create a Node API User (xfer2) that can be used to monitor your clusters using IBM Aspera Console. Use the following first-boot script (replacing node_api_password with the desired password) when launching a new cluster:
#!/bin/bash

echo "/opt/aspera/bin/asnodeadmin -a -u xfer2 -x root -p node_api_password --acl-set impersonation" >> /opt/aspera/atcm/bin/configure-node-users.sh
Note: For more information about the Node API User in Console, see the IBM Aspera Console Admin Guide.

Enable Object Symlinking

If you want to take advantage of the Aspera Object Symlink feature, you need to enable it in the system-wide configuration. The following script can enable this feature.
#!/bin/bash
        
sed -i 's/#aspera.session.support.symlink = false/aspera.session.support.symlink = true/' /opt/aspera/etc/trapd/s3.properties 

Automatically Tag New Elastic Block Store (EBS) Volumes

The following script automatically tags EBS volumes created by cluster nodes. Replace the values for tag_name and tag_value.
#!/bin/bash
        
Key=tag_name
Value=tag_value
Region=$(curl -sS http://169.254.169.254/2014-11-05/dynamic/instance-identity/document/ | jq --raw-output '.region')
Instance=$(curl -sS http://169.254.169.254/latest/meta-data/instance-id)
Volume=$(aws ec2 describe-instances --instance-ids $Instance --region $Region | jq --raw-output '.Reservations[].Instances[].BlockDeviceMappings[].Ebs.VolumeId')

aws ec2 create-tags --resources $Volume --tags Key=$Key,Value=$Value --region $Region

Creating a New Default System User to Use with Access Keys

The cluster connects to cloud storage using access keys, which provide a more secure and flexible alternative to authenticating with the Aspera node user or system user. For more information about access keys, see Access Key Overview.

Aspera recommends creating a new system user to use with all access keys. To create this system user, use the first-boot script and replace username with the desired name of your default user:

#!/bin/bash

SYSTEM_USER=username

function createUser() {
  local user=$1
  groupadd -f aspusers
  adduser -s /bin/aspshell -G aspusers ${user}
  pushd /home/${user}
    mkdir -p .ssh
    cp -f /opt/aspera/var/aspera_id_dsa.pub .ssh/authorized_keys
    chown -R ${user}:${user} .ssh/
    chmod 755 .ssh/
    chmod 644 .ssh/authorized_keys
  popd
}

createUser "$SYSTEM_USER"

echo "
/opt/aspera/bin/asnodeadmin -d -u \"\$3\"
/opt/aspera/bin/asnodeadmin -a -u \"\$3\" -x \"$SYSTEM_USER\" -p \"\$4\"" >> /opt/aspera/atcm/bin/configure-node-users.sh