-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.sh
executable file
·97 lines (60 loc) · 3.54 KB
/
git.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
#!/bin/bash
######################################################################################
############# This script will increment the port in Dockerfile && Nginx #############
######################################################################################
######################################################################################
############# CHANGE ENV PORT IN DOCKERFILE & NGINX #############
######################################################################################
get_api_port=`grep -o 'port=.*' Dockerfile`
api_port=`echo $get_api_port | awk 'match($0,"="){print substr($0,RSTART+1,4)}'`
echo 'previous_api_port : ' $api_port
changed_api_port=`echo $(($api_port + 1))`
sed -i "s/^ENV port=$api_port *$/ENV port=$changed_api_port/" Dockerfile
echo 'changed ENV ASPNETCORE_URLS port TO in DOCKERFILE : ' $changed_api_port
sed -i "s/server 127.0.0.1:$api_port/server 127.0.0.1:$changed_api_port/" nginx/nginx.conf
echo 'changed server 127.0.0.1:PORT in NGINX : ' $changed_api_port
echo ''
echo ''
echo ''
#####################################################################################
############ CHANGE EXPOSE PORT IN DOCKERFILE, NGINX & YML #############
#####################################################################################
get_nginx_in_dockerfile=`grep -o 'EXPOSE .*' Dockerfile`
nginx_port=`echo $get_nginx_in_dockerfile | awk 'match($0," "){print substr($0,RSTART+1,4)}'`
echo 'previous_nginx_port : ' $nginx_port
changed_nginx_port=`echo $(($nginx_port + 1))`
sed -i "s/^EXPOSE .*$/EXPOSE $changed_nginx_port/" Dockerfile
echo 'changed EXPOSE port TO in DOCKERFILE: ' $changed_nginx_port
sed -i "s/listen .*$/listen $changed_nginx_port;/" nginx/nginx.conf
echo 'changed LISTEN port in NGINX: ' $changed_nginx_port
sed -i "s/Default: $nginx_port/Default: $changed_nginx_port/" fargate_from_scratch.yml
echo 'changed DEFAULT port for CONTAINER in YML: ' $changed_nginx_port
echo ''
echo ''
echo ''
#####################################################################################
############ CHANGE VERSION NUMBER IN YML & NGINX #############
#####################################################################################
get_api_location=`grep -o 'location .*' nginx/nginx.conf`
api_location=`echo $get_api_location | awk 'match($0,"v"){print substr($0,RSTART+1,1)}'`
echo 'previous_api_location : ' $api_location
changed_api_location=`echo $(($api_location + 1))`
echo 'changed location: ' $changed_api_location
sed -i "s/v$api_location/v$changed_api_location/" nginx/nginx.conf
echo 'changed API PATH LOCATION in NGINX : ' $changed_api_location
sed -i "s/v$api_location/v$changed_api_location/g" fargate_from_scratch.yml
echo 'changed API PATH LOCATION in YML : ' $changed_api_location
echo ''
echo ''
echo ''
#####################################################################################
###################### CHANGE PRIORITY NUMBER IN YML ###################
#####################################################################################
find_priority=`grep -o 'Priority: .*' fargate_from_scratch.yml`
get_priority_number=`echo $find_priority | awk 'match($0,":"){print substr($0,RSTART+1,2)}'`
echo 'get priority number: ' $get_priority_number
changed_priority_number=`echo $(($get_priority_number + 1))`
echo 'changed priority: ' $changed_priority_number
####### SPACING AFTER DEFAULT: 2 NEEDED ###########3
sed -i "s/Priority:$get_priority_number/Priority: $changed_priority_number/" fargate_from_scratch.yml
echo 'changed PRIORITY NUMBER in YML: ' $changed_priority_number