35
|
1 #!/bin/bash
|
|
2 # Create an HDInsight cluster, and initialise ssh access to the head
|
|
3 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"
|
|
4 set -e -o pipefail
|
|
5 if [ $# -eq 1 ]
|
|
6 then
|
|
7 :
|
|
8 elif [ \( $# -eq 3 \) -a \( "$1" = "-c" \) -a \( ! -d "$2" \) ]
|
|
9 then
|
|
10 if >> "$2" 2>/dev/null
|
|
11 then
|
|
12 save_conf=" | tee \"$2\""
|
|
13 shift 2
|
|
14 else
|
|
15 printf "$u" 1>&2
|
|
16 exit 1
|
|
17 fi
|
|
18 else
|
|
19 printf "$u" 1>&2
|
|
20 exit 2
|
|
21 fi
|
|
22 name="$1"
|
|
23 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"
|
|
24 echo "Starting creation of $name, will take 15 minutes or so..."
|
|
25 echo $cmd
|
|
26 # remove old host key, if any
|
|
27 ssh-keygen -R cchd1-ssh.azurehdinsight.net
|
|
28 ssh cchd1-ssh.azurehdinsight.net "cat >> .ssh/authorized_keys" < /home/cc/.ssh/id_rsa.pub
|