Refactor BetterDesk PowerShell and Dockerfile

Major refactor of betterdesk.ps1: convert to modern PowerShell script with Param/Help, enforce RunAsAdministrator, introduce script-scoped variables, structured logging, Print-* helper functions, auto-mode handling, public IP and password helpers, improved path detection and defaults, binary verification (Verify-*), dependency installation, venv setup for the web console, service setup using NSSM with scheduled-task fallback, and database migration/initialization logic. UI and status output were cleaned up and many functions renamed for clarity. Dockerfile.console: make resolv.conf DNS edits conditional (skip on read-only / Oracle Cloud VCNs) to avoid modifying immutable resolv.conf. .github/copilot-instructions.md: update project status date. These changes improve robustness, non-interactive automation, and Windows service management for BetterDesk.
This commit is contained in:
UNITRONIX
2026-02-11 23:04:28 +01:00
parent d524e9268a
commit 59216f7620
5 changed files with 1683 additions and 1284 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
---
## 📊 Stan Projektu (aktualizacja: 2026-02-08)
## 📊 Stan Projektu (aktualizacja: 2026-02-11)
### Wersja Skryptów ALL-IN-ONE (v2.1.1)
+5 -2
View File
@@ -6,8 +6,11 @@ WORKDIR /app
# Install system dependencies with DNS fallback for systems with resolver issues
# This fixes "Temporary failure resolving 'deb.debian.org'" on some systems (e.g., AlmaLinux)
RUN echo "nameserver 8.8.8.8" >> /etc/resolv.conf && \
echo "nameserver 1.1.1.1" >> /etc/resolv.conf && \
# Skip DNS modification on Oracle Cloud VMs (oraclevcn) and read-only resolv.conf
RUN if [ -w /etc/resolv.conf ] && ! grep -q "oraclevcn" /etc/resolv.conf 2>/dev/null; then \
echo "nameserver 8.8.8.8" >> /etc/resolv.conf; \
echo "nameserver 1.1.1.1" >> /etc/resolv.conf; \
fi && \
apt-get update && apt-get install -y \
sqlite3 \
curl \
+1284 -1009
View File
File diff suppressed because it is too large Load Diff
+346 -272
View File
@@ -1,112 +1,145 @@
# =============================================================================
# BetterDesk Server - Interactive Build Script (Windows)
# =============================================================================
# This script automates building BetterDesk enhanced binaries from source.
# It handles downloading RustDesk sources, applying BetterDesk modifications,
# and compiling the final binaries.
#
# Usage:
# .\build-betterdesk.ps1 # Interactive mode
# .\build-betterdesk.ps1 -Auto # Non-interactive (use defaults)
# .\build-betterdesk.ps1 -Clean # Clean build directory
# .\build-betterdesk.ps1 -Help # Show help
#
# Requirements:
# - Rust toolchain (rustup)
# - Visual Studio Build Tools with C++ support
# - Git
# =============================================================================
<#
.SYNOPSIS
BetterDesk Server - Interactive Build Script for Windows
.DESCRIPTION
This script automates building BetterDesk enhanced binaries from source.
It handles downloading RustDesk sources, applying BetterDesk modifications,
and compiling the final binaries.
.PARAMETER Auto
Non-interactive mode (use default settings)
.PARAMETER Clean
Clean build directory and exit
.PARAMETER Version
Specify RustDesk version (default: 1.1.14)
.EXAMPLE
.\build-betterdesk.ps1
Interactive build
.EXAMPLE
.\build-betterdesk.ps1 -Auto
Build with defaults
.EXAMPLE
.\build-betterdesk.ps1 -Version 1.1.15
Build specific version
#>
param(
[switch]$Auto,
[switch]$Clean,
[string]$Version = "",
[string]$Platform = "",
[switch]$Help
)
$ErrorActionPreference = "Stop"
# ============================================================================
# Configuration
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$BuildDir = Join-Path $ScriptDir "build"
$PatchesDir = Join-Path $ScriptDir "hbbs-patch-v2\src"
$OutputDir = Join-Path $ScriptDir "hbbs-patch-v2"
# ============================================================================
# Default RustDesk version
$DefaultRustDeskVersion = "1.1.14"
$RustDeskRepo = "https://github.com/rustdesk/rustdesk-server.git"
$Script:ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$Script:BuildDir = Join-Path $Script:ScriptDir "build"
$Script:PatchesDir = Join-Path $Script:ScriptDir "hbbs-patch-v2\src"
$Script:OutputDir = Join-Path $Script:ScriptDir "hbbs-patch-v2"
# State
$RustDeskVersion = $DefaultRustDeskVersion
$TargetPlatform = "windows-x64"
$Script:DefaultRustDeskVersion = "1.1.14"
$Script:RustDeskRepo = "https://github.com/rustdesk/rustdesk-server.git"
# =============================================================================
$Script:RustDeskVersion = ""
$Script:TargetPlatform = "windows-x64"
# ============================================================================
# Helper Functions
# =============================================================================
# ============================================================================
function Write-Header {
param([string]$Message)
param([string]$Title)
Write-Host ""
Write-Host "╔══════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host " $Message" -ForegroundColor Cyan
Write-Host "╚══════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
Write-Host " ========================================================" -ForegroundColor Cyan
Write-Host " $Title" -ForegroundColor Cyan
Write-Host " ========================================================" -ForegroundColor Cyan
Write-Host ""
}
function Write-Success { param([string]$Msg) Write-Host "$Msg" -ForegroundColor Green }
function Write-Error2 { param([string]$Msg) Write-Host "$Msg" -ForegroundColor Red }
function Write-Warning2 { param([string]$Msg) Write-Host "$Msg" -ForegroundColor Yellow }
function Write-Info { param([string]$Msg) Write-Host " $Msg" -ForegroundColor Blue }
function Write-Step { param([string]$Msg) Write-Host "$Msg" -ForegroundColor Cyan }
function Write-Success {
param([string]$Message)
Write-Host "[OK] " -ForegroundColor Green -NoNewline
Write-Host $Message
}
function Show-Help {
Write-Host "BetterDesk Server - Build Script (Windows)"
function Write-Error2 {
param([string]$Message)
Write-Host "[ERROR] " -ForegroundColor Red -NoNewline
Write-Host $Message
}
function Write-Warning2 {
param([string]$Message)
Write-Host "[WARNING] " -ForegroundColor Yellow -NoNewline
Write-Host $Message
}
function Write-Info {
param([string]$Message)
Write-Host "[INFO] " -ForegroundColor Blue -NoNewline
Write-Host $Message
}
function Write-Step {
param([string]$Message)
Write-Host ">> " -ForegroundColor Magenta -NoNewline
Write-Host $Message
}
function Show-HelpMessage {
Write-Host "BetterDesk Server - Build Script"
Write-Host ""
Write-Host "Usage: .\build-betterdesk.ps1 [OPTIONS]"
Write-Host ""
Write-Host "Options:"
Write-Host " -Auto Non-interactive mode (use default settings)"
Write-Host " -Clean Clean build directory and exit"
Write-Host " -Version VER Specify RustDesk version (default: $DefaultRustDeskVersion)"
Write-Host " -Platform PLT Target platform: windows-x64, linux-x64"
Write-Host " -Version VER Specify RustDesk version (default: $Script:DefaultRustDeskVersion)"
Write-Host " -Help Show this help message"
Write-Host ""
Write-Host "Examples:"
Write-Host " .\build-betterdesk.ps1 # Interactive build"
Write-Host " .\build-betterdesk.ps1 -Auto # Build with defaults"
Write-Host " .\build-betterdesk.ps1 -Version 1.1.15 # Build specific version"
Write-Host " .\build-betterdesk.ps1 # Interactive build"
Write-Host " .\build-betterdesk.ps1 -Auto # Build with defaults"
Write-Host " .\build-betterdesk.ps1 -Version 1.1.15 # Build specific version"
Write-Host ""
}
# =============================================================================
# ============================================================================
# Dependency Checks
# =============================================================================
# ============================================================================
function Test-Dependencies {
function Check-Dependencies {
Write-Header "Checking Dependencies"
$missing = 0
# Check Rust
$cargo = Get-Command cargo -ErrorAction SilentlyContinue
if ($cargo) {
$cargoCmd = Get-Command cargo -ErrorAction SilentlyContinue
if ($cargoCmd) {
$rustVersion = & rustc --version 2>&1
Write-Success "Rust/Cargo: $rustVersion"
} else {
Write-Error2 "Rust/Cargo not found"
Write-Host " Install from: https://rustup.rs/"
Write-Host " Install from: https://rustup.rs"
$missing++
}
# Check Git
$git = Get-Command git -ErrorAction SilentlyContinue
if ($git) {
$gitCmd = Get-Command git -ErrorAction SilentlyContinue
if ($gitCmd) {
$gitVersion = & git --version 2>&1
Write-Success "Git: $gitVersion"
} else {
Write-Error2 "Git not found"
Write-Host " Install from: https://git-scm.com/"
Write-Host " Install from: https://git-scm.com/download/win"
$missing++
}
@@ -117,33 +150,43 @@ function Test-Dependencies {
if ($vsPath) {
Write-Success "Visual Studio Build Tools found"
} else {
Write-Warning2 "Visual Studio C++ Build Tools may not be installed"
Write-Host " Install from: https://visualstudio.microsoft.com/visual-cpp-build-tools/"
Write-Warning2 "Visual Studio C++ tools may not be installed"
Write-Host " Install Visual Studio Build Tools with C++ support"
}
} else {
Write-Warning2 "Could not verify Visual Studio Build Tools"
Write-Warning2 "vswhere not found - cannot verify Visual Studio"
}
# Check CMake (optional but helpful)
$cmakeCmd = Get-Command cmake -ErrorAction SilentlyContinue
if ($cmakeCmd) {
$cmakeVersion = & cmake --version 2>&1 | Select-Object -First 1
Write-Success "CMake: $cmakeVersion"
} else {
Write-Info "CMake not found (optional for some builds)"
}
if ($missing -gt 0) {
Write-Host ""
Write-Error2 "Missing dependencies. Please install them first."
Write-Host ""
Write-Host "Required:"
Write-Host " 1. Rust: https://rustup.rs/"
Write-Host " 2. Git: https://git-scm.com/"
Write-Host " 3. Visual Studio Build Tools with C++ support"
Write-Host "Quick install:" -ForegroundColor Yellow
Write-Host " 1. Install Rust from https://rustup.rs"
Write-Host " 2. Install Git from https://git-scm.com/download/win"
Write-Host " 3. Install Visual Studio Build Tools with C++ workload"
Write-Host ""
exit 1
return $false
}
Write-Success "All dependencies satisfied!"
return $true
}
# =============================================================================
# ============================================================================
# Interactive Configuration
# =============================================================================
# ============================================================================
function Get-Configuration {
function Interactive-Config {
Write-Header "Build Configuration"
# Select RustDesk version
@@ -154,52 +197,36 @@ function Get-Configuration {
Write-Host ""
if ($Auto) {
$script:RustDeskVersion = $DefaultRustDeskVersion
Write-Info "Auto mode: Using version $RustDeskVersion"
} elseif ($Version) {
$script:RustDeskVersion = $Version
$Script:RustDeskVersion = $Script:DefaultRustDeskVersion
Write-Info "Auto mode: Using version $Script:RustDeskVersion"
} else {
$choice = Read-Host "Select version [1]"
switch ($choice) {
"2" { $script:RustDeskVersion = "1.1.13" }
"3" { $script:RustDeskVersion = Read-Host "Enter version (e.g., 1.1.15)" }
default { $script:RustDeskVersion = $DefaultRustDeskVersion }
$versionChoice = Read-Host "Select version [1]"
switch ($versionChoice) {
"2" { $Script:RustDeskVersion = "1.1.13" }
"3" {
$Script:RustDeskVersion = Read-Host "Enter version (e.g., 1.1.15)"
}
default { $Script:RustDeskVersion = $Script:DefaultRustDeskVersion }
}
}
Write-Success "Selected RustDesk version: $RustDeskVersion"
Write-Success "Selected RustDesk version: $Script:RustDeskVersion"
Write-Host ""
# Select target platform
Write-Host "Target platform:" -ForegroundColor White
Write-Host " 1) Windows x86_64 (native)"
Write-Host " 2) Linux x86_64 (cross-compile, requires WSL)"
Write-Host ""
if ($Auto) {
$script:TargetPlatform = "windows-x64"
Write-Info "Auto mode: Building for $TargetPlatform"
} elseif ($Platform) {
$script:TargetPlatform = $Platform
} else {
$choice = Read-Host "Select platform [1]"
switch ($choice) {
"2" { $script:TargetPlatform = "linux-x64" }
default { $script:TargetPlatform = "windows-x64" }
}
}
Write-Success "Target platform: $TargetPlatform"
# Target platform is always Windows x64 on Windows
$Script:TargetPlatform = "windows-x64"
Write-Success "Target platform: $Script:TargetPlatform"
Write-Host ""
# Confirm
if (-not $Auto) {
Write-Host "Build Summary:" -ForegroundColor White
Write-Host " RustDesk Version: $RustDeskVersion"
Write-Host " Target Platform: $TargetPlatform"
Write-Host " Build Directory: $BuildDir"
Write-Host " Output Directory: $OutputDir"
Write-Host " RustDesk Version: $Script:RustDeskVersion"
Write-Host " Target Platform: $Script:TargetPlatform"
Write-Host " Build Directory: $Script:BuildDir"
Write-Host " Output Directory: $Script:OutputDir"
Write-Host ""
$confirm = Read-Host "Continue with build? [Y/n]"
if ($confirm -match "^[Nn]$") {
Write-Host "Build cancelled."
@@ -208,14 +235,14 @@ function Get-Configuration {
}
}
# =============================================================================
# ============================================================================
# Download RustDesk Sources
# =============================================================================
# ============================================================================
function Get-RustDeskSources {
function Download-RustDesk {
Write-Header "Downloading RustDesk Server Sources"
$sourceDir = Join-Path $BuildDir "rustdesk-server-$RustDeskVersion"
$sourceDir = Join-Path $Script:BuildDir "rustdesk-server-$Script:RustDeskVersion"
if (Test-Path $sourceDir) {
Write-Info "Source directory exists: $sourceDir"
@@ -224,259 +251,306 @@ function Get-RustDeskSources {
$redownload = Read-Host "Re-download sources? [y/N]"
if ($redownload -notmatch "^[Yy]$") {
Write-Success "Using existing sources"
return
return $true
}
} else {
Write-Info "Auto mode: Using existing sources"
return
return $true
}
Remove-Item $sourceDir -Recurse -Force
Remove-Item -Path $sourceDir -Recurse -Force
}
if (-not (Test-Path $BuildDir)) {
New-Item -ItemType Directory -Path $BuildDir | Out-Null
if (-not (Test-Path $Script:BuildDir)) {
New-Item -ItemType Directory -Path $Script:BuildDir -Force | Out-Null
}
Push-Location $BuildDir
Push-Location $Script:BuildDir
Write-Step "Cloning rustdesk-server repository..."
& git clone --depth 1 --branch $RustDeskVersion $RustDeskRepo "rustdesk-server-$RustDeskVersion"
Set-Location "rustdesk-server-$RustDeskVersion"
Write-Step "Initializing submodules..."
& git submodule update --init --recursive
Pop-Location
Write-Success "RustDesk sources downloaded successfully"
try {
Write-Step "Cloning rustdesk-server repository..."
& git clone --depth 1 --branch $Script:RustDeskVersion $Script:RustDeskRepo "rustdesk-server-$Script:RustDeskVersion" 2>&1
Set-Location "rustdesk-server-$Script:RustDeskVersion"
Write-Step "Initializing submodules..."
& git submodule update --init --recursive 2>&1
Write-Success "RustDesk sources downloaded successfully"
return $true
} catch {
Write-Error2 "Failed to download sources: $_"
return $false
} finally {
Pop-Location
}
}
# =============================================================================
# ============================================================================
# Apply BetterDesk Modifications
# =============================================================================
# ============================================================================
function Apply-Modifications {
Write-Header "Applying BetterDesk Modifications"
$sourceDir = Join-Path $BuildDir "rustdesk-server-$RustDeskVersion"
$sourceDir = Join-Path $Script:BuildDir "rustdesk-server-$Script:RustDeskVersion"
if (-not (Test-Path $sourceDir)) {
Write-Error2 "Source directory not found: $sourceDir"
exit 1
return $false
}
Push-Location $sourceDir
# List of files to copy from patches
$patchFiles = @(
"main.rs",
"http_api.rs",
"database.rs",
"database_fixed.rs",
"peer.rs",
"peer_fixed.rs",
"rendezvous_server_core.rs"
)
Write-Step "Copying BetterDesk modifications..."
foreach ($file in $patchFiles) {
$patchPath = Join-Path $PatchesDir $file
if (Test-Path $patchPath) {
$targetPath = Join-Path "src" $file
Copy-Item $patchPath $targetPath -Force
Write-Success "Applied: $file"
} else {
Write-Warning2 "Patch file not found: $file"
try {
# List of files to copy from patches
$patchFiles = @(
"main.rs",
"http_api.rs",
"database.rs",
"database_fixed.rs",
"peer.rs",
"peer_fixed.rs",
"rendezvous_server_core.rs"
)
Write-Step "Copying BetterDesk modifications..."
foreach ($file in $patchFiles) {
$srcPath = Join-Path $Script:PatchesDir $file
if (Test-Path $srcPath) {
switch ($file) {
"main.rs" {
Copy-Item -Path $srcPath -Destination "src\main.rs" -Force
Write-Success "Applied: main.rs (HTTP API integration)"
}
"http_api.rs" {
Copy-Item -Path $srcPath -Destination "src\http_api.rs" -Force
Write-Success "Applied: http_api.rs (REST API module)"
}
default {
Copy-Item -Path $srcPath -Destination "src\$file" -Force
Write-Success "Applied: $file"
}
}
} else {
Write-Warning2 "Patch file not found: $file"
}
}
# Update Cargo.toml if needed
Write-Step "Checking Cargo.toml dependencies..."
$cargoPath = "Cargo.toml"
$cargoContent = Get-Content $cargoPath -Raw
if ($cargoContent -notmatch "axum") {
Write-Info "Adding HTTP API dependencies to Cargo.toml..."
# This is a simplified approach - may need manual adjustment
Write-Warning2 "Please verify Cargo.toml has required dependencies (axum, chrono)"
} else {
Write-Info "Cargo.toml already has required dependencies"
}
Write-Success "BetterDesk modifications applied successfully"
return $true
} catch {
Write-Error2 "Failed to apply modifications: $_"
return $false
} finally {
Pop-Location
}
Pop-Location
Write-Success "BetterDesk modifications applied successfully"
}
# =============================================================================
# ============================================================================
# Build Binaries
# =============================================================================
# ============================================================================
function Build-Binaries {
Write-Header "Building BetterDesk Binaries"
$sourceDir = Join-Path $BuildDir "rustdesk-server-$RustDeskVersion"
$sourceDir = Join-Path $Script:BuildDir "rustdesk-server-$Script:RustDeskVersion"
Push-Location $sourceDir
$targetFlag = ""
$binarySuffix = "-windows-x86_64.exe"
if ($TargetPlatform -eq "linux-x64") {
Write-Step "Setting up Linux cross-compilation..."
& rustup target add x86_64-unknown-linux-gnu
$targetFlag = "--target x86_64-unknown-linux-gnu"
$binarySuffix = "-linux-x86_64"
}
Write-Step "Building HBBS (Signal Server)..."
if ($targetFlag) {
& cargo build --release $targetFlag -p hbbs
} else {
& cargo build --release -p hbbs
}
Write-Step "Building HBBR (Relay Server)..."
if ($targetFlag) {
& cargo build --release $targetFlag -p hbbr
} else {
& cargo build --release -p hbbr
}
# Find binaries
$targetDir = "target\release"
if ($targetFlag) {
$targetDir = "target\$($targetFlag -replace '--target ','')\release"
}
$hbbsBinary = Join-Path $targetDir "hbbs.exe"
$hbbrBinary = Join-Path $targetDir "hbbr.exe"
if ($TargetPlatform -eq "linux-x64") {
$hbbsBinary = Join-Path $targetDir "hbbs"
$hbbrBinary = Join-Path $targetDir "hbbr"
}
if (-not (Test-Path $hbbsBinary) -or -not (Test-Path $hbbrBinary)) {
Write-Error2 "Build failed - binaries not found"
try {
Write-Step "Building HBBS (Signal Server)..."
$result = & cargo build --release 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Error2 "Build failed!"
Write-Host $result
return $false
}
# Check for binaries
$hbbsBinary = "target\release\hbbs.exe"
$hbbrBinary = "target\release\hbbr.exe"
if (-not (Test-Path $hbbsBinary) -or -not (Test-Path $hbbrBinary)) {
Write-Error2 "Build failed - binaries not found"
return $false
}
Write-Success "Build completed successfully!"
# Copy to output directory
Write-Step "Copying binaries to output directory..."
if (-not (Test-Path $Script:OutputDir)) {
New-Item -ItemType Directory -Path $Script:OutputDir -Force | Out-Null
}
$hbbsDst = Join-Path $Script:OutputDir "hbbs-windows-x86_64.exe"
$hbbrDst = Join-Path $Script:OutputDir "hbbr-windows-x86_64.exe"
Copy-Item -Path $hbbsBinary -Destination $hbbsDst -Force
Copy-Item -Path $hbbrBinary -Destination $hbbrDst -Force
Write-Success "Binaries saved to:"
Write-Host " - $hbbsDst"
Write-Host " - $hbbrDst"
return $true
} catch {
Write-Error2 "Build error: $_"
return $false
} finally {
Pop-Location
exit 1
}
Write-Success "Build completed successfully!"
# Copy to output directory
Write-Step "Copying binaries to output directory..."
$hbbsOutput = Join-Path $OutputDir "hbbs$binarySuffix"
$hbbrOutput = Join-Path $OutputDir "hbbr$binarySuffix"
Copy-Item $hbbsBinary $hbbsOutput -Force
Copy-Item $hbbrBinary $hbbrOutput -Force
Pop-Location
Write-Success "Binaries saved to:"
Write-Host " - $hbbsOutput"
Write-Host " - $hbbrOutput"
}
# =============================================================================
# ============================================================================
# Generate Checksums
# =============================================================================
# ============================================================================
function New-Checksums {
function Generate-Checksums {
Write-Header "Generating Checksums"
$checksumsFile = Join-Path $OutputDir "CHECKSUMS.md"
$dateNow = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Push-Location $Script:OutputDir
$content = @"
try {
$checksumFile = "CHECKSUMS.md"
$dateNow = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$content = @"
# BetterDesk Server - Binary Checksums
Generated: $dateNow
RustDesk Base Version: $RustDeskVersion
RustDesk Base Version: $Script:RustDeskVersion
BetterDesk Version: 2.0.0
## SHA256 Checksums
``````
"@
Get-ChildItem $OutputDir -Filter "hbbs-*" | ForEach-Object {
$hash = (Get-FileHash $_.FullName -Algorithm SHA256).Hash
$content += "$hash $($_.Name)`n"
$binaries = Get-ChildItem -Filter "hbbs-*" -File
$binaries += Get-ChildItem -Filter "hbbr-*" -File
foreach ($binary in $binaries) {
$hash = (Get-FileHash -Path $binary.FullName -Algorithm SHA256).Hash
$content += "$hash $($binary.Name)`n"
}
$content += "```"
$content | Out-File -FilePath $checksumFile -Encoding UTF8
Write-Success "Checksums saved to: $Script:OutputDir\$checksumFile"
} catch {
Write-Warning2 "Could not generate checksums: $_"
} finally {
Pop-Location
}
Get-ChildItem $OutputDir -Filter "hbbr-*" | ForEach-Object {
$hash = (Get-FileHash $_.FullName -Algorithm SHA256).Hash
$content += "$hash $($_.Name)`n"
}
$content += "``````"
$content | Out-File $checksumsFile -Encoding UTF8
Write-Success "Checksums saved to: $checksumsFile"
}
# =============================================================================
# ============================================================================
# Clean Build
# =============================================================================
# ============================================================================
function Clear-Build {
function Clean-Build {
Write-Header "Cleaning Build Directory"
if (Test-Path $BuildDir) {
Write-Step "Removing: $BuildDir"
Remove-Item $BuildDir -Recurse -Force
if (Test-Path $Script:BuildDir) {
Write-Step "Removing: $Script:BuildDir"
Remove-Item -Path $Script:BuildDir -Recurse -Force
Write-Success "Build directory cleaned"
} else {
Write-Info "Build directory does not exist"
}
}
# =============================================================================
# ============================================================================
# Main
# =============================================================================
# ============================================================================
function Main {
# Handle help
# Show help
if ($Help) {
Show-Help
Show-HelpMessage
exit 0
}
# Handle clean mode
# Clean mode
if ($Clean) {
Clear-Build
Clean-Build
exit 0
}
# Banner
# Use provided version or default
if ($Version) {
$Script:RustDeskVersion = $Version
}
Write-Host ""
Write-Host "╔══════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host "║ BetterDesk Server - Build from Source (Windows) " -ForegroundColor Cyan
Write-Host "║ Enhanced RustDesk with HTTP API & Management ║" -ForegroundColor Cyan
Write-Host "╚══════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
Write-Host " ========================================================" -ForegroundColor Cyan
Write-Host " BetterDesk Server - Build Script (Windows) " -ForegroundColor Cyan
Write-Host " ========================================================" -ForegroundColor Cyan
Write-Host ""
# Run build steps
Test-Dependencies
Get-Configuration
Get-RustDeskSources
Apply-Modifications
Build-Binaries
New-Checksums
# Check dependencies
if (-not (Check-Dependencies)) {
exit 1
}
# Final message
Write-Header "Build Complete!"
# Interactive configuration
Interactive-Config
# Download sources
if (-not (Download-RustDesk)) {
exit 1
}
# Apply modifications
if (-not (Apply-Modifications)) {
exit 1
}
# Build
if (-not (Build-Binaries)) {
exit 1
}
# Generate checksums
Generate-Checksums
Write-Host "BetterDesk binaries have been built successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "Output location: $OutputDir"
Write-Success "Build process completed successfully!"
Write-Host ""
Write-Host "Next steps:"
Write-Host "Binaries are available in: $Script:OutputDir" -ForegroundColor Cyan
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Yellow
Write-Host " 1. Test the binaries:"
Write-Host " cd $OutputDir"
Write-Host " .\hbbs-windows-x86_64.exe --help"
Write-Host " .\hbbr-windows-x86_64.exe --help"
Write-Host ""
Write-Host " 2. Run the installer to deploy:"
Write-Host " .\install-improved.ps1"
Write-Host ""
Write-Host " 3. Or manually start the servers:"
Write-Host " .\hbbs-windows-x86_64.exe -k _ --api-port 21114"
Write-Host " .\hbbr-windows-x86_64.exe"
Write-Host " 2. Install using betterdesk.ps1:"
Write-Host " .\betterdesk.ps1"
Write-Host ""
}
# Run
Main
+47
View File
@@ -97,6 +97,53 @@ The BetterDesk binaries in `hbbs-patch-v2/` include:
---
## Problem: Build Fails on Oracle Cloud VM (Read-only resolv.conf)
### Symptom
```
/bin/sh: 1: cannot create /etc/resolv.conf: Read-only file system
target betterdesk-console: failed to solve: process "/bin/sh -c echo \"nameserver 8.8.8.8\" >> /etc/resolv.conf...
```
### Cause
Oracle Cloud VMs have `/etc/resolv.conf` managed by `oraclevcn` service and it's **read-only**. The Dockerfile tries to modify DNS settings which fails.
### ✅ Solution
**This is now fixed in the latest version.** The Dockerfile.console now checks if the file is writable before attempting to modify it:
```dockerfile
RUN if [ -w /etc/resolv.conf ] && ! grep -q "oraclevcn" /etc/resolv.conf 2>/dev/null; then \
echo "nameserver 8.8.8.8" >> /etc/resolv.conf; \
echo "nameserver 1.1.1.1" >> /etc/resolv.conf; \
fi && \
apt-get update && apt-get install -y ...
```
If you have an older version:
```bash
# Update to latest
git pull origin main
# Rebuild images
docker compose build --no-cache
docker compose up -d
```
**Alternative for Oracle Cloud (if DNS issues persist):**
```bash
# Configure Docker daemon to use Google DNS
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json > /dev/null <<EOF
{
"dns": ["8.8.8.8", "1.1.1.1"]
}
EOF
sudo systemctl restart docker
```
---
## Problem: DNS Failure During Build (AlmaLinux/CentOS)
### Symptom