1#!/bin/sh 2# 3# $NetBSD: ntpd,v 1.13 2004/08/13 18:08:03 mycroft Exp $ 4# 5 6# PROVIDE: ntpd 7# REQUIRE: DAEMON 8# BEFORE: LOGIN 9# KEYWORD: chrootdir 10 11$_rc_subr_loaded . /etc/rc.subr 12 13name="ntpd" 14rcvar=$name 15command="/usr/sbin/${name}" 16pidfile="/var/run/${name}.pid" 17start_precmd="ntpd_precmd" 18required_files="/etc/ntp.conf" 19 20ntpd_precmd() 21{ 22 if [ -z "$ntpd_chrootdir" ]; then 23 return 0; 24 fi 25 26 # If running in a chroot cage, ensure that the appropriate files 27 # exist inside the cage, as well as helper symlinks into the cage 28 # from outside. 29 # 30 # As this is called after the is_running and required_dir checks 31 # are made in run_rc_command(), we can safely assume ${ntpd_chrootdir} 32 # exists and ntpd isn't running at this point (unless forcestart 33 # is used). 34 # 35 # Before enabling ntpd_chrootdir, ensure that: 36 # - The kernel has "pseudo-device clockctl" compiled in 37 # - /dev/clockctl is present 38 # 39 if (: </dev/clockctl) 2>/dev/null; then 40 : exists and works 41 else 42 logger -s -p daemon.warning -t ntpd \ 43 "WARNING: not chrooting -- no working /dev/clockctl device" 44 return 0 45 fi 46 if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then 47 rm -f "${ntpd_chrootdir}/dev/clockctl" 48 ( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" ) 49 fi 50 ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift 51 52 # Change run_rc_commands()'s internal copy of $ntpd_flags 53 # 54 rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags" 55} 56 57load_rc_config $name 58run_rc_command "$1" 59