From 14540f043d8e1b1fd0d05fe8403125cd6b626d4f Mon Sep 17 00:00:00 2001 From: soraefir Date: Thu, 14 May 2026 17:40:57 +0200 Subject: [PATCH] fix script errors --- modules/server/containers/apps/jellyfin.nix | 37 +++++---------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/modules/server/containers/apps/jellyfin.nix b/modules/server/containers/apps/jellyfin.nix index ca00d44..efeefac 100644 --- a/modules/server/containers/apps/jellyfin.nix +++ b/modules/server/containers/apps/jellyfin.nix @@ -88,11 +88,6 @@ in { echo "ERROR: Failed to set startup configuration." exit 1 fi - - SETUP_USER_PAYLOAD=$(${pkgs.jq}/bin/jq -n \ - --arg name "$DEFAULT_ADMIN_USERNAME" \ - --arg pass "$DEFAULT_ADMIN_PASSWORD" \ - '{"Name": $name, "Password": $pass}') if ! ${pkgs.curl}/bin/curl -sSf -X GET "$JELLYFIN_URL/Startup/User"; then echo "ERROR: Failed to get base user." @@ -100,9 +95,8 @@ in { fi if ! ${pkgs.curl}/bin/curl -sSf -X POST "$JELLYFIN_URL/Startup/User" \ - -H 'accept: */*' \ - -H "Content-Type: application/json" \ - -d "$SETUP_USER_PAYLOAD"; then + -H 'accept: */*' -H "Content-Type: application/json" \ + -d '{"Name": "$DEFAULT_ADMIN_USERNAME", "Password": "$DEFAULT_ADMIN_PASSWORD"}'; then echo "ERROR: Failed to set admin user." exit 1 fi @@ -156,34 +150,19 @@ in { echo "Jellyfin is up. Sleeping for 20 seconds..." sleep 20 fi - JELLYFIN_TOKEN=$(${pkgs.curl}/bin/curl -sSf -X POST "$JELLYFIN_URL/Users/AuthenticateByName" \ - -H "Content-Type: application/json" \ - -H "Authorization: MediaBrowser Client=\"Bash Script\", Device=\"Server Terminal\", DeviceId=\"script-12345\", Version=\"1.0.0\"" \ - -d "{\"Username\": \"$DEFAULT_ADMIN_USERNAME\", \"Pw\": \"$DEFAULT_ADMIN_PASSWORD\"}" \ - | ${pkgs.jq}/bin/jq -r '.AccessToken') - # Verify we got a token - if [ "$JELLYFIN_TOKEN" = "null" ] || [ -z "$JELLYFIN_TOKEN" ]; then - echo "ERROR: Authentication failed." - exit 1 - fi - - SETUP_LDAP_PAYLOAD=$(${pkgs.jq}/bin/jq -n \ - --arg ldap_pass "$DEFAULT_LDAP_PASSWORD" \ - '{"LdapUsers":[],"LdapServer":"authentik-ldap","LdapPort":6636,"UseSsl":true,"UseStartTls":false,"SkipSslVerify":true, - "LdapBindUser":"cn=ldap-service,ou=users,${LDAP_DC_DOMAIN}","LdapBindPassword":$ldap_pass, + if ! ${pkgs.curl}/bin/curl -sSf -X POST "$JELLYFIN_URL/Plugins/958aad66-3784-4d2a-b89a-a7b6fab6e25c/Configuration" \ + -H "Authorization: MediaBrowser Token=\"$JELLYFIN_TOKEN\"" \ + -H "Content-Type: application/json" -H 'accept: */*' \ + -d '{"LdapUsers":[],"LdapServer":"authentik-ldap","LdapPort":6636,"UseSsl":true,"UseStartTls":false,"SkipSslVerify":true, + "LdapBindUser":"cn=ldap-service,ou=users,${LDAP_DC_DOMAIN}","LdapBindPassword": "$DEFAULT_LDAP_PASSWORD", "LdapBaseDn":"${LDAP_DC_DOMAIN}","LdapSearchFilter":"(memberOf=cn=flix,ou=groups,${LDAP_DC_DOMAIN})", "LdapSearchAttributes":"uid, cn, mail, displayName", "LdapAdminBaseDn":"","LdapAdminFilter":"(memberOf=cn=admin,ou=groups,${LDAP_DC_DOMAIN})", "EnableLdapAdminFilterMemberUid":false,"LdapUidAttribute":"uid","LdapUsernameAttribute":"cn","LdapPasswordAttribute":"userPassword", "EnableLdapProfileImageSync":false,"RemoveImagesNotInLdap":false,"LdapProfileImageAttribute":"jpegphoto","LdapProfileImageFormat":"Default", "LdapClientCertPath":"","LdapClientKeyPath":"","LdapRootCaPath":"","CreateUsersFromLdap":true,"AllowPassChange":false, - "EnableAllFolders":true,"EnabledFolders":[],"PasswordResetUrl":""}') - - if ! ${pkgs.curl}/bin/curl -sSf -X POST "$JELLYFIN_URL/Plugins/958aad66-3784-4d2a-b89a-a7b6fab6e25c/Configuration" \ - -H "Authorization: MediaBrowser Token=\"$JELLYFIN_TOKEN\"" \ - -H "Content-Type: application/json" -H 'accept: */*' \ - -d "$SETUP_USER_PAYLOAD"; then + "EnableAllFolders":true,"EnabledFolders":[],"PasswordResetUrl":""}'; then echo "ERROR: LDAP Plugin Setup Failed." exit 1 fi