Last active
September 8, 2019 16:21
-
-
Save hongkongkiwi/21902317880164ee3090200cd43c9a8b to your computer and use it in GitHub Desktop.
networkd-dispatcher routable.d config for zerotier-ddns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
command -v zerotier-cli >/dev/null 2>&1 || { echo >&2 "I require zerotier-cli but it's not installed. Aborting."; exit 1; } | |
command -v systemctl >/dev/null 2>&1 || { echo >&2 "I require systemctl but it's not installed. Aborting."; exit 1; } | |
# Vars for updating | |
export ZONE=domain.com | |
export HOST=zt.domain.com | |
export USE_DYNAMIC_HOSTNAME=true | |
export API=yourapikey | |
export PROXY=false | |
export FORCE_CREATE=true | |
export MASTER_API_KEY=false | |
DDNS_SCRIPT="/usr/local/bin/cloudflare-ddns.sh" | |
# Get some useful info | |
MY_HOSTNAME=`echo "$HOSTNAME" | tr '[:upper:]' '[:lower:]'` | |
DEV=`zerotier-cli listnetworks -j | jq -c -r '.[].portDeviceName' | grep "$IFACE"` | |
if [[ "$DEV" == "$IFACE" ]]; then | |
export ZEROTIER_NETWORK_ID=`zerotier-cli listnetworks -j | jq -c -r '.[] | select(.portDeviceName == "'$IFACE'") | .nwid'` | |
export HOST="${MY_HOSTNAME}.${ZEROTIER_NETWORK_ID}.${HOST}" | |
export NEW_IP_ADDR=`zerotier-cli listnetworks -j | jq -c -r '.[] | select(.portDeviceName == "'$IFACE'") | .assignedAddresses[0]' | cut -f1 -d"/"` | |
$DDNS_SCRIPT | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment