-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #449 from bhumi46/release-1.1.x
[MOSIP-36849] added postgres init script
- Loading branch information
Showing
4 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
dbUserPasswords: | ||
dbuserPassword: "" | ||
databases: | ||
mosip_audit: | ||
enabled: true | ||
host: "esignet-postgres.es-dev.mosip.net" | ||
port: 5432 | ||
su: | ||
user: postgres | ||
secret: | ||
name: postgres-postgresql | ||
key: postgres-password | ||
dml: 0 | ||
repoUrl: https://github.com/mosip/audit-manager.git | ||
branch: develop | ||
mosip_kernel: | ||
enabled: true | ||
host: "esignet-postgres.es-dev.mosip.net" | ||
port: 5432 | ||
su: | ||
user: postgres | ||
secret: | ||
name: postgres-postgresql | ||
key: postgres-password | ||
dml: 0 | ||
repoUrl: https://github.com/mosip/commons.git | ||
branch: develop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
# Script to initialize the DB. | ||
## Usage: ./init_db.sh [kubeconfig] | ||
|
||
if [ $# -ge 1 ] ; then | ||
export KUBECONFIG=$1 | ||
fi | ||
|
||
# Function to initialize the DB | ||
function initialize_db() { | ||
NS=signup | ||
CHART_VERSION=1.1.0-develop | ||
helm repo update | ||
|
||
# Confirm if the user wants to initialize DB scripts | ||
while true; do | ||
read -p "Are the modules of the MOSIP platform already deployed? (Y/n): " yn | ||
if [[ "$yn" == "Y" || "$yn" == "y" ]]; then | ||
echo "Exiting as MOSIP platform modules are already deployed.No need to initialize db again" | ||
exit 0 | ||
elif [[ "$yn" == "N" || "$yn" == "n" ]]; then | ||
echo "Initializing DB scripts for MOSIP_KERNEL and MOSIP_AUDIT, because mosip platform modules are not deployed yet" | ||
break | ||
else | ||
echo "Invalid input. Please enter Y for Yes or N for No." | ||
fi | ||
done | ||
|
||
while true; do | ||
read -p "Please confirm with "Y" once init-values.yaml is updated correctly with tag, postgres host details else "N" to exit installation: " ans | ||
if [ "$ans" = "Y" ] || [ "$ans" = "y" ]; then | ||
break | ||
elif [ "$ans" = "N" ] || [ "$ans" = "n" ]; then | ||
exit 1 | ||
else | ||
echo "Please provide a correct option (Y or N)" | ||
fi | ||
done | ||
|
||
# Prompt for dbuserPassword | ||
echo "Please provide the dbuserPassword" | ||
read -s dbuserPassword | ||
if [ -z "$dbuserPassword" ]; then | ||
echo "ERROR: dbuserPassword not specified; EXITING." | ||
exit 1 | ||
fi | ||
|
||
# Initialize DB | ||
echo "Removing any existing installation..." | ||
helm -n $NS delete postgres-init || true | ||
kubectl -n $NS delete secret db-common-secrets || true | ||
./copy_cm_func.sh secret postgres-postgresql postgres $NS | ||
|
||
echo "Initializing DB..." | ||
helm -n $NS install postgres-init mosip/postgres-init -f init_values.yaml \ | ||
--version $CHART_VERSION \ | ||
--set dbUserPasswords.dbuserPassword="$dbuserPassword" \ | ||
--wait --wait-for-jobs | ||
|
||
echo "Database initialization complete." | ||
return 0 | ||
} | ||
|
||
# Set commands for error handling | ||
set -e | ||
set -o errexit ## exit the script if any statement returns a non-true return value | ||
set -o nounset ## exit the script if you try to use an uninitialized variable | ||
set -o errtrace # trace ERR through 'time command' and other functions | ||
set -o pipefail # trace ERR through pipes | ||
|
||
# Call the function | ||
initialize_db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters