From cb3ab668d866ea9e3428e548d9065a9681174e82 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 21 Mar 2025 13:34:46 -0500 Subject: [PATCH] chore(updatescript): added in so we can do a full install with an env creation for old --- server/scripts/update.ps1 | 127 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/server/scripts/update.ps1 b/server/scripts/update.ps1 index dc68889..a9f3258 100644 --- a/server/scripts/update.ps1 +++ b/server/scripts/update.ps1 @@ -204,12 +204,139 @@ $plantFunness = { ########################################################### # Old system still active until we have everything off it ########################################################### + +########################################################### +# Frontend env +########################################################### + + Write-Host "Creating the env file in the front end" +$envContentTemplatef = @" +NEXTAUTH_SECRET= "12348fssad5sdg2f2354afvfw34" +NEXTAUTH_URL_INTERNAL= "http://localhost:3000" +NEXTAUTH_URL="{url}" +API_KEY= "E3ECD3619A943B98C6F33E3322362" +"@ + + try { + $url = "http://$($token)vms006:3000" + + if ($token -eq "usiow2") { + $url = "http://usiow1vms006:3001" + } + + if ($token -in @("test1", "test2", "test3")) { + $url = "http://usmcd1vms036:3000" + } + + # Replace {url} with the actual $url + $envContentf = $envContentTemplatef -replace "{url}", $url + + # Define the path where the .env file should be created + $envFilePathf = $obslst + "\apps\frontend\.env" + Write-Host "Final URL: $url" + # Write the content to the .env file + $envContentf | Out-File -FilePath $envFilePathf -Encoding UTF8 -Force + + # Optional: Verify the file was created + if (Test-Path $envFilePathf) { + Write-Host "`.env` file created successfully on $env:COMPUTERNAME at $envFilePathf" + } else { + Write-Host "Failed to create `.env` file on $env:COMPUTERNAME" + } + + } catch { + Write-Host "Error: Failed to create `.env` file on $server - $_" + } + +########################################################### +# DB env +########################################################### + +Write-Host "Creating the env file in the front end" +$envContentTemplateb = @" +DATABASE_URL="file:E:\LST\db\lstBackendDB.db" +"@ + + try { + + # 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 + + # Optional: Verify the file was created + if (Test-Path $envFilePathb) { + Write-Host "`.env` file created successfully on $env:COMPUTERNAME at $envFilePathb" + } else { + Write-Host "Failed to create `.env` file on $env:COMPUTERNAME" + } + + } catch { + Write-Host "Error: Failed to create `.env` file on $server - $_" + } + +########################################################### +# backend env +########################################################### + +Write-Host "Creating the env file in the front end" +$envContentTemplated = @" +# Server env +NODE_ENV = production +# server apiKey +API_KEY = E3ECD3619A943B98C6F33E3322362 +# Prisma DB link +DATABASE_URL="file:E:\LST\db\lstBackendDB.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" +DATABASE_BACKUP_LOC="E:\LST\backups" +# Server port +SERVER_PORT = 4400 +# Logging +LOG_LEVEL = info +LOG_LOC ="E:\\LST\\logs" + +# authentication +SALTING = 12 +SECRET = E3ECD3619A943B98C6F33E3322362 +JWT_SECRET = 12348fssad5sdg2f2354afvfw34 +JWT_EXPIRES_TIME = 1h + +# cookie time is in min please take this into consideration when creating all the times +COOKIE_EXPIRES_TIME = 60 + +# password token reset in mintues +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 + + # Optional: Verify the file was created + if (Test-Path $envFilePathd) { + Write-Host "`.env` file created successfully on $env:COMPUTERNAME at $envFilePathd" + } else { + Write-Host "Failed to create `.env` file on $env:COMPUTERNAME" + } + + } catch { + Write-Host "Error: Failed to create `.env` file on $server - $_" + } + + Write-Host "Running install on obs server." Set-Location $obslst npm run newinstall # --omit=dev Write-Host "Update the frontend" npm run install:front npm run install:ui + npm run install:db Write-Host "Running db updates" npm run db:migrate