Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Update Docker XML from script

Featured Replies

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 by ajb3932
grammar error

Solved by ajb3932

  • 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 by ajb3932
formatting error

  • 2 weeks later...

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 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.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.