-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathstart.sh
executable file
·104 lines (90 loc) · 2.36 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/sh
#/ Usage: start.sh [-g -h -n -r]
#/
#/ Start a GPU VM in Azure that will automatically process work for Folding@HOME
#/ https://foldingathome.org/
#/ https://github.com/gorzell/folding-at-azure
#/
#/ OPTIONS:
#/ -h | --help Show this message.
#/ -g | --resource-group Azure resource group name. DEFAULT: foldingathome
#/ -n | --name Name for the VM. DEFAULT: folding
#/ -p | --public Attach a public IP with port 22 open. DEFAULT: false
#/ -r | --region Azure region. DEFAULT: eastus
#/
set -e
usage () {
grep '^#/' <"$0" | cut -c 4-
}
RESOURCE_GROUP=foldingathome
LOCATION=eastus
USER=$(whoami)
NAME=
while [ "$#" -gt 0 ]; do
case "$1" in
-g|--resource-group)
RESOURCE_GROUP=$2
shift 2
;;
-h|--help)
usage
exit 2
;;
-n|--name)
NAME=$2
shift 2
;;
-r|--region)
LOCATION=$2
shift 2
;;
*)
echo "Unknown argument: $arg. Use -h or --help for details on available arguments." 1>&2
exit 2
esac
done
# Require the name flag.
if [ -z "$NAME" ]; then
echo "You must set a name.\n" 1>&2
usage
exit 2
fi
az group create --name $RESOURCE_GROUP --location $LOCATION
az network vnet create \
--resource-group $RESOURCE_GROUP \
--name $NAME-Vnet \
--address-prefix 192.168.0.0/16 \
--subnet-name $NAME-Subnet \
--subnet-prefix 192.168.1.0/24
az network public-ip create \
--resource-group $RESOURCE_GROUP \
--name $NAME-PublicIP \
--dns-name $NAME-publicdns
az network nsg create \
--resource-group $RESOURCE_GROUP \
--name $NAME-NetworkSecurityGroup
az network nsg rule create \
--resource-group $RESOURCE_GROUP \
--nsg-name $NAME-NetworkSecurityGroup \
--name $NAME-NetworkSecurityGroupRuleSSH \
--protocol tcp \
--priority 1000 \
--destination-port-range 22 \
--access allow
az network nic create \
--resource-group $RESOURCE_GROUP \
--name $NAME-Nic \
--vnet-name $NAME-Vnet \
--subnet $NAME-Subnet \
--public-ip-address $NAME-PublicIP \
--network-security-group $NAME-NetworkSecurityGroup
#--size Standard_NC6_Promo \
az vm create \
--resource-group $RESOURCE_GROUP \
--name $NAME-vm \
--size Standard_NC6_Promo \
--image Canonical:UbuntuServer:18.04-LTS:latest \
--custom-data cloud-init.yaml \
--admin-username $USER \
--generate-ssh-keys \
--nics $NAME-Nic