Creating and Retrieving New StackScript

When you set up your Akamai Linode Cloud profile on ScaleGrid, you’ll need to set up a new stackscript and link it to your profile.

Step 1: Create New StackScript

In the side bar on your Akamai Linode console, find the StackScript section.

Then click on the button Create StackScript in the top right corner.

You will now see the following page:

We are now going to fill out these fields as follows:

  • StackScript Label: Can be anything of your choosing
  • Description: Can be anything of your choosing
  • Target Images: Select Centos7
  • Script: Enter the following content:
#!/bin/bash 
# <UDF name="SCRIPT_URL" Label="Fetch this script and execute it"/>
exec > /var/log/sg-stackscript.log
exec 2>&1   
set -x
os_version=""
if [ -f /etc/os-release ]; then
  os_version=$(cat /etc/os-release | tr -dc '0-9'|cut -c 1)
elif [ -f /etc/redhat-release ]; then
  os_version=$(cat /etc/redhat-release | tr -dc '0-9.'|cut -d \. -f1)
else
  os_version=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f1)
fi
# Update CENTOS 7 repo to use vault mirror
if [ "$os_version" -eq "7" ]; then
  sed -i 's/mirrorlist.centos.org/vault.centos.org/' /etc/yum.repos.d/CentOS-Base.repo
  sed -i 's/mirror.centos.org/vault.centos.org/' /etc/yum.repos.d/CentOS-Base.repo
  sed -i 's/mirrors.linode.com/vault.centos.org/' /etc/yum.repos.d/CentOS-Base.repo
  sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/CentOS-Base.repo
  sed -i 's/^#baseurl/baseurl/' /etc/yum.repos.d/CentOS-Base.repo
fi
yumcount=1
while [ $yumcount -le 20 ]
do
    echo "*** stackscript - yum install try $yumcount ***"
    command -v wget >/dev/null 2>&1 || yum install -y wget
    if [ $? -eq 0 ]; then
        break
    fi
    yumcount=$(( $yumcount + 1 ))
    sleep 2
done
command -v dos2unix >/dev/null 2>&1 || yum install -y dos2unix || exit 1
cd ${HOME}
SCRIPT=`echo "$SCRIPT_URL" | cut  -d/ -f5 | cut -d? -f1`
rm -f ${SCRIPT}
echo "Copying ${SCRIPT_URL} to ${HOME}"
wget --tries=5 ${SCRIPT_URL} -O ${SCRIPT} && /usr/bin/dos2unix ${SCRIPT} && . ${SCRIPT}
cd ${HOME} && rm -f ${SCRIPT}

Once you have done this, click the Create StackScript button at the bottom of the page.

Step 2: Getting the StackScript ID

Go back to the StackScripts page in the Linode console and find the script you just created. After clicking on it, you can find the StackScript ID near the top of the page:

Copy this ID, you will need this ID to complete your Akamai Linode cloud profile setup with ScaleGrid.