This commit is contained in:
soraefir
2026-05-14 00:12:18 +02:00
parent 3b4e7d07a4
commit 2cb8d6c24e

View File

@@ -68,19 +68,19 @@ in {
envFile = config.sops.secrets."CUSTOM".path; envFile = config.sops.secrets."CUSTOM".path;
script = pkgs.writeShellScript "setup" '' script = pkgs.writeShellScript "setup" ''
JELLYFIN_URL="http://jellyfin-server:8096" JELLYFIN_URL="http://jellyfin-server:8096"
until ${pkgs.curl} -sf "\${JELLYFIN_URL}/health" > /dev/null 2>&1; do until ${pkgs.curl} -sf "$JELLYFIN_URL/health" > /dev/null 2>&1; do
sleep 5 sleep 5
done done
echo "Jellyfin is up. Sleeping for 20 seconds..." echo "Jellyfin is up. Sleeping for 20 seconds..."
sleep 20 sleep 20
WIZARD_COMPLETE=$(${pkgs.curl}/bin/curl -sSf "\${JELLYFIN_URL}/System/Info/Public" 2>/dev/null | \ WIZARD_COMPLETE=$(${pkgs.curl}/bin/curl -sSf "$JELLYFIN_URL/System/Info/Public" 2>/dev/null | \
${pkgs.jq}/bin/jq -r '.StartupWizardCompleted // false') ${pkgs.jq}/bin/jq -r '.StartupWizardCompleted // false')
if [ "$WIZARD_COMPLETE" = "true" ]; then if [ "$WIZARD_COMPLETE" = "true" ]; then
echo "Jellyfin wizard already completed. Exiting cleanly." echo "Jellyfin wizard already completed. Exiting cleanly."
exit 0 exit 0
fi fi
if ! ${pkgs.curl}/bin/curl -sSf -X POST "''\${JELLYFIN_URL}/Startup/Configuration" \ if ! ${pkgs.curl}/bin/curl -sSf -X POST "''$JELLYFIN_URL/Startup/Configuration" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"ServerName":"jellyfin","UICulture":"en-US","MetadataCountryCode":"US","PreferredMetadataLanguage":"en"}'; then -d '{"ServerName":"jellyfin","UICulture":"en-US","MetadataCountryCode":"US","PreferredMetadataLanguage":"en"}'; then
echo "ERROR: Failed to set startup configuration." echo "ERROR: Failed to set startup configuration."
@@ -92,9 +92,9 @@ in {
--arg pass "''\${DEFAULT_ADMIN_PASSWORD}" \ --arg pass "''\${DEFAULT_ADMIN_PASSWORD}" \
'{"Name": $name, "Password": $pass}') '{"Name": $name, "Password": $pass}')
echo "Payload to be sent to /Startup/User: ''${SETUP_USER_PAYLOAD}" echo "Payload to be sent to /Startup/User: ''$SETUP_USER_PAYLOAD"
if ! ${pkgs.curl}/bin/curl -sSf -X POST "''${JELLYFIN_URL}/Startup/User" \ if ! ${pkgs.curl}/bin/curl -sSf -X POST "''$JELLYFIN_URL/Startup/User" \
-H 'accept: */*' \ -H 'accept: */*' \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "''${SETUP_USER_PAYLOAD}"; then -d "''${SETUP_USER_PAYLOAD}"; then
@@ -103,7 +103,7 @@ in {
fi fi
# Enable remote access, disable UPnP auto-mapping # Enable remote access, disable UPnP auto-mapping
if ! ${pkgs.curl}/bin/curl -sSf -X POST "''\${JELLYFIN_URL}/Startup/RemoteAccess" \ if ! ${pkgs.curl}/bin/curl -sSf -X POST "''$JELLYFIN_URL/Startup/RemoteAccess" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"EnableRemoteAccess":true,"EnableAutomaticPortMapping":false}'; then -d '{"EnableRemoteAccess":true,"EnableAutomaticPortMapping":false}'; then
echo "ERROR: Failed to configure remote access." echo "ERROR: Failed to configure remote access."
@@ -111,7 +111,7 @@ in {
fi fi
# Complete the wizard # Complete the wizard
if ! ${pkgs.curl}/bin/curl -sSf -X POST "''\${JELLYFIN_URL}/Startup/Complete"; then if ! ${pkgs.curl}/bin/curl -sSf -X POST "''$JELLYFIN_URL/Startup/Complete"; then
echo "ERROR: Failed to complete wizard." echo "ERROR: Failed to complete wizard."
exit 1 exit 1
fi fi