fix: discover default interface

sometimes docker would change the container interface
This commit is contained in:
f 2023-11-23 09:54:20 -03:00
parent 7d84f1ad9a
commit 04b0f20647
No known key found for this signature in database
3 changed files with 5 additions and 1 deletions

View file

@ -24,6 +24,7 @@ RUN install -dm 2750 -o root -g root /var/lib/monit
COPY --from=build /etc/monitrc /etc/monitrc
COPY ./nsupdate.sh /usr/local/bin/nsupdate
COPY ./whatsmyip6.sh /usr/local/bin/whatsmyip6
COPY ./whatsmydefaulteth.sh /usr/local/bin/whatsmydefaulteth
COPY ./syslogize.sh /usr/local/bin/syslogize
COPY ./zeroconf.sh /usr/local/bin/zeroconf
COPY ./zeroconf.conf /etc/zeroconf.conf

3
whatsmydefaulteth.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
ip -6 r | grep default | tr -s " " | cut -d " " -f 5

View file

@ -1,3 +1,3 @@
#!/bin/sh
ip address show ${1:-eth0} | grep inet6 | grep global | tr -s " " | cut -d " " -f 3 | cut -d / -f 1
ip address show ${1:-$(whatsmydefaulteth)} | grep inet6 | grep global | tr -s " " | cut -d " " -f 3 | cut -d / -f 1