·5 min read
A Jellyfin image that finishes its own setup wizard from the start script
A new Jellyfin server has one dangerous minute. It boots, listens on a public port, and shows a setup wizard that will make whoever clicks first the administrator. On a hosting panel, where the port is handed out by an allocation and the person who created the server might not open the page for an hour, that is not a detail I wanted to leave to luck.
- Project
- Pterodactyl Yolks
- Date
- Oct 2026
- Stack
- bash, Docker, Jellyfin, Pterodactyl Wings
- Commit
- 3dcef72
The image, briefly
The image in jellyfin/ is the official portable build (self-contained .NET, jellyfin-web included) plus the portable jellyfin-ffmpeg, on debian:bookworm-slim. Everything the server writes goes under /home/container: data, config, cache, logs and the media folder. That is the convention for every image in the repo, because Wings mounts that directory as the server volume.
Jellyfin does not take its HTTP port from the command line. It takes it from network.xml in the config directory. So the first job of jellyfin-start is to make that file agree with SERVER_PORT:
NET="$JELLYFIN_CONFIG_DIR/network.xml"
if [[ -f "$NET" ]] && grep -q '<InternalHttpPort>' "$NET"; then
sed -i -e "s|<InternalHttpPort>[0-9]*</InternalHttpPort>|<InternalHttpPort>${PORT}</InternalHttpPort>|" \
-e "s|<PublicHttpPort>[0-9]*</PublicHttpPort>|<PublicHttpPort>${PORT}</PublicHttpPort>|" \
-e "s|<AutoDiscovery>true</AutoDiscovery>|<AutoDiscovery>false</AutoDiscovery>|" \
-e "s|<EnableUPnP>true</EnableUPnP>|<EnableUPnP>false</EnableUPnP>|" "$NET"
else
# write a minimal network.xml with the same four settings
fiIf the file exists, only those four values are touched, so anything the user changed in the dashboard survives a restart. If it does not exist, the script writes a minimal one. Auto discovery and UPnP are switched off because a container with one TCP allocation has nothing to discover and nothing to map.
Closing the wizard window
The part I care about is the next function. It is started with finish_wizard & just before exec replaces the shell with Jellyfin, so it runs next to the server instead of blocking its start:
finish_wizard() {
local base="http://127.0.0.1:${PORT}" info i
for i in $(seq 1 180); do
info=$(curl -fsS "$base/System/Info/Public" 2>/dev/null) && break
sleep 2
done
[[ -n "${info:-}" ]] || { say "Renode: Jellyfin did not answer, setup wizard left as it is."; return; }
grep -q '"StartupWizardCompleted":false' <<<"$info" || return 0
...
}It polls /System/Info/Public every two seconds for up to 180 tries, so up to six minutes, which covers a slow first boot on a small allocation. If the server never answers, it leaves the wizard alone and prints one line saying so. If the public info says StartupWizardCompleted is not false, it returns immediately. That check is what makes the function safe to run on every start: on the second boot it costs one request and does nothing.
When the wizard is open, the script walks the same endpoints the web wizard uses: /Startup/Configuration for language and country, /Startup/User to create the administrator from JELLYFIN_ADMIN_USER and JELLYFIN_ADMIN_PASSWORD, /Startup/RemoteAccess with automatic port mapping off, and finally POST /Startup/Complete. The script itself says in its header what the password is for: the variable is only read while the wizard is open, and the owner should change the password inside Jellyfin afterwards.
The empty password branch
The decision I spent the most time on was what to do without a password. The script does this:
if [[ -z "$pass" ]]; then
say "Renode: JELLYFIN_ADMIN_PASSWORD is empty, finish the setup wizard in the browser."
return
fiI did not want a built-in default account, because a default password on a public port is the same hole as the open wizard, just with extra steps. So the behavior is explicit: with a password, the server is never open; without one, the person is told in the console that the wizard is waiting for them. The panel console is where they are already looking when a server starts.
Libraries without a second request from the user
After the wizard, the script authenticates through /Users/AuthenticateByName with a client header, takes the access token with a sed expression, and creates three libraries through /Library/VirtualFolders: Movies, Shows and Music, pointing at media/movies, media/shows and media/music under the server volume. Then it logs the session out. The library and logout calls end in || true, and an empty token returns early, so a library failure never stops the rest; the function runs in the background anyway, so it cannot take the server down. The server is already usable by then, and the worst result is that someone adds the folders by hand.
Other choices in the same commit
The Dockerfile sets STOPSIGNAL SIGINT and runs tini -g as the entrypoint, the same pattern as the other images. The Jellyfin version, the ffmpeg version and the architecture are build arguments, and the build ends with ffmpeg -version | head -1 and test -x /opt/jellyfin/jellyfin, so a bad download fails the image build instead of failing at runtime on someone's panel.
What I would take from this
A start script is the only place where you know both the allocation and the lifecycle, so it is the right place to close a first-run gap. Three rules kept the function honest: it checks the real server state before acting, it does nothing when it lacks the one secret it needs, and everything after the essential step is best effort. I did not measure how long the wizard step takes in practice, so I will not quote a number; the six minute ceiling is simply the loop bound in the code.
#docker#bash#jellyfin#pterodactyl#security
Keep reading
Have a project in mind?