annotate master/bin/hd_create.sh @ 67:13182e98a1ab

use sorted insertion into tuple list for properties
author Henry S. Thompson <ht@markup.co.uk>
date Thu, 04 Jun 2020 17:58:10 +0000
parents 8ce6a81e2bb4
children
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
37
93de42761f9c parameterise name
Henry S. Thompson <ht@markup.co.uk>
parents: 35
diff changeset
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
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
37
93de42761f9c parameterise name
Henry S. Thompson <ht@markup.co.uk>
parents: 35
diff changeset
22 name=cc"$1"
93de42761f9c parameterise name
Henry S. Thompson <ht@markup.co.uk>
parents: 35
diff changeset
23 pwd=CommonCrawl_"$1"
35
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..."
56
8ce6a81e2bb4 remove -s 4
Henry S. Thompson <ht@markup.co.uk>
parents: 37
diff changeset
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
93de42761f9c parameterise name
Henry S. Thompson <ht@markup.co.uk>
parents: 35
diff changeset
26 bash -c "$cmd$save_conf"
35
1b6bcc54268d what it says on the tin
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
27 # remove old host key, if any
37
93de42761f9c parameterise name
Henry S. Thompson <ht@markup.co.uk>
parents: 35
diff changeset
28 ssh-keygen -R $name-ssh.azurehdinsight.net
93de42761f9c parameterise name
Henry S. Thompson <ht@markup.co.uk>
parents: 35
diff changeset
29 # let us in w/o password after this
93de42761f9c parameterise name
Henry S. Thompson <ht@markup.co.uk>
parents: 35
diff changeset
30 ssh $name-ssh.azurehdinsight.net "cat >> .ssh/authorized_keys" < /home/cc/.ssh/id_rsa.pub