Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / scripts / rc2 / local.ntpd
blobba53e05adbbb7547a95eab647c5c261350a4f602
1 #! /usr/bin/perl -w
2 # 980904 Harlan Stenn - created
4 # vvv CHANGE THESE vvv
6 $ps = "/bin/ps x |";
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";
12 # ^^^ CHANGE THESE ^^^
15 if (0)
18 elsif ($ARGV[0] eq "start")
20 @pidlist = pidlist($ntpd);
21 if (defined(@pidlist))
23 warn "NTP is already running\n";
25 else
27 if ( -f $ntp_conf && -x $ntpd )
29 system ($ntpdate);
30 system ($ntpd." -c ".$ntp_conf);
34 elsif ($ARGV[0] eq "stop")
36 @pidlist = pidlist($ntpd);
37 kill 'TERM', @pidlist if (scalar(@pidlist) > 0);
39 else
41 die "Usage: $0 {start,stop}\n";
45 sub pidlist ($)
47 my ($target) = @_;
48 my ($qt) = quotemeta($target);
49 my @pids;
51 open(PS, $ps) || die "Can't run ps: $!\n";
52 while (<PS>)
54 chomp;
55 next unless (/$qt/);
56 print "Got <$_>\n";
57 if (/^\s*(\d+)\s+/)
59 push @pids, $1;
62 close(PS);
63 return @pids;