Fix qBittorrent auth: stamp known password hash via initContainer
LocalhostAuthEnabled=false isn't honored in this qBT version. Instead, initContainer stamps the PBKDF2 hash for admin:adminadmin before startup so all three pods have consistent credentials. portforward-helper and coordinator restored to cookie-based SID auth.
This commit is contained in:
@@ -35,16 +35,17 @@ spec:
|
||||
- -c
|
||||
- |
|
||||
CONF=/config/qBittorrent/qBittorrent.conf
|
||||
HASH='@ByteArray(HqYj1eGsdXlQ4CSy597Y9A==:J9hsJIlU5FYfHb5rY5qQoIpVpTijryS/H+CE07oMtplL/ytneBVFd2tfVJtqGjhdht8tEi4wmqSSlqTgEu444w==)'
|
||||
mkdir -p /config/qBittorrent
|
||||
if [ -f "$CONF" ]; then
|
||||
if grep -q "LocalhostAuthEnabled" "$CONF"; then
|
||||
sed -i 's/LocalhostAuthEnabled=.*/LocalhostAuthEnabled=false/' "$CONF"
|
||||
# Set known adminadmin password hash
|
||||
if grep -q "Password_PBKDF2" "$CONF"; then
|
||||
sed -i "s|WebUI\\\\Password_PBKDF2=.*|WebUI\\\\Password_PBKDF2=\"$HASH\"|" "$CONF"
|
||||
else
|
||||
sed -i '/^\[Preferences\]/a WebUI\\LocalhostAuthEnabled=false' "$CONF" || \
|
||||
printf '\n[Preferences]\nWebUI\\LocalhostAuthEnabled=false\n' >> "$CONF"
|
||||
sed -i "/^\[Preferences\]/a WebUI\\\\Password_PBKDF2=\"$HASH\"" "$CONF"
|
||||
fi
|
||||
fi
|
||||
echo "Config patched: $(grep LocalhostAuth $CONF 2>/dev/null || echo 'will be set on first run')"
|
||||
echo "Password hash set."
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /config
|
||||
@@ -96,7 +97,9 @@ spec:
|
||||
PORT=$(cat /tmp/gluetun/forwarded_port)
|
||||
if [ -n "$PORT" ] && [ "$PORT" != "0" ]; then
|
||||
echo "$(date): Forwarded port: $PORT — updating qBittorrent"
|
||||
curl -s -X POST http://localhost:8080/api/v2/app/setPreferences \
|
||||
curl -s -c /tmp/qbt.txt -X POST http://localhost:8080/api/v2/auth/login \
|
||||
-d "username=admin&password=adminadmin" >/dev/null 2>&1
|
||||
curl -s -b /tmp/qbt.txt -X POST http://localhost:8080/api/v2/app/setPreferences \
|
||||
-d "json={\"listen_port\":$PORT,\"random_port\":false}" >/dev/null 2>&1
|
||||
echo "$(date): qBittorrent listen port set to $PORT"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user