mirror of
https://git.freebsd.org/ports.git
synced 2025-06-21 04:30:37 -04:00
ntpd-rs is an NTP implementation written in Rust, with a focus on security and stability. It includes client and server functionality and supports NTS. WWW: https://tweedegolf.nl/en/pendulum PR: 272774
56 lines
1.2 KiB
Bash
56 lines
1.2 KiB
Bash
#!/bin/sh
|
|
|
|
# PROVIDE: ntp_daemon
|
|
# REQUIRE: DAEMON FILESYSTEMS devfs
|
|
# BEFORE: LOGIN
|
|
# KEYWORD: nojail resume shutdown
|
|
#
|
|
. /etc/rc.subr
|
|
|
|
name=ntp_daemon
|
|
rcvar=ntp_daemon_enable
|
|
|
|
load_rc_config $name
|
|
|
|
ntp_daemon_enable=${ntp_daemon_enable-"NO"}
|
|
ntp_daemon_config=${ntp_daemon_config-"%%ETCDIR%%/ntp.toml"}
|
|
ntp_daemon_socket=${ntp_daemon_socket-"/var/run/ntpd-rs"}
|
|
|
|
command="/usr/bin/true"
|
|
procname="/usr/sbin/daemon"
|
|
pidfile="/var/run/${name}.pid"
|
|
|
|
start_cmd="ntp_daemon_start"
|
|
stop_cmd="ntp_daemon_stop"
|
|
|
|
is_process_running()
|
|
{
|
|
[ -f ${pidfile} ] && procstat $(cat ${pidfile}) >/dev/null 2>&1
|
|
}
|
|
|
|
ntp_daemon_start()
|
|
{
|
|
[ -d "${ntp_daemon_socket}" ] || /bin/mkdir "${ntp_daemon_socket}"
|
|
/usr/sbin/chown _ntp:_ntp "${ntp_daemon_socket}"
|
|
/usr/sbin/daemon -P ${pidfile} -r -f -o /var/log/ntp_daemon.log -H %%PREFIX%%/bin/ntp-daemon --config "${ntp_daemon_config}"
|
|
|
|
if is_process_running; then
|
|
echo "Started ntp-daemon (pid=$(cat ${pidfile}))"
|
|
else
|
|
echo "Failed to start ntp-daemon"
|
|
fi
|
|
}
|
|
|
|
ntp_daemon_stop()
|
|
{
|
|
if is_process_running; then
|
|
/bin/rm -rf "${ntp_daemon_socket}"
|
|
local pid=$(cat ${pidfile})
|
|
echo "Stopping ntp-daemon (pid=${pid})"
|
|
kill -- -${pid}
|
|
else
|
|
echo "ntp-daemon isn't running"
|
|
fi
|
|
}
|
|
|
|
run_rc_command "$1"
|