domeneshop: don't set temporary ipv6
fucks you up on restart
This commit is contained in:
parent
5e261ca6d6
commit
60b890b566
|
@ -5,10 +5,12 @@ in
|
|||
{
|
||||
# auto domain update
|
||||
|
||||
# TODO: ensure dns64 does not interfere with this
|
||||
|
||||
options = with lib; {
|
||||
services.domeneshop-updater.targets = mkOption {
|
||||
type = with types; listOf str;
|
||||
#default = [ config.networking.fqdn ];
|
||||
example = [ config.networking.fqdn ];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -33,7 +35,7 @@ in
|
|||
serviceConfig = let
|
||||
prog = pkgs.writeShellApplication {
|
||||
name = "domeneshop-dyndns-updater.sh";
|
||||
runtimeInputs = with pkgs; [ curl yq ];
|
||||
runtimeInputs = with pkgs; [ curl iproute2 jq ];
|
||||
text = ''
|
||||
test -s /run/secrets/domeneshop/token || {
|
||||
>&2 echo "ERROR: /run/secrets/domeneshop/token not found!"
|
||||
|
@ -45,8 +47,29 @@ in
|
|||
}
|
||||
DOMENESHOP_TOKEN="$( cat /run/secrets/domeneshop/token)"
|
||||
DOMENESHOP_SECRET="$(cat /run/secrets/domeneshop/secret)"
|
||||
|
||||
# get stable ipv6 addr, fallback to ipv4, fallback to curl default
|
||||
IF=$(
|
||||
ip -6 -json addr show scope global -temporary \
|
||||
| jq '.[]| select(.ifname|contains("docker")|not) | .addr_info[].local | select(.==null|not)' -r \
|
||||
| head -n1
|
||||
)
|
||||
if [[ -z "$IF" ]]; then
|
||||
IF=$(
|
||||
ip -4 -json addr show scope global -temporary \
|
||||
| jq '.[]| select(.ifname|contains("docker")|not) | .addr_info[].local | select(.==null|not)' -r \
|
||||
| head -n1
|
||||
)
|
||||
fi
|
||||
if [[ -n "$IF" ]]; then
|
||||
IF="--interface $IF"
|
||||
else
|
||||
IF=""
|
||||
fi
|
||||
|
||||
${lib.concatMapStringsSep "\n" (target: ''
|
||||
curl https://"$DOMENESHOP_TOKEN":"$DOMENESHOP_SECRET"@api.domeneshop.no/v0/dyndns/update?hostname="${target}"
|
||||
# shellcheck disable=SC2086
|
||||
curl $IF https://"$DOMENESHOP_TOKEN":"$DOMENESHOP_SECRET"@api.domeneshop.no/v0/dyndns/update?hostname="${target}"
|
||||
'') cfg.targets}
|
||||
'';
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue