generated from arafkarsh/ms-springboot-324-java-22-jakarta-ee-10
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathupdateProperties
executable file
·43 lines (36 loc) · 1.86 KB
/
updateProperties
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
#!/bin/bash
# -------------------------------------------------------------------------------------------
# @author: Araf Karsh Hamid
# -------------------------------------------------------------------------------------------
# Update properties for local testing inside docker and kubernetes
# ===========================================================================================
update_properties() {
echo "--------------------------------------------------------------------------"
echo "Updating Staging and Production Property file with DB Server Name"
echo "--------------------------------------------------------------------------"
replace_db_server "src/docker/Input/application-staging.properties"
replace_db_server "src/docker/Input/application-prod.properties"
echo "--------------------------------------------------------------------------"
replace_db_server "src/kubernetes/Package/application-staging.properties"
replace_db_server "src/kubernetes/Package/application-prod.properties"
enable_k8s_for_swagger "src/kubernetes/Package/application.properties"
echo "--------------------------------------------------------------------------"
}
# Function to replace db.server value in the given file
replace_db_server() {
local filepath="$1"
# Check if the file exists
if [ -f "$filepath" ]; then
sed -i -r 's/^db\.server=localhost$/db.server=host.docker.internal/g' "$filepath"
echo "Replaced 'db.server=localhost' with 'db.server=host.docker.internal' in $filepath."
fi
}
enable_k8s_for_swagger() {
local filepath="$1"
if [ -f "$filepath" ]; then
# server.host.k8s.enabled=false
sed -i -r 's/^server\.host\.k8s\.enabled=false$/server.host.k8s.enabled=true/g' "$filepath"
echo "Replaced 'server.host.k8s.enabled=false' with 'server.host.k8s.enabled=true' in $filepath."
fi
}
update_properties