ntpd revision 1.10
11.1Ssimonb#!/bin/sh 21.1Ssimonb# 31.10Sitohy# $NetBSD: ntpd,v 1.10 2002/07/02 14:47:22 itohy Exp $ 41.1Ssimonb# 51.1Ssimonb 61.1Ssimonb# PROVIDE: ntpd 71.1Ssimonb# REQUIRE: DAEMON 81.6Sthorpej# BEFORE: LOGIN 91.9Slukem# KEYWORD: chrootdir 101.1Ssimonb 111.1Ssimonb. /etc/rc.subr 121.1Ssimonb 131.1Ssimonbname="ntpd" 141.3Slukemrcvar=$name 151.1Ssimonbcommand="/usr/sbin/${name}" 161.1Ssimonbpidfile="/var/run/${name}.pid" 171.4Slukemstart_precmd="ntpd_precmd" 181.1Ssimonbrequired_files="/etc/ntp.conf" 191.4Slukem 201.4Slukemntpd_precmd() 211.4Slukem{ 221.4Slukem if [ -z "$ntpd_chrootdir" ]; then 231.4Slukem return 0; 241.4Slukem fi 251.4Slukem 261.4Slukem # If running in a chroot cage, ensure that the appropriate files 271.4Slukem # exist inside the cage, as well as helper symlinks into the cage 281.4Slukem # from outside. 291.4Slukem # 301.4Slukem # As this is called after the is_running and required_dir checks 311.4Slukem # are made in run_rc_command(), we can safely assume ${ntpd_chrootdir} 321.4Slukem # exists and ntpd isn't running at this point (unless forcestart 331.4Slukem # is used). 341.7Slukem # 351.8Slukem # Before enabling ntpd_chrootdir, ensure that: 361.8Slukem # - The kernel has "pseudo-device clockctl" compiled in 371.8Slukem # - /dev/clockctl is present 381.4Slukem # 391.10Sitohy if (: </dev/clockctl) 2>/dev/null; then 401.10Sitohy : exists and works 411.10Sitohy else 421.10Sitohy logger -s -p daemon.warning -t ntpd \ 431.10Sitohy "WARNING: not chrooting -- no working /dev/clockctl device" 441.10Sitohy return 0 451.10Sitohy fi 461.4Slukem if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then 471.4Slukem rm -f "${ntpd_chrootdir}/dev/clockctl" 481.4Slukem ( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" ) 491.4Slukem fi 501.4Slukem ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift 511.4Slukem 521.4Slukem # Change run_rc_commands()'s internal copy of $ntpd_flags 531.4Slukem # 541.5Slukem rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags" 551.4Slukem} 561.1Ssimonb 571.2Slukemload_rc_config $name 581.1Ssimonbrun_rc_command "$1" 59