Skip to content

Instantly share code, notes, and snippets.

@marshyski
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshyski/92d00b3bb3551ca8d066 to your computer and use it in GitHub Desktop.
Save marshyski/92d00b3bb3551ca8d066 to your computer and use it in GitHub Desktop.
Build a SoftLayer RHEL Image
#!/bin/bash
BUILD_DATE=`date +"%d%b%Y"`
TIME=`date +"%H%M"`
BUILD_NAME="$1$BUILD_DATE"
KEY="ets-poc"
PEM_KEY="/home/timski/keyfile.pem"
APPDIR="/home/timski"
OS="REDHAT_LATEST_64"
if [[ $1 = "" ]]; then
echo "Enter a build name"
exit
fi
sl vs create -y --hostname=$1 --key=$KEY --domain=marshyski.com --cpu=1 --memory=1024 --hourly --os=$OS --datacenter=wdc01
sleep 5
echo ""
sl vs list | grep $1
echo ""
ID=`sl vs list --format=raw | grep $1 | awk '{ print $1 }'`
echo $ID
while true; do
if [[ `sl vs ready "$1" --wait=600` = READY ]]; then
break
sleep 5
fi
done
IP=`sl vs list --format=raw | grep $1 | awk '{ print $7 }' | head -n 1`
echo "$IP"
sleep 10
#SCP bootstrap suite and run remote commands
scp -o StrictHostKeyChecking=no -i $PEM_KEY -r $APPDIR/bootstrap/* root@$IP:
ssh -o StrictHostKeyChecking=no -i $PEM_KEY root@$IP -n "/root/mk-install"
ssh -o StrictHostKeyChecking=no -i $PEM_KEY root@$IP -n "/root/extras/install.sh"
ssh -o StrictHostKeyChecking=no -i $PEM_KEY root@$IP -n "/root/mk-clean"
sleep 5
sl vs capture -n $BUILD_NAME --all $ID --note="Support: marshyski@gmail.com date: $BUILD_DATE time: $BUILD_TIME"
sleep 155
sl vs cancel $ID -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment