-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx_generator.sh
executable file
·65 lines (52 loc) · 1.23 KB
/
nginx_generator.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
#/bin/bash
#################################
# configuration variables
################################
# default parameters
VM_1="null"
DS_IP="null"
PROXY="proxy"
VM_1="null"
NETWORK_NAME="private-network"
NETWORK="192.168.0.0/24"
# arguments
while (( "$#" ));
do
PARAM="$1";
VALUE="$2";
case $PARAM in
-n)
NETWORK="$VALUE"
;;
-nName)
NETWORK_NAME="$VALUE"
;;
-name)
PROXY="$VALUE"
;;
-image)
NG_IMAGE="$VALUE"
;;
-vm)
VM_1="$VALUE"
;;
-ds)
DS_IP="$VALUE"
;;
esac
shift
done
#############################################
# creating nginx
#############################################
ID_CONTAINER=$[RANDOM % 10 + 1]
UUID=$(uuidgen)
IP=$(docker-machine ip $VM_1)
echo "tu3"
eval $(docker-machine env $VM_1)
docker run -itd -p 80:80 --name=$PROXY$ID_CONTAINER --net=$NETWORK_NAME --env="constraint:node==$VM_1" ng
echo "tu"
json="{ \"ID\": \"$UUID\", \"Name\": \"$PROXY\", \"Address\": \"$IP\", \"Port\": 80, \"check\": { \"name\": \"web-proxy\", \"http\": \"http://$IP:80/health/\", \"interval\": \"10s\", \"timeout\": \"5s\", \"status\": \"passing\"}}"
echo $json > ./temporary.json
curl -X PUT --data-binary @temporary.json http://$DS_IP:8500/v1/agent/service/register
rm ./temporary.json