35
|
1 #!/bin/bash
|
|
2 # Create an HDInsight cluster, and initialise ssh access to the head
|
37
|
3 u="Usage: hd_create.sh [-c filename] HDname\nWhere name will be prefixed with 'cc' to form\nthe name of an HDInsight cluster to create, and with 'CommonCrawl_' to give its password\nSaves config in named file if -c is present and file is writeable\n"
|
35
|
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
|
37
|
22 name=cc"$1"
|
|
23 pwd=CommonCrawl_"$1"
|
35
|
24 echo "Starting creation of $name, will take 15 minutes or so..."
|
56
|
25 cmd="az hdinsight create -g cc -n $name -l southcentralus -t hadoop -p $pwd -U cc --storage-account ccscsg.blob.core.windows.net --workernode-size Standard_D13_V2 --headnode-size Standard_D12_V2"
|
37
|
26 bash -c "$cmd$save_conf"
|
35
|
27 # remove old host key, if any
|
37
|
28 ssh-keygen -R $name-ssh.azurehdinsight.net
|
|
29 # let us in w/o password after this
|
|
30 ssh $name-ssh.azurehdinsight.net "cat >> .ssh/authorized_keys" < /home/cc/.ssh/id_rsa.pub
|