|
@@ -16,16 +16,13 @@ workload:
|
|
|
runAsGroup: 999
|
|
|
readOnlyRootFilesystem: false
|
|
|
env:
|
|
|
- UNIFI_STDOUT: true
|
|
|
+ DB_MONGO_LOCAL: true
|
|
|
+ RUN_CHOWN: false
|
|
|
+ RUNAS_UID0: false
|
|
|
UNIFI_HTTP_PORT: {{ .Values.unifiNetwork.webHttpPort }}
|
|
|
UNIFI_HTTPS_PORT: {{ .Values.unifiNetwork.webHttpsPort }}
|
|
|
PORTAL_HTTP_PORT: {{ .Values.unifiNetwork.portalHttpPort }}
|
|
|
PORTAL_HTTPS_PORT: {{ .Values.unifiNetwork.portalHttpsPort }}
|
|
|
- {{- if .Values.unifiNetwork.certificateID }}
|
|
|
- CERTNAME: cert.pem
|
|
|
- CERT_PRIVATE_NAME: privkey.pem
|
|
|
- CERT_IS_CHAIN: true
|
|
|
- {{- end }}
|
|
|
{{ with .Values.unifiConfig.additionalEnvs }}
|
|
|
envList:
|
|
|
{{ range $env := . }}
|
|
@@ -52,11 +49,20 @@ workload:
|
|
|
"GID" 999
|
|
|
"mode" "check"
|
|
|
"type" "init") | nindent 8 }}
|
|
|
- {{- if .Values.unifiNetwork.certificateID }}
|
|
|
- # Unifi chowns the files on startup, and if we mount them directly
|
|
|
- # from the secret, it will fail to start. So we make copy.
|
|
|
- 02-certs:
|
|
|
- enabled: true
|
|
|
+ {{- $migrate := false -}}
|
|
|
+ {{- if (hasKey .Values.global "ixChartContext") -}}
|
|
|
+ {{- if (hasKey .Values.global.ixChartContext "upgradeMetadata") -}}
|
|
|
+ {{- with .Values.global.ixChartContext.upgradeMetadata -}}
|
|
|
+ {{- $ver := semver (.oldChartVersion | default "0.0.0") -}}
|
|
|
+ {{/* Enable migrate script if old version is below 1.2.x */}}
|
|
|
+ {{- if and (eq $ver.Major 1) (lt $ver.Minor 2) -}}
|
|
|
+ {{- $migrate = true -}}
|
|
|
+ {{- end -}}
|
|
|
+ {{- end -}}
|
|
|
+ {{- end -}}
|
|
|
+ {{- end }}
|
|
|
+ 02-migrate:
|
|
|
+ enabled: {{ $migrate }}
|
|
|
type: init
|
|
|
imageSelector: image
|
|
|
securityContext:
|
|
@@ -64,15 +70,24 @@ workload:
|
|
|
runAsGroup: 999
|
|
|
readOnlyRootFilesystem: false
|
|
|
command:
|
|
|
- - /bin/sh
|
|
|
- - -c
|
|
|
+ - /bin/bash
|
|
|
args:
|
|
|
+ - -c
|
|
|
- |
|
|
|
- certdir=/unifi/cert
|
|
|
- echo "Copying certificates to $certdir"
|
|
|
- mkdir -p $certdir
|
|
|
- cp --force --verbose /ix/cert/private.key $certdir/privkey.pem
|
|
|
- cp --force --verbose /ix/cert/public.crt $certdir/cert.pem
|
|
|
- cp --force --verbose /ix/cert/public.crt $certdir/chain.pem
|
|
|
- {{- end -}}
|
|
|
+ newdatadir="/usr/lib/unifi/data"
|
|
|
+ olddatadir="/usr/lib/unifi/data/data"
|
|
|
+ # Check the dir exists
|
|
|
+ [ ! -d "$newdatadir" ] && echo "$newdatadir missing" && exit 1
|
|
|
+ # Check if there is a data/data dir to migrate
|
|
|
+ [ ! -d "$olddatadir" ] && echo "No $olddatadir dir found. Migration skipped" && exit 0
|
|
|
+
|
|
|
+ # Check if the new data dir is empty, ignoring the old data dir
|
|
|
+ dirs=$(ls -A "$newdatadir" | grep -v "data")
|
|
|
+ if [ -n "$dirs" ]; then
|
|
|
+ echo "New data dir is empty. Migrating data one level up"
|
|
|
+ mv $olddatadir/* $newdatadir || echo "Failed to move data" && exit 1
|
|
|
+ # Remove the data/data dir
|
|
|
+ rm -rf $olddatadir
|
|
|
+ echo "Data migration complete"
|
|
|
+ fi
|
|
|
{{- end -}}
|