Skip to content

Commit

Permalink
Merge pull request #295 from hollaex/testnet
Browse files Browse the repository at this point in the history
HollaEx CLI v2.9.0 Release
  • Loading branch information
abeikverdi committed Nov 20, 2023
2 parents 3055543 + 0ef1f80 commit 79a452e
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 5 deletions.
107 changes: 107 additions & 0 deletions hollaex
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ Options:
--whitelist-ip, List of whitelist IPs for the maintenance mode. Comma separated, no spaces.
--disable_maintenance_mode, Disabling maintenance mode.
--upgrade-psql-db-version, Upgrade PostgreSQL DB to a specific version.
--change-user-email, Force change exchange user's email address.
--user-id, Target User ID.
--user-email, New User Email Address.

dev: Running an exchange in a dev mode.
--setup, Setup an exchange in a dev mode.
Expand Down Expand Up @@ -7113,6 +7116,25 @@ elif [[ "$1" == "toolbox" ]]; then
TOOLBOX_ENABLE=true
shift; continue
;;
--change-user-email)
export CHANGE_USER_EMAIL=true
TOOLBOX_ENABLE=true
shift; continue
;;
--user-id)
shift
case $1 in (-*|"") err_msg_l; print_usage; exit 1; esac
export CHANGE_USER_EMAIL_USER_ID=$1
TOOLBOX_ENABLE=true
shift; continue
;;
--user-email)
shift
case $1 in (-*|"") err_msg_l; print_usage; exit 1; esac
export CHANGE_USER_EMAIL_USER_EMAIL_ADDR=$1
TOOLBOX_ENABLE=true
shift; continue
;;
--skip)
RUN_WITH_VERIFY=false
echo "Skipping the command confirmation."
Expand Down Expand Up @@ -8614,6 +8636,91 @@ elif [[ "$1" == "toolbox" ]]; then
fi


elif [[ "$CHANGE_USER_EMAIL" ]]; then


if [[ ! "$CHANGE_USER_EMAIL_USER_ID" ]] || [[ ! "$CHANGE_USER_EMAIL_USER_EMAIL_ADDR" ]]; then


echo "Error: Either Target User ID or Target User Email Addr is missing!"
echo "Please set them by passing --user-id and --user-email flags!"
exit 1;

fi

echo "Target User ID: $CHANGE_USER_EMAIL_USER_ID"
echo "New User Email: $CHANGE_USER_EMAIL_USER_EMAIL_ADDR"

if [[ "$USE_KUBERNETES" ]]; then


cat > $TEMPLATE_GENERATE_PATH/kubernetes/config/changeEmail.yaml <<EOL
job:
enable: true
mode: changeEmail
env:
targetUserID: ${CHANGE_USER_EMAIL_USER_ID}
newUserEmail: ${CHANGE_USER_EMAIL_USER_EMAIL_ADDR}

EOL

if command helm install $ENVIRONMENT_EXCHANGE_NAME-change-email \
--namespace $ENVIRONMENT_EXCHANGE_NAME \
--set DEPLOYMENT_MODE="api" \
--set imageRegistry="$ENVIRONMENT_USER_HOLLAEX_CORE_IMAGE_REGISTRY" \
--set dockerTag="$ENVIRONMENT_USER_HOLLAEX_CORE_IMAGE_VERSION" \
--set envName="$ENVIRONMENT_EXCHANGE_NAME-env" \
--set secretName="$ENVIRONMENT_EXCHANGE_NAME-secret" \
--set job.enable=true \
--set job.mode=changeEmail \
-f $TEMPLATE_GENERATE_PATH/kubernetes/config/nodeSelector-hollaex-stateful.yaml \
-f $SCRIPTPATH/kubernetes/helm-chart/bitholla-hollaex-server/values.yaml \
-f $TEMPLATE_GENERATE_PATH/kubernetes/config/changeEmail.yaml \
$SCRIPTPATH/kubernetes/helm-chart/bitholla-hollaex-server; then

while ! [[ $(kubectl get jobs $ENVIRONMENT_EXCHANGE_NAME-change-email --namespace $ENVIRONMENT_EXCHANGE_NAME -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}') == "True" ]] ;
do echo "Waiting for the changeEmail job gets done..."
sleep 10;
done;

echo "Successfully ran the changeEmail job!"
kubectl logs --namespace $ENVIRONMENT_EXCHANGE_NAME job/$ENVIRONMENT_EXCHANGE_NAME-change-email

echo "Removing the Kubernetes Job for running changeEmail jobs..."
helm uninstall $ENVIRONMENT_EXCHANGE_NAME-change-email --namespace $ENVIRONMENT_EXCHANGE_NAME

else

printf "\033[91mFailed to create Kubernetes Job for running changeEmail job, Please confirm your input values and try again.\033[39m\n"

echo "Displayling logs..."
kubectl logs --namespace $ENVIRONMENT_EXCHANGE_NAME job/$ENVIRONMENT_EXCHANGE_NAME-change-email

helm uninstall $ENVIRONMENT_EXCHANGE_NAME-change-email --namespace $ENVIRONMENT_EXCHANGE_NAME

exit 1;

fi

else

IFS=',' read -ra CONTAINER_PREFIX <<< "-${ENVIRONMENT_EXCHANGE_RUN_MODE}"

if command docker exec --env "USER_ID=${CHANGE_USER_EMAIL_USER_ID}" --env "EMAIL=${CHANGE_USER_EMAIL_USER_EMAIL_ADDR}" ${DOCKER_COMPOSE_NAME_PREFIX}${ENVIRONMENT_EXCHANGE_NAME}-server${CONTAINER_PREFIX[0]}${DOCKER_COMPOSE_CONTAINER_NUMBER_CONNECTOR}1 node tools/dbs/changeEmail.js; then

echo "Successfully updated user $CHANGE_USER_EMAIL_USER_ID's email to $CHANGE_USER_EMAIL_USER_EMAIL_ADDR."

exit 0;

else

echo "Failed to run the command!"
exit 1;

fi

fi

fi

elif [[ "$1" == "cloud" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/helm-chart/bitholla-hollaex-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
description: A Helm chart for HollaEx Kit
name: hollaex-kit
version: 2.8.4
version: 2.9.0
17 changes: 14 additions & 3 deletions kubernetes/helm-chart/bitholla-hollaex-server/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ spec:
node tools/dbs/checkConfig.js;
node tools/dbs/setKitVersion.js;

{{- else if eq .Values.job.mode "changeEmail" }}

args:
- node tools/dbs/changeEmail.js;

{{- end }}

imagePullPolicy: Always
Expand Down Expand Up @@ -160,14 +165,20 @@ spec:
- name: CAPTCHA_SECRET_KEY
value: "{{.Values.job.env.captcha_secret_key}}"

{{- else if eq .Values.job.mode "changeEmail" }}

- name: USER_ID
value: "{{.Values.job.env.targetUserID}}"
- name: EMAIL
value: "{{.Values.job.env.newUserEmail}}"

{{- end }}

resources:
limits:
memory: "300Mi"
cpu: "100m"
memory: "500Mi"
requests:
memory: "50Mi"
memory: "100Mi"
cpu: "15m"

{{- if .Values.imagePullSecrets }}
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.4
2.9.0

0 comments on commit 79a452e

Please sign in to comment.