view master/bin/hd_create.sh @ 35:1b6bcc54268d

what it says on the tin
author Henry S. Thompson <ht@markup.co.uk>
date Tue, 27 Nov 2018 19:08:08 +0000
parents
children 93de42761f9c
line wrap: on
line source

#!/bin/bash
# Create an HDInsight cluster, and initialise ssh access to the head
u="Usage: hd_create.sh [-c filename] HDname\nWhere name is the name of an HDInsight cluster to create\nSaves config in named file if -c is present and file is writeable\n"
set -e -o pipefail
if [ $# -eq 1 ]
then
 :
elif [ \( $# -eq 3 \) -a \( "$1" = "-c" \) -a \( ! -d "$2" \) ]
then
 if >> "$2" 2>/dev/null
 then
  save_conf=" | tee \"$2\""
  shift 2
 else  
  printf "$u" 1>&2
  exit 1
 fi
else
 printf "$u" 1>&2
 exit 2
fi
name="$1"
cmd="az hdinsight create -g cc -n $name -l southcentralus -s 4 -t hadoop -p CommonCrawl_hd1 -U cc --storage-account ccscsg.blob.core.windows.net --workernode-size Standard_D13_V2 --headnode-size Standard_D12_V2$save_conf"
echo "Starting creation of $name, will take 15 minutes or so..."
echo $cmd
# remove old host key, if any
ssh-keygen -R cchd1-ssh.azurehdinsight.net
ssh cchd1-ssh.azurehdinsight.net "cat >> .ssh/authorized_keys" < /home/cc/.ssh/id_rsa.pub