fix script errors

This commit is contained in:
soraefir
2026-05-14 17:40:57 +02:00
parent 2c29f8a41b
commit 14540f043d

View File

@@ -89,20 +89,14 @@ in {
exit 1 exit 1
fi 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 if ! ${pkgs.curl}/bin/curl -sSf -X GET "$JELLYFIN_URL/Startup/User"; then
echo "ERROR: Failed to get base user." echo "ERROR: Failed to get base user."
exit 1 exit 1
fi fi
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 '{"Name": "$DEFAULT_ADMIN_USERNAME", "Password": "$DEFAULT_ADMIN_PASSWORD"}'; then
-d "$SETUP_USER_PAYLOAD"; then
echo "ERROR: Failed to set admin user." echo "ERROR: Failed to set admin user."
exit 1 exit 1
fi fi
@@ -156,34 +150,19 @@ in {
echo "Jellyfin is up. Sleeping for 20 seconds..." echo "Jellyfin is up. Sleeping for 20 seconds..."
sleep 20 sleep 20
fi 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 ! ${pkgs.curl}/bin/curl -sSf -X POST "$JELLYFIN_URL/Plugins/958aad66-3784-4d2a-b89a-a7b6fab6e25c/Configuration" \
if [ "$JELLYFIN_TOKEN" = "null" ] || [ -z "$JELLYFIN_TOKEN" ]; then -H "Authorization: MediaBrowser Token=\"$JELLYFIN_TOKEN\"" \
echo "ERROR: Authentication failed." -H "Content-Type: application/json" -H 'accept: */*' \
exit 1 -d '{"LdapUsers":[],"LdapServer":"authentik-ldap","LdapPort":6636,"UseSsl":true,"UseStartTls":false,"SkipSslVerify":true,
fi "LdapBindUser":"cn=ldap-service,ou=users,${LDAP_DC_DOMAIN}","LdapBindPassword": "$DEFAULT_LDAP_PASSWORD",
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,
"LdapBaseDn":"${LDAP_DC_DOMAIN}","LdapSearchFilter":"(memberOf=cn=flix,ou=groups,${LDAP_DC_DOMAIN})", "LdapBaseDn":"${LDAP_DC_DOMAIN}","LdapSearchFilter":"(memberOf=cn=flix,ou=groups,${LDAP_DC_DOMAIN})",
"LdapSearchAttributes":"uid, cn, mail, displayName", "LdapSearchAttributes":"uid, cn, mail, displayName",
"LdapAdminBaseDn":"","LdapAdminFilter":"(memberOf=cn=admin,ou=groups,${LDAP_DC_DOMAIN})", "LdapAdminBaseDn":"","LdapAdminFilter":"(memberOf=cn=admin,ou=groups,${LDAP_DC_DOMAIN})",
"EnableLdapAdminFilterMemberUid":false,"LdapUidAttribute":"uid","LdapUsernameAttribute":"cn","LdapPasswordAttribute":"userPassword", "EnableLdapAdminFilterMemberUid":false,"LdapUidAttribute":"uid","LdapUsernameAttribute":"cn","LdapPasswordAttribute":"userPassword",
"EnableLdapProfileImageSync":false,"RemoveImagesNotInLdap":false,"LdapProfileImageAttribute":"jpegphoto","LdapProfileImageFormat":"Default", "EnableLdapProfileImageSync":false,"RemoveImagesNotInLdap":false,"LdapProfileImageAttribute":"jpegphoto","LdapProfileImageFormat":"Default",
"LdapClientCertPath":"","LdapClientKeyPath":"","LdapRootCaPath":"","CreateUsersFromLdap":true,"AllowPassChange":false, "LdapClientCertPath":"","LdapClientKeyPath":"","LdapRootCaPath":"","CreateUsersFromLdap":true,"AllowPassChange":false,
"EnableAllFolders":true,"EnabledFolders":[],"PasswordResetUrl":""}') "EnableAllFolders":true,"EnabledFolders":[],"PasswordResetUrl":""}'; then
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
echo "ERROR: LDAP Plugin Setup Failed." echo "ERROR: LDAP Plugin Setup Failed."
exit 1 exit 1
fi fi