/redeploy.sh

raw link view readme
1
2 if [ -z "$1" ]; then
3 echo "usage: create.sh type resource_group"
4 exit 1
5 fi
6
7 if [ -z "$2" ]; then
8 echo "usage: create.sh type resource_group"
9 exit 1
10 fi
11
12 if [ ! -z "$3" ]; then
13 SSH_KEY_PATH=~/.ssh/id_rsa.pub
14 echo testing for $SSH_KEY_PATH
15 if [ -f "$SSH_KEY_PATH" ]; then
16 SSH_KEY=`cat "$SSH_KEY_PATH"`
17 USERNAME=$3
18 fi
19 fi
20
21 TYPE=$1
22 RESOURCE_GROUP=$2
23
24 if [ -z "$SSH_KEY" ] ; then
25 if [ ! -f "$TYPE/azuredeploy-parameters.json" ]; then
26 echo "$TYPE/azuredeploy-parameters.json missing"
27 exit 1
28 fi
29 fi
30
31 EXISTS_COUNT=`az group list --query "[?name=='$RESOURCE_GROUP']" | wc -l`
32 if [ $EXISTS_COUNT -eq 1 ] ; then
33 echo "$RESOURCE_GROUP does not exist; use create.sh"
34 exit 1
35 fi
36
37 if [ ! -z "$SSH_KEY" ]; then
38 echo Deploying with parameters...
39 az group deployment create --name burrito01 --template-file $TYPE/azuredeploy.json --resource-group $RESOURCE_GROUP --parameters "{\"admin-username\":{\"value\":\"$USERNAME\"},\"ssh-public-key\":{\"value\":\"$SSH_KEY\"}}"
40 else
41 echo Deploying with parameter file...
42 az group deployment create --name burrito01 --template-file $TYPE/azuredeploy.json --resource-group $RESOURCE_GROUP --parameters @$TYPE/azuredeploy-parameters.json
43 fi
44