add helm charts

This commit is contained in:
Ybehrooz
2025-11-09 13:22:40 +03:30
parent 282c3e52d0
commit 38e4d749ad
1352 changed files with 190457 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
#!/bin/bash
{{- if .Values.backup.enabled }}
export database=$1;
export now=$2;
if [ -z "$database" ]; then
echo ERROR Database name is not specified at the 1st argument
exit 1
fi
if [ -z "$now" ]; then
echo "ERROR Backup time is not specified as 2nd argument"
exit 1
fi
backuppath={{ .Values.backup.persistence.mount }}/$database-$now.bak
if [ -f "${backuppath}" ];then
echo INFO - DB $database Snapshot found! Restoring...
else
echo ERROR - No Snapshot Found under $backuppath
exit 1;
fi
sqlcmd -C \
-S {{ include "mssql.primary.fullname" . }}.{{ include "common.names.namespace" $ }}.svc.{{ .Values.clusterDomain }} \
-U sa -P "$MSSQL_SA_PASSWORD" \
-e -Q "RESTORE DATABASE $database FROM DISK = '$backuppath'"
{{- else }}
printf "WARN No restore script available because"
echo " .Values.backup.enabled is falsy when you deployed this helm chart"
{{- end }}

View File

@@ -0,0 +1,21 @@
-- Credits for https://stackoverflow.com/a/52484134/747579
{{- if .Values.auth.createLogin }}
USE [master]
GO
CREATE LOGIN [{{ .Values.auth.username }}] WITH PASSWORD=N'$(MSSQL_PASSWORD)'
GO
{{- end }}
{{- if .Values.auth.username }}
USE [master]
GO
CREATE USER [{{ .Values.auth.username }}] FOR LOGIN [{{ .Values.auth.username }}]
GO
{{- end }}
{{- if and .Values.auth.database .Values.auth.username }}
USE [{{ .Values.auth.database }}]
GO
CREATE USER [{{ .Values.auth.username }}] FOR LOGIN [{{ .Values.auth.username }}]
ALTER ROLE db_owner ADD MEMBER [{{ .Values.auth.username }}]
GO
{{- end }}