diff --git a/server/scripts/update.ps1 b/server/scripts/update.ps1 index a9f3258..f2931b5 100644 --- a/server/scripts/update.ps1 +++ b/server/scripts/update.ps1 @@ -254,16 +254,29 @@ API_KEY= "E3ECD3619A943B98C6F33E3322362" Write-Host "Creating the env file in the front end" $envContentTemplateb = @" -DATABASE_URL="file:E:\LST\db\lstBackendDB.db" +DATABASE_URL="file:E:\LST\db\{dbLink}.db" "@ try { + + $dbLink = "lstBackendDB" + + if ($token -eq "usiow2") { + $dbLink = "lstBackendDB_2" + } + + if ($token -in @("test1", "test2", "test3")) { + $dbLink = "lstBackendDB" + } + + # Replace {url} with the actual $url + $envContentb = $envContentTemplateb -replace "{dbLink}", $dbLink # Define the path where the .env file should be created $envFilePathb = $obslst + "\packages\database\.env" # Write the content to the .env file - $envContentTemplateb | Out-File -FilePath $envFilePathb -Encoding UTF8 -Force + $envContentb | Out-File -FilePath $envFilePathb -Encoding UTF8 -Force # Optional: Verify the file was created if (Test-Path $envFilePathb) { @@ -287,12 +300,19 @@ NODE_ENV = production # server apiKey API_KEY = E3ECD3619A943B98C6F33E3322362 # Prisma DB link -DATABASE_URL="file:E:\LST\db\lstBackendDB.db" +DATABASE_URL="file:E:\LST\db\{dbLink}.db" # if you still want the db in the same folder as the server install you need to do like the example below else use the relevent link -DATEBASE_LOC="E:\LST\db\lstBackendDB.db" +DATEBASE_LOC="E:\LST\db\{dbLink}.db" DATABASE_BACKUP_LOC="E:\LST\backups" # Server port -SERVER_PORT = 4400 +GATEWAY_PORT={gatewayport} +AUTH_PORT=4100 +SYSTEM_APP_PORT={systemport} +OCME_PORT={ocme} + +# This should me removed once we have the entire app broke out to its own apps +OLD_APP_PORT={appPort} + # Logging LOG_LEVEL = info LOG_LOC ="E:\\LST\\logs" @@ -310,13 +330,39 @@ COOKIE_EXPIRES_TIME = 60 RESET_TOKEN = 330 "@ - try { - - # Define the path where the .env file should be created - $envFilePathd = $obslst + "\.env" - - # Write the content to the .env file - $envContentTemplated | Out-File -FilePath $envFilePathd -Encoding UTF8 -Force +try { + + $dbLink = "lstBackendDB" + $gatewayport = "4400" + $systemport = "4200" + $ocmeport = "4300" + $appport = "4900" + + if ($token -eq "usiow2") { + $dbLink = "lstBackendDB_2" + $gatewayport = "4401" + $systemport = "4201" + $ocmeport = "4301" + $appport = "4901" + } + + if ($token -in @("test1", "test2", "test3")) { + $dbLink = "lstBackendDB" + } + + # + $port1 = $envContentTemplated -replace "{gatewayport}", $gatewayport + $port2 = $port1 -replace "{systemport}", $systemport + $port3 = $port2 -replace "{ocme}", $ocmeport + $port4 = $port3 -replace "{appPort}", $appport + $envContentd = $port4 -replace "{dbLink}", $dbLink + + + # Define the path where the .env file should be created + $envFilePathd = $obslst + "\.env" + + # Write the content to the .env file + $envContentd | Out-File -FilePath $envFilePathd -Encoding UTF8 -Force # Optional: Verify the file was created if (Test-Path $envFilePathd) {