Skip to content

A self-hosted media server and file management system

chore: add script for adding default url to hosts file

aminnausin3409a57b67e1
diff --git a/.github/workflows/ci-docker-release.yml b/.github/workflows/ci-docker-release.yml
index 4ee2d877..0c5b557b 100644
--- a/.github/workflows/ci-docker-release.yml
+++ b/.github/workflows/ci-docker-release.yml
@@ -217,7 +217,7 @@ jobs:
- name: Zip Files Windows
run: |
- zip -r mediaServerDockerWindows.zip ./docker/etc ./docker/.env.docker ./docker-compose.yaml ./startDocker.bat ./README.md ./data/*
+ zip -r mediaServerDockerWindows.zip ./docker/etc ./docker/.env.docker ./docker-compose.yaml ./startDocker.bat ./README.md ./data/* ./add-hosts-entry.ps1
- name: Cleanup temp
run: rm -rf temp
diff --git a/add-hosts-entry.ps1 b/add-hosts-entry.ps1
new file mode 100644
index 00000000..2d1c806d
--- /dev/null
+++ b/add-hosts-entry.ps1
@@ -0,0 +1,28 @@
+param (
+ [string]$Domain,
+ [string]$IPAddress = "127.0.0.1"
+)
+
+if (-not $Domain) {
+ $Domain = "app.test"
+}
+
+# Elevate if not already running as Administrator
+if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
+ Start-Process powershell "-ExecutionPolicy Bypass -File `"$PSCommandPath`" -Domain `"$Domain`" -IPAddress `"$IPAddress`"" -Verb RunAs
+ exit
+}
+
+$hostsPath = "$env:SystemRoot\System32\drivers\etc\hosts"
+
+# Check if entry already exists
+$exists = Get-Content $hostsPath | Where-Object { $_ -match "^\s*$IPAddress\s+$Domain" }
+
+if (-not $exists) {
+ Add-Content -Path $hostsPath -Value "`n$IPAddress`t$Domain"
+ Write-Host "Added $Domain to hosts file." -ForegroundColor Green
+} else {
+ Write-Host "$Domain already exists in hosts file." -ForegroundColor Cyan
+}
+
+pause > $null
diff --git a/startDocker.bat b/startDocker.bat
index dc52c7f9..a41eb961 100644
--- a/startDocker.bat
+++ b/startDocker.bat
@@ -437,7 +437,8 @@ echo.
echo Your mediaServer will be available at https://%APP_HOST% or http://127.0.0.1:%APP_PORT%
echo.
echo To add audio or video to your server, put the files in ./data/media organised by /LIBRARY/FOLDER/VIDEO.mp4
-
+echo.
+echo Make sure to run the included powershell script to add app.test to your hosts file if you did not set a domain
:end
set arg0=%0
diff --git a/startDocker.sh b/startDocker.sh
index 407485a6..43ece74b 100644
--- a/startDocker.sh
+++ b/startDocker.sh
@@ -290,3 +290,15 @@ echo
echo "Your mediaServer will be available at https://$APP_HOST or http://127.0.0.1:$APP_PORT"
echo
echo "To add audio or video to your server, put the files in ./data/media organised by /LIBRARY/FOLDER/VIDEO.mp4"
+
+if [[ "$APP_HOST" == "app.test" ]]; then
+ echo
+ echo "${YELLOW}[WARNING]${RESET} The domain '$APP_HOST' is not publicly resolvable."
+ echo "You may need to add the following line to your /etc/hosts file:"
+ echo
+ echo " 127.0.0.1 $APP_HOST"
+ echo
+ echo "Run the following command with sudo if desired:"
+ echo "echo '127.0.0.1 $APP_HOST' | sudo tee -a /etc/hosts"
+ echo
+fi