Skip to content

Commit

Permalink
[DSD-6382] added captcha secret update part to initialisation script (#…
Browse files Browse the repository at this point in the history
…943)

* [DSD-6382] added captcha secret update part to initialisation script

Signed-off-by: ckm007 <[email protected]>

* Update initialise-prereq.sh

Signed-off-by: Chandra Keshav Mishra <[email protected]>

* Update initialise-prereq.sh

Signed-off-by: Chandra Keshav Mishra <[email protected]>

---------

Signed-off-by: ckm007 <[email protected]>
Signed-off-by: Chandra Keshav Mishra <[email protected]>
  • Loading branch information
ckm007 authored Oct 15, 2024
1 parent d60c127 commit 264c510
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 22 deletions.
7 changes: 2 additions & 5 deletions deploy/captcha/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ fi
NS=captcha
CHART_VERSION=0.1.0-develop

echo Create $NS namespace
kubectl create ns $NS

function installing_captcha() {

while true; do
read -p "Do you want to continue installing captcha validation service? (y/n): "
read -p "Do you want to continue installing captcha validation service? (y/n): " ans
if [ "$ans" = "Y" ] || [ "$ans" = "y" ]; then
break
elif [ "$ans" = "N" ] || [ "$ans" = "n" ]; then
Expand All @@ -29,7 +26,7 @@ function installing_captcha() {
CHART_VERSION=0.1.0-develop

echo Create $NS namespace
kubectl create ns $NS
kubectl create ns $NS || true

echo Istio label

Expand Down
15 changes: 8 additions & 7 deletions deploy/config-server/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ if [ $# -ge 1 ] ; then
export KUBECONFIG=$1
fi

# set commands for error handling.
set -e
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errtrace # trace ERR through 'time command' and other functions
set -o pipefail # trace ERR through pipes

NS=esignet
CHART_VERSION=0.0.1-develop

echo Create $NS namespace
kubectl create ns $NS
# set commands for error handling.
set -e
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errtrace # trace ERR through 'time command' and other functions
set -o pipefail # trace ERR through pipes
kubectl create ns $NS || true

echo Istio label
kubectl label ns $NS istio-injection=enabled --overwrite
Expand Down
2 changes: 1 addition & 1 deletion deploy/esignet/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kubectl create ns $NS
function installing_esignet() {

while true; do
read -p "Do you want to continue installing esignet services? (y/n): "
read -p "Do you want to continue installing esignet services? (y/n): " ans
if [ "$ans" = "Y" ] || [ "$ans" = "y" ]; then
break
elif [ "$ans" = "N" ] || [ "$ans" = "n" ]; then
Expand Down
33 changes: 25 additions & 8 deletions deploy/initialise-prereq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,45 @@ function initialising_Prerequisites() {
prompt_for_initialisation "$module" "${prompts[$module]}"
done

ESIGNET_HOST=$(kubectl -n esignet get cm esignet-global -o jsonpath={.data.mosip-esignet-host})
echo Please enter the recaptcha admin site key for domain $ESIGNET_HOST
read ESITE_KEY
echo Please enter the recaptcha admin secret key for domain $ESIGNET_HOST
read ESECRET_KEY

while true; do
read -p "Do you want to continue configuring Captcha secrets for esignet ? (y/n) : " ans
if [ $ans='Y' ] || [ $ans='y' ]; then
echo "Please create captcha site and secret key for esignet domain: esignet.sandbox.xyz.net"

ESIGNET_HOST=$(kubectl -n esignet get cm esignet-global -o jsonpath={.data.mosip-esignet-host})
echo Please enter the recaptcha admin site key for domain $ESIGNET_HOST
read ESITE_KEY
echo Please enter the recaptcha admin secret key for domain $ESIGNET_HOST
read ESECRET_KEY

echo "Setting up captcha secrets"
kubectl -n $NS create secret generic esignet-captcha --from-literal=esignet-captcha-site-key=$ESITE_KEY --from-literal=esignet-captcha-secret-key=$ESECRET_KEY --dry-run=client -o yaml | kubectl apply -f -
echo "Captcha secrets for esignet configured sucessfully"

./copy_cm_func.sh secret esignet-captcha $NS captcha

# Check if the second environment variable exists
ENV_VAR_EXISTS=$(kubectl -n captcha get deployment captcha -o jsonpath="{.spec.template.spec.containers[0].env[?(@.name=='MOSIP_CAPTCHA_SECRET_ESIGNET')].name}")

if [[ -z "$ENV_VAR_EXISTS" ]]; then
# If the environment variable does not exist, add it
echo "Environment variable 'MOSIP_CAPTCHA_SECRET_ESIGNET' does not exist. Adding it..."
kubectl patch deployment -n captcha captcha --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/env/-", "value": {"name": "MOSIP_CAPTCHA_SECRET_ESIGNET", "valueFrom": {"secretKeyRef": {"name": "esignet-captcha", "key": "esignet-captcha-secret-key"}}}}]'
else
# If the environment variable exists, update it
echo "Environment variable 'MOSIP_CAPTCHA_SECRET_ESIGNET' exists. Updating it..."
kubectl patch deployment -n captcha captcha --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/env[?(@.name==\"MOSIP_CAPTCHA_SECRET_ESIGNET\")]", "value": {"name": "MOSIP_CAPTCHA_SECRET_ESIGNET", "valueFrom": {"secretKeyRef": {"name": "esignet-captcha", "key": "esignet-captcha-secret-key"}}}}]'
fi

echo Setting up dummy values for esignet misp license key
kubectl -n $NS create secret generic esignet-misp-onboarder-key --from-literal=mosip-esignet-misp-key='' --dry-run=client -o yaml | kubectl apply -f -
elif [ "$ans" = "N" ] || [ "$ans" = "n" ]; then
exit 1
else
echo "Please provide a correct option (Y or N)"
fi
done

echo "Setting up dummy values for esignet misp license key"
kubectl -n $NS create secret generic esignet-misp-onboarder-key --from-literal=mosip-esignet-misp-key='' --dry-run=client -o yaml | kubectl apply -f -

echo "All prerequisite services initialised successfully."
return 0
Expand Down
2 changes: 1 addition & 1 deletion deploy/oidc-ui/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi
function installing_oidc-ui() {

while true; do
read -p "Do you want to continue installing OIDC ui? (y/n) :"
read -p "Do you want to continue installing OIDC ui? (y/n) :" ans
if [ "$ans" = "Y" ] || [ "$ans" = "y" ]; then
break
elif [ "$ans" = "N" ] || [ "$ans" = "n" ]; then
Expand Down

0 comments on commit 264c510

Please sign in to comment.