diff --git a/deploy/cloud/scripts/init.sh b/deploy/cloud/scripts/init.sh index 10880a59f71..f14e2631808 100644 --- a/deploy/cloud/scripts/init.sh +++ b/deploy/cloud/scripts/init.sh @@ -7,7 +7,7 @@ mongodbUri="" cockroachdbUri="" cockroachdbLocalUri="" cockroachdbGlobalUri="" -defaultLocalRegionUID="ed257b4d-6832-437a-9e06-d683e7edb320" +localRegionUID="" tlsCrtPlaceholder="" tlsKeyPlaceholder="" @@ -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 @@ -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;;$(echo -n "${mongodbUri}/sealos-auth?authSource=admin" | base64 -w 0);" etc/sealos/desktop-config.yaml @@ -143,7 +155,7 @@ function mutate_desktop_config() { sed -i -e "s;;$saltKey;" etc/sealos/desktop-config.yaml sed -i -e "s;;$(echo -n "${cockroachdbLocalUri}" | base64 -w 0);" etc/sealos/desktop-config.yaml sed -i -e "s;;$(echo -n "${cockroachdbGlobalUri}" | base64 -w 0);" etc/sealos/desktop-config.yaml - sed -i -e "s;;$(echo -n "${defaultLocalRegionUID}" | base64 -w 0);" etc/sealos/desktop-config.yaml + sed -i -e "s;;$(echo -n "${localRegionUID}" | base64 -w 0);" etc/sealos/desktop-config.yaml } function create_tls_secret { @@ -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