Skip to content

Commit

Permalink
Add -r|--reload
Browse files Browse the repository at this point in the history
  • Loading branch information
pschmitt committed Jan 13, 2024
1 parent 1f4cf2b commit 0c47325
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions zerotier-hosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ usage() {
echo " -h, --help Show this help"
echo " -n, --network Network name to use (default: the first network)"
echo " -o, --output Output file (default: stdout)"
echo " -r, --reload Reload dnsmasq (SIGHUP) after generating zone file"
echo " -s, --suffix Suffix to append to hostnames (default: zt)"
echo " -t, --token API token to use (default: read from $PWD/token)"
}
Expand Down Expand Up @@ -101,6 +102,7 @@ then
ZEROTIER_API_HOST="${ZEROTIER_API_HOST:-}"
ZEROTIER_NETWORK_NAME="${ZEROTIER_NETWORK_NAME:-}"
SUFFIX="${SUFFIX:-zt}"
DNSMASQ_RELOAD="${DNSMASQ_RELOAD:-}"

while [[ -n "$*" ]]
do
Expand All @@ -121,6 +123,10 @@ then
OUTPUT="$2"
shift 2
;;
-r|--reload)
DNSMASQ_RELOAD="1"
shift
;;
-s|--suffix)
SUFFIX="$2"
shift 2
Expand Down Expand Up @@ -158,4 +164,9 @@ then
else
echo "$ZONEFILE"
fi

if [[ -n "$DNSMASQ_RELOAD" ]]
then
killall -HUP dnsmasq
fi
fi

0 comments on commit 0c47325

Please sign in to comment.