May 28, 20242 yr I have Gluetun VPN set up with port forwarding enabled and a Qbittorrent container which uses the Gluetun and uses the port that has been forwarded. Sometimes when the Gluetun container restarts the port forward changes and I have to manually update the Qbt config from the UI to match the new port. I have a user script that lets me know when the port changes and what the port is but I wondered if I could go one step further and use sed to update the Qbittorrent xml with the new port forward and restart the container. Something like: ... if [ "$oldport" != "$gluetunport" ]; then sed -i 's/${oldport}/${gluetunport}/g' my-qbittorrent.xml docker run .... fi ... Is this recommended/advised or is there is an easier way? How would I rebuild the docker container with the new xml? Thanks Edited May 28, 20242 yr by ajb3932 grammar error
May 29, 20242 yr Author Solution I've figured it out. Probably a hacky way round but still. I enabled 'Template Authoring Mode' and grabbed the docker command, then update the xml to keep it in line with the docker command that will be run. ... if [ "$oldport" != "$gluetunport" ]; then docker stop qbitorrent docker rm qbitorrent sed -i 's/${oldport}/${gluetunport}/g' my-qbittorrent.xml /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker create --name='qbittorrent' .... fi ... Maybe this will help someone in the future. Edited May 29, 20242 yr by ajb3932 formatting error
June 11, 20242 yr For future reference: The concept of XML is not being a text file, that gets edited with text tools (like sed, awk) but an in-memory tree of nodes. Therefore it makes most sense to use the tools, that have been crafted for XML. To get an overview of some light-weight XML tools, I'd recommend to read this article over at Baeldung.com. I think, at least "xidel" can also update in-place and write back to the XML file in question. Should make these things easier. Edited June 11, 20242 yr by amix
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.