annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
1 #!/bin/bash
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
2 # Create an HDInsight cluster, and initialise ssh access to the head
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
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"
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
4 set -e -o pipefail
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
5 if [ $# -eq 1 ]
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
6 then
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
7 :
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
8 elif [ \( $# -eq 3 \) -a \( "$1" = "-c" \) -a \( ! -d "$2" \) ]
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
9 then
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
10 if >> "$2" 2>/dev/null
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
11 then
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
12 save_conf=" | tee \"$2\""
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
13 shift 2
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
14 else
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
15 printf "$u" 1>&2
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
16 exit 1
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
17 fi
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
18 else
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
19 printf "$u" 1>&2
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
20 exit 2
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
21 fi
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
22 name="$1"
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
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"
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
24 echo "Starting creation of $name, will take 15 minutes or so..."
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
25 echo $cmd
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
26 # remove old host key, if any
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
27 ssh-keygen -R cchd1-ssh.azurehdinsight.net
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
28 ssh cchd1-ssh.azurehdinsight.net "cat >> .ssh/authorized_keys" < /home/cc/.ssh/id_rsa.pub