comparison master/bin/hd_create.sh @ 37:93de42761f9c

parameterise name
author Henry S. Thompson <ht@markup.co.uk>
date Thu, 29 Nov 2018 13:51:43 +0000
parents 1b6bcc54268d
children 8ce6a81e2bb4
comparison
equal deleted inserted replaced
36:9d4f130073b8 37:93de42761f9c
1 #!/bin/bash 1 #!/bin/bash
2 # Create an HDInsight cluster, and initialise ssh access to the head 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" 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"
4 set -e -o pipefail 4 set -e -o pipefail
5 if [ $# -eq 1 ] 5 if [ $# -eq 1 ]
6 then 6 then
7 : 7 :
8 elif [ \( $# -eq 3 \) -a \( "$1" = "-c" \) -a \( ! -d "$2" \) ] 8 elif [ \( $# -eq 3 \) -a \( "$1" = "-c" \) -a \( ! -d "$2" \) ]
17 fi 17 fi
18 else 18 else
19 printf "$u" 1>&2 19 printf "$u" 1>&2
20 exit 2 20 exit 2
21 fi 21 fi
22 name="$1" 22 name=cc"$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" 23 pwd=CommonCrawl_"$1"
24 echo "Starting creation of $name, will take 15 minutes or so..." 24 echo "Starting creation of $name, will take 15 minutes or so..."
25 echo $cmd 25 cmd="az hdinsight create -g cc -n $name -l southcentralus -s 4 -t hadoop -p $pwd -U cc --storage-account ccscsg.blob.core.windows.net --workernode-size Standard_D13_V2 --headnode-size Standard_D12_V2"
26 bash -c "$cmd$save_conf"
26 # remove old host key, if any 27 # remove old host key, if any
27 ssh-keygen -R cchd1-ssh.azurehdinsight.net 28 ssh-keygen -R $name-ssh.azurehdinsight.net
28 ssh cchd1-ssh.azurehdinsight.net "cat >> .ssh/authorized_keys" < /home/cc/.ssh/id_rsa.pub 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