#!/usr/bin/env bash

# Uninstalls the NTP server relay daemon on your Mac.
#
# This daemon opens automatically at Mac startup, and listens on NTP port 123
# for clients. Data is forwarded to time.apple.com and the replies are relayed
# back to clients.
#
# Written by Ben Bird, June 2021. Free for anyone to use or distribute for
# any purpose.

if [ -f "/Library/LaunchDaemons/ntp-relay.plist" ]; then
	launchctl stop ntp-relay
	launchctl unload /Library/LaunchDaemons/ntp-relay.plist
	rm -f "/Library/LaunchDaemons/ntp-relay.plist"
fi

if [ -f "/Library/LaunchDaemons/com.bensoftware.ntp-relay.plist" ]; then
	launchctl stop com.bensoftware.ntp-relay
	launchctl unload /Library/LaunchDaemons/com.bensoftware.ntp-relay.plist
	rm -f "/Library/LaunchDaemons/com.bensoftware.ntp-relay.plist"
fi

if [ -f "/usr/local/sbin/ntp-relay" ]; then
	rm -f "/usr/local/sbin/ntp-relay"
fi
