-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-server.sh
executable file
·48 lines (40 loc) · 1.57 KB
/
create-server.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
#!/bin/bash
while getopts "s:n:h:g:k:a:i:d:r:" opt;
do
case $opt in
a) AMAZON_INSTANCE="-a $OPTARG" ;;
d) RACKSPACE_SERVER_SIZE="-d $OPTARG" ;;
s) service=$OPTARG ;;
n) hostname=$OPTARG ;;
g) SECURITY_GROUP_NAME=$OPTARG ;;
i) AMAZON_INSTANCE_SIZE=" -i $OPTARG" ;;
k) PUBLIC_KEY=$OPTARG ;;
r) RACKSPACE_INSTANCE_NAME="-r $OPTARG" ;;
h) echo "Usage: create-server -n SERVERNAME -s SERVERTYPE (optional -d 'rackspace instance size', optional -g 'amazon security group name', optional -k 'public amazon/rackspace ssh key', optional -a 'amazon ami instance name', optional -i 'amazon instance size', optional -r 'rackspace VM instance name')"; exit 1 ;;
*) echo "Usage: create-server -n SERVERNAME -s SERVERTYPE (optional -d 'rackspace instance size', optional -g 'amazon security group name', optional -k 'public amazon/rackspace ssh key', optional -a 'amazon ami instance name', optional -i 'amazon instance size', optional -r 'rackspace VM instance name')" ; exit 1 ;;
esac
done
if [ -z "$hostname" ];
then
echo "Must have a hostname set!"
echo "Usage: create-server -n SERVERNAME -s SERVERTYPE";
exit 0;
fi
if [ "$service" = "rackspace" ];
then
./create-server-rackspace.sh -n $hostname $RACKSPACE_SERVER_SIZE $RACKSPACE_INSTANCE_NAME -k $PUBLIC_KEY
exit 1;
fi
if [ -z "$PUBLIC_KEY" ];
then
KEYARG="";
else
KEYARG=" -k $PUBLIC_KEY"
fi
if [ "$service" = "amazon" ];
then
./create-server-amazon.sh -n $hostname -g $SECURITY_GROUP_NAME $KEYARG $AMAZON_INSTANCE $AMAZON_INSTANCE_SIZE
exit 1;
fi
echo "You Must Enter A Service Type -s (either amazon or rackspace)"
exit 1;