Added Built-In Borealis Updating Feature
This commit is contained in:
parent
4e7c5a1b85
commit
e71b845c9a
85
Borealis.ps1
85
Borealis.ps1
@ -22,51 +22,6 @@
|
|||||||
# Change the Windows OEM code page to 65001 (UTF-8)
|
# Change the Windows OEM code page to 65001 (UTF-8)
|
||||||
chcp.com 65001 > $null
|
chcp.com 65001 > $null
|
||||||
|
|
||||||
# ---------------------- Version Check ----------------------
|
|
||||||
$localVersionFile = Join-Path $scriptDir "Data\version.txt"
|
|
||||||
$remoteVersionUrl = "https://git.bunny-lab.io/Borealis/Borealis/raw/branch/main/Data/version.txt"
|
|
||||||
|
|
||||||
$localVersion = "0.000"
|
|
||||||
$remoteVersion = "ERROR"
|
|
||||||
|
|
||||||
# Get local version
|
|
||||||
if (Test-Path $localVersionFile) {
|
|
||||||
try {
|
|
||||||
$localVersion = (Get-Content $localVersionFile -Raw).Trim()
|
|
||||||
} catch {
|
|
||||||
Write-Host "Failed to read local version file." -ForegroundColor Red
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Write-Host "Local version file not found at: $localVersionFile" -ForegroundColor Yellow
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get remote version
|
|
||||||
try {
|
|
||||||
$remoteVersion = (Invoke-WebRequest -Uri $remoteVersionUrl -UseBasicParsing -TimeoutSec 5).Content.Trim()
|
|
||||||
} catch {
|
|
||||||
Write-Host "Failed to fetch remote version. Check URL or network connection." -ForegroundColor Red
|
|
||||||
}
|
|
||||||
|
|
||||||
# Show diagnostics
|
|
||||||
Write-Host "Local: [$localVersion]"
|
|
||||||
Write-Host "Remote: [$remoteVersion]"
|
|
||||||
Write-Host "Equal? " + ($remoteVersion -eq $localVersion)
|
|
||||||
Write-Host "Length Local: $($localVersion.Length)"
|
|
||||||
Write-Host "Length Remote: $($remoteVersion.Length)"
|
|
||||||
|
|
||||||
# Determine display
|
|
||||||
if ($remoteVersion -ne $localVersion -and $remoteVersion -ne "ERROR") {
|
|
||||||
$versionColor = "Green"
|
|
||||||
$versionDisplay = "New Version: $remoteVersion"
|
|
||||||
} elseif ($remoteVersion -eq "ERROR") {
|
|
||||||
$versionColor = "Red"
|
|
||||||
$versionDisplay = "Version Check Failed"
|
|
||||||
} else {
|
|
||||||
$versionColor = "DarkGray"
|
|
||||||
$versionDisplay = "Up-to-Date"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------- Common Initialization & Visuals ----------------------
|
# ---------------------- Common Initialization & Visuals ----------------------
|
||||||
Clear-Host
|
Clear-Host
|
||||||
|
|
||||||
@ -148,7 +103,7 @@ Write-Host " 3) Build Electron App " -NoNewline -ForegroundColor DarkGray
|
|||||||
Write-Host "[Experimental]" -ForegroundColor Red
|
Write-Host "[Experimental]" -ForegroundColor Red
|
||||||
Write-Host " 4) Package Self-Contained EXE of Server or Agent " -NoNewline -ForegroundColor DarkGray
|
Write-Host " 4) Package Self-Contained EXE of Server or Agent " -NoNewline -ForegroundColor DarkGray
|
||||||
Write-Host "[Experimental]" -ForegroundColor Red
|
Write-Host "[Experimental]" -ForegroundColor Red
|
||||||
Write-Host " 5) Update Borealis ($versionDisplay)" -ForegroundColor $versionColor
|
Write-Host " 5) Update Borealis" -ForegroundColor DarkGray
|
||||||
Write-Host "Type a number and press " -NoNewLine
|
Write-Host "Type a number and press " -NoNewLine
|
||||||
Write-Host "<ENTER>" -ForegroundColor DarkCyan
|
Write-Host "<ENTER>" -ForegroundColor DarkCyan
|
||||||
$choice = Read-Host
|
$choice = Read-Host
|
||||||
@ -388,29 +343,28 @@ switch ($choice) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
"5" {
|
"5" {
|
||||||
if ($remoteVersion -eq $localVersion) {
|
Write-Host " "
|
||||||
Write-Host "Borealis is already up-to-date." -ForegroundColor Gray
|
Write-Host "Updating Borealis..." -ForegroundColor Green
|
||||||
Exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Updating Borealis to version $remoteVersion..." -ForegroundColor Cyan
|
|
||||||
|
|
||||||
# Prepare paths
|
# Prepare paths
|
||||||
$updateZip = Join-Path $scriptDir "Update_Staging\main.zip"
|
$updateZip = Join-Path $scriptDir "Update_Staging\main.zip"
|
||||||
$updateDir = Join-Path $scriptDir "Update_Staging\borealis"
|
$updateDir = Join-Path $scriptDir "Update_Staging\borealis"
|
||||||
|
|
||||||
# Delete old directories/files
|
# Delete old directories/files
|
||||||
|
Run-Step "Updating: Clean Up Folders to Prepare for Update" {
|
||||||
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue `
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue `
|
||||||
(Join-Path $scriptDir "Data"), `
|
(Join-Path $scriptDir "Data"), `
|
||||||
(Join-Path $scriptDir "Server\web-interface\src"), `
|
(Join-Path $scriptDir "Server\web-interface\src"), `
|
||||||
(Join-Path $scriptDir "Server\web-interface\build"), `
|
(Join-Path $scriptDir "Server\web-interface\build"), `
|
||||||
(Join-Path $scriptDir "Server\web-interface\public"), `
|
(Join-Path $scriptDir "Server\web-interface\public"), `
|
||||||
(Join-Path $scriptDir "Update_Staging") # Clear out Previous Update Staging Folder
|
(Join-Path $scriptDir "Server\Borealis")
|
||||||
|
|
||||||
# Backup launchers
|
# Backup launchers
|
||||||
Rename-Item -ErrorAction SilentlyContinue (Join-Path $scriptDir "Launch-Borealis.ps1") "Launch-Borealis.ps1.bak"
|
#Rename-Item -ErrorAction SilentlyContinue (Join-Path $scriptDir "Launch-Borealis.ps1") "Launch-Borealis.ps1.bak"
|
||||||
Rename-Item -ErrorAction SilentlyContinue (Join-Path $scriptDir "Launch-Borealis.sh") "Launch-Borealis.sh.bak"
|
#Rename-Item -ErrorAction SilentlyContinue (Join-Path $scriptDir "Launch-Borealis.sh") "Launch-Borealis.sh.bak"
|
||||||
|
}
|
||||||
|
|
||||||
|
Run-Step "Updating: Creating Update Staging Folder" {
|
||||||
# Ensure staging folder exists
|
# Ensure staging folder exists
|
||||||
$stagingPath = Join-Path $scriptDir "Update_Staging"
|
$stagingPath = Join-Path $scriptDir "Update_Staging"
|
||||||
if (-not (Test-Path $stagingPath)) {
|
if (-not (Test-Path $stagingPath)) {
|
||||||
@ -419,20 +373,27 @@ switch ($choice) {
|
|||||||
|
|
||||||
$updateZip = Join-Path $stagingPath "main.zip"
|
$updateZip = Join-Path $stagingPath "main.zip"
|
||||||
$updateDir = Join-Path $stagingPath "borealis"
|
$updateDir = Join-Path $stagingPath "borealis"
|
||||||
|
}
|
||||||
|
|
||||||
# Now download safely
|
Run-Step "Updating: Download Update from https://git.bunny-lab.io/Borealis/Borealis/archive/main.zip" {
|
||||||
Invoke-WebRequest -Uri "https://git.bunny-lab.io/Borealis/Borealis/archive/main.zip" -OutFile $updateZip
|
Invoke-WebRequest -Uri "https://git.bunny-lab.io/Borealis/Borealis/archive/main.zip" -OutFile $updateZip
|
||||||
|
}
|
||||||
|
|
||||||
|
Run-Step "Updating: Extract Update Files" {
|
||||||
# Download & Extract Update
|
|
||||||
Invoke-WebRequest -Uri "https://git.bunny-lab.io/Borealis/Borealis/archive/main.zip" -OutFile $updateZip
|
|
||||||
Expand-Archive -Path $updateZip -DestinationPath (Join-Path $scriptDir "Update_Staging") -Force
|
Expand-Archive -Path $updateZip -DestinationPath (Join-Path $scriptDir "Update_Staging") -Force
|
||||||
|
}
|
||||||
|
|
||||||
# Copy update contents into project root
|
Run-Step "Updating: Copy Update Files into Production Borealis Root Folder" {
|
||||||
Copy-Item "$updateDir\*" $scriptDir -Recurse -Force
|
Copy-Item "$updateDir\*" $scriptDir -Recurse -Force
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "`nUpdate Complete! Please restart the Borealis Launch Script." -ForegroundColor Green
|
Run-Step "Updating: Clean Up Update Staging Folder" {
|
||||||
Read-Host "Press any key to close the launcher script..."
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue (Join-Path $scriptDir "Update_Staging")
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "`nUpdate Complete! Please Re-Launch the Borealis Script." -ForegroundColor Green
|
||||||
|
Read-Host "Press any key to re-launch Borealis..."
|
||||||
|
& (Join-Path $scriptDir "Borealis.ps1")
|
||||||
Exit 0
|
Exit 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user