Annotation of embedaddon/ntp/scripts/rc2/local.ntpd, revision 1.1
1.1 ! misho 1: #! /usr/bin/perl -w
! 2: # 980904 Harlan Stenn - created
! 3:
! 4: # vvv CHANGE THESE vvv
! 5:
! 6: $ps = "/bin/ps x |";
! 7:
! 8: $ntp_conf = "/etc/ntp.conf";
! 9: $ntpd = "/usr/local/bin/xntpd";
! 10: $ntpdate = "/usr/local/bin/ntpdate -b -s 10.0.0.1 10.0.0.2";
! 11:
! 12: # ^^^ CHANGE THESE ^^^
! 13:
! 14: {
! 15: if (0)
! 16: {
! 17: }
! 18: elsif ($ARGV[0] eq "start")
! 19: {
! 20: @pidlist = pidlist($ntpd);
! 21: if (defined(@pidlist))
! 22: {
! 23: warn "NTP is already running\n";
! 24: }
! 25: else
! 26: {
! 27: if ( -f $ntp_conf && -x $ntpd )
! 28: {
! 29: system ($ntpdate);
! 30: system ($ntpd." -c ".$ntp_conf);
! 31: }
! 32: }
! 33: }
! 34: elsif ($ARGV[0] eq "stop")
! 35: {
! 36: @pidlist = pidlist($ntpd);
! 37: kill 'TERM', @pidlist if (scalar(@pidlist) > 0);
! 38: }
! 39: else
! 40: {
! 41: die "Usage: $0 {start,stop}\n";
! 42: }
! 43: }
! 44:
! 45: sub pidlist ($)
! 46: {
! 47: my ($target) = @_;
! 48: my ($qt) = quotemeta($target);
! 49: my @pids;
! 50:
! 51: open(PS, $ps) || die "Can't run ps: $!\n";
! 52: while (<PS>)
! 53: {
! 54: chomp;
! 55: next unless (/$qt/);
! 56: print "Got <$_>\n";
! 57: if (/^\s*(\d+)\s+/)
! 58: {
! 59: push @pids, $1;
! 60: }
! 61: }
! 62: close(PS);
! 63: return @pids;
! 64: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>