Skip to content

Commit

Permalink
fix gen region uid (#4611)
Browse files Browse the repository at this point in the history
* fix gen region uid

* fix gen region uid

* fix gen region uid
  • Loading branch information
bxy4543 authored Mar 20, 2024
1 parent 9487f0b commit 60e490d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions deploy/cloud/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mongodbUri=""
cockroachdbUri=""
cockroachdbLocalUri=""
cockroachdbGlobalUri=""
defaultLocalRegionUID="ed257b4d-6832-437a-9e06-d683e7edb320"
localRegionUID=""

tlsCrtPlaceholder="<tls-crt-placeholder>"
tlsKeyPlaceholder="<tls-key-placeholder>"
Expand All @@ -32,6 +32,9 @@ function prepare {
# gen saltKey if not set or not found in secret
gen_saltKey

# gen regionUID if not set or not found in secret
gen_regionUID

# mutate desktop config
mutate_desktop_config

Expand Down Expand Up @@ -135,6 +138,15 @@ function gen_saltKey() {
fi
}

function gen_regionUID(){
uid=$(kubectl get secret desktop-frontend-secret -n sealos -o jsonpath="{.data.region_uid}" 2>/dev/null || true)
if [[ -z "$uid" ]]; then
localRegionUID=$(uuidgen)
else
localRegionUID=$(echo -n "$uid" | base64 -d)
fi
}

function mutate_desktop_config() {
# mutate etc/sealos/desktop-config.yaml by using mongodb uri and two random base64 string
sed -i -e "s;<your-mongodb-uri-base64>;$(echo -n "${mongodbUri}/sealos-auth?authSource=admin" | base64 -w 0);" etc/sealos/desktop-config.yaml
Expand All @@ -143,7 +155,7 @@ function mutate_desktop_config() {
sed -i -e "s;<your-password-salt-base64>;$saltKey;" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-region-database-url-base64>;$(echo -n "${cockroachdbLocalUri}" | base64 -w 0);" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-global-database-url-base64>;$(echo -n "${cockroachdbGlobalUri}" | base64 -w 0);" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-global-database-url-base64>;$(echo -n "${defaultLocalRegionUID}" | base64 -w 0);" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-local-region-uid-base64>;$(echo -n "${localRegionUID}" | base64 -w 0);" etc/sealos/desktop-config.yaml
}

function create_tls_secret {
Expand Down Expand Up @@ -186,7 +198,7 @@ function sealos_run_controller {
--env DEFAULT_NAMESPACE="account-system" \
--env GLOBAL_COCKROACH_URI="$cockroachdbGlobalUri" \
--env LOCAL_COCKROACH_URI="$cockroachdbLocalUri" \
--env LOCAL_REGION="$defaultLocalRegionUID"
--env LOCAL_REGION="$localRegionUID"

sealos run tars/account-service.tar

Expand Down

0 comments on commit 60e490d

Please sign in to comment.