#!/usr/bin/env python3 import hashlib, os, base64 password = "{{ qbittorrent_webui_password }}" salt = os.urandom(16) dk = hashlib.pbkdf2_hmac("sha512", password.encode(), salt, 100000) pw_hash = "@ByteArray(" + base64.b64encode(salt).decode() + ":" + base64.b64encode(dk).decode() + ")" os.makedirs("/containers/qbittorrent/config/qBittorrent", exist_ok=True) with open("/containers/qbittorrent/config/qBittorrent/qBittorrent.conf", "w") as f: f.write("[Preferences]\n") f.write('WebUI\\Password_PBKDF2="{}"\n'.format(pw_hash)) f.write("WebUI\\Port=5080\n") f.write("WebUI\\Username=admin\n") f.write("WebUI\\LocalHostAuth=false\n") f.write("WebUI\\ServerDomains=*\n") f.write("WebUI\\Address=*\n")