commit 668bc135dd33145772532a7decf2ce83c1319801 Author: achi Date: Wed Jun 5 10:36:28 2024 +1000 Initial commit diff --git a/Install-Lers.ps1 b/Install-Lers.ps1 new file mode 100644 index 0000000..63037e5 --- /dev/null +++ b/Install-Lers.ps1 @@ -0,0 +1,98 @@ +param ([string]$db) + +Set-Strictmode -Version 1 + +$composeDir = "." + +$composeWithoutDb=@" +version: "3.9" +services: + lers: + image: sc.lers.ru/reg/full:`${VERSION:-latest} + ports: + - "10000:10000" + volumes: + - lers-data:/var/LERS + - lers-config-data:/etc/LERS +volumes: + lers-data: + lers-config-data: +"@ + +$composeSqlServer=@" +version: "3.9" +services: + lers: + image: sc.lers.ru/reg/full:`${VERSION:-latest} + depends_on: + - "db" + ports: + - "10000:10000" + volumes: + - lers-data:/var/LERS + environment: + LERS_SERVER_DATABASE__ConnectionString: "Data Source=db; Initial Catalog=LERS; User ID=sa; Password=`${DB_PASSWORD}; Integrated Security=false" + db: + image: "mcr.microsoft.com/mssql/server" + environment: + MSSQL_SA_PASSWORD: `${DB_PASSWORD} + ACCEPT_EULA: "y" + volumes: + - db-data:/var/opt/mssql/data +volumes: + lers-db-data: + lers-data: +"@ + +$composePostgres=@" +version: "3.9" +services: + lers: + image: lersamr/full:`${VERSION:-latest} + depends_on: + - "db" + ports: + - "10000:10000" + volumes: + - lers-data:/var/LERS + environment: + LERS_SERVER_DATABASE__ConnectionString: "Host=db;Database=LERS;Username=postgres;Password=${DB_PASSWORD}" + LERS_SERVER_DATABASE__Provider: "Postgres" + db: + image: postgres + environment: + POSTGRES_PASSWORD: ${DB_PASSWORD} + volumes: + - lers-db-data:/var/lib/postgresql/data +volumes: + lers-db-data: + lers-data: +"@ + + +$compose = $composeWithoutDb + +if (($db -eq "pg") -or ($db -eq "postgres") -or ($db -eq "postgresql")) { + Write-Host "Устанавливается Postgres" + $compose = $composePostgres +} +elseif (($db -eq "sql") -or ($db -eq "sqlserver") -or ($db -eq "mssql") -or ($db -eq "mssqlserver")) { + Write-Host "Устанавливается Microsoft SQL Server" + $compose = $composeSqlServer +} +elseif ($db -eq "") { + Write-Host "Устанавливается система без базы данных" +} +else { + throw Error("Неподдерживаемая БД: " + $db) +} + +# Создаём compose.yml +Out-File -FilePath "$composeDir/compose.yml" -InputObject $compose + +# Создаём переменные среды +$envVars = @" +DB_PASSWORD=StrongDb_Password1 +"@ + +Out-File -FilePath "$composeDir/.env" -InputObject $envVars