summaryrefslogtreecommitdiff
path: root/scripts/deprecated
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/deprecated')
-rw-r--r--scripts/deprecated/freq_adj.in97
-rwxr-xr-xscripts/deprecated/hpadjtime.sh18
-rwxr-xr-xscripts/deprecated/html2man.in234
-rwxr-xr-xscripts/deprecated/ntp-close8
-rwxr-xr-xscripts/deprecated/ntp-groper95
-rwxr-xr-xscripts/deprecated/ntp-restart10
-rwxr-xr-xscripts/deprecated/ntp-status45
7 files changed, 507 insertions, 0 deletions
diff --git a/scripts/deprecated/freq_adj.in b/scripts/deprecated/freq_adj.in
new file mode 100644
index 0000000..88eb390
--- /dev/null
+++ b/scripts/deprecated/freq_adj.in
@@ -0,0 +1,97 @@
+#! @PATH_PERL@ -w
+
+die "perl5 needed\n" unless ($] > 5);
+
+use Getopt::Std;
+use vars qw($opt_n);
+
+getopts('d:nt:');
+
+#chop($ncpu = `sysctl -n hw.ncpu`);
+#die "Found $ncpu CPUs; can only be run on systems with 1 CPU.\n" if ($ncpu > 1);
+
+$driftfile = "/etc/ntp.drift";
+$driftfile = $opt_d if defined($opt_d);
+
+chop($timer = `sysctl -n kern.timecounter.hardware 2> /dev/null`);
+
+$timer =~ tr/\U/\L/;
+
+if ($timer eq '') {
+ open(DM, "/var/run/dmesg.boot");
+ while(<DM>) {
+ # Timecounter "i8254" frequency 1193182 Hz
+ if (/^Timecounter "(\w+)"\s+/) {
+ $timer = $1;
+ last;
+ }
+ }
+ close(DM);
+}
+
+$opt_t = $timer if !defined($opt_t);
+
+if ($timer ne '') { # $timer found...
+ if ($opt_t ne '') { # - and $opt_t found
+ if ($timer ne $opt_t) { # - - and they differ
+ warn "You specified a $opt_t timer but I detected a $timer timer.\n";
+ usage();
+ exit 1;
+ } else { # - - and they are the same
+ ;
+ }
+ } else { # - but no $opt_t specified; this is OK
+ ;
+ }
+} else { # No $timer found...
+ if ($opt_t ne '') { # - but $opt_t was specified
+ $timer = $opt_t; # - - so use it.
+ } else { # - and neither was $opt_t
+ warn "I can't tell what timer you have. Please specify one.\n";
+ usage();
+ exit 1;
+ }
+}
+
+open(DF, $driftfile) || die "Can't open driftfile ($driftfile): $!\n";
+while(<DF>) {
+ chop;
+ if (/^(-?\d+\.\d+)(\s\d)?$/) {
+ $drift = $1;
+ } else {
+ die "Bogus value in driftfile $driftfile: <$_>\n";
+ }
+}
+close(DF);
+
+print "NTP drift is <$drift>\n";
+
+# Convert from NTP's idea of PPM to a decimal equivalent
+$freq_adj = int ( $drift * ( 10 ** 6 / 2 ** 20) );
+print "normalized freq_adj is <$freq_adj>\n";
+
+$freq_adj = int ( ( $freq_adj - 1 ) / 2 );
+print "Applying freq_adj of <".-$freq_adj.">\n";
+
+$sysctl = "machdep.".$timer."_freq";
+
+chop($mach_freq = `sysctl -n $sysctl`);
+
+print "$sysctl is <$mach_freq>\n";
+
+$n_mach_freq = $mach_freq - $freq_adj;
+
+if (defined($opt_n)) {
+ print "$sysctl $mach_freq -> $n_mach_freq\n";
+} else {
+ print "i8254: ".`sysctl -w $sysctl=$n_mach_freq`;
+}
+
+sub usage {
+ print STDERR <<EOUsage
+Usage: $0 [-d drift_file] [-n] [-t timer]
+where "drift_file" defaults to /etc/ntp.drift
+and "timer" is usually "tsc" or "i8254"
+and "-n" says "don't really change anything, just say what would happen".
+EOUsage
+}
diff --git a/scripts/deprecated/hpadjtime.sh b/scripts/deprecated/hpadjtime.sh
new file mode 100755
index 0000000..3de2a40
--- /dev/null
+++ b/scripts/deprecated/hpadjtime.sh
@@ -0,0 +1,18 @@
+#! /bin/sh
+val=1
+if [ -f /bin/uname -o -f /usr/bin/uname ]; then
+ set `uname -a | tr '[A-Z]' '[a-z]'`
+ case "$1" in
+ hp-ux) case "$3" in
+ *.10.*) val=1 ;;
+ *.09.03 | *.09.10) case "$5" in
+ 9000/3*) val=1 ;;
+ *) val=0 ;;
+ esac ;;
+ *) val=0 ;;
+ esac
+ ;;
+ *)
+ esac
+fi
+exit $val
diff --git a/scripts/deprecated/html2man.in b/scripts/deprecated/html2man.in
new file mode 100755
index 0000000..adc4848
--- /dev/null
+++ b/scripts/deprecated/html2man.in
@@ -0,0 +1,234 @@
+#! @PATH_PERL@ -w
+#
+# html2man: Converts the NTP HTML documentation to man page format
+#
+# This file require the Perl HTML::TokeParser module:
+# http://search.cpan.org/search?module=HTML::TokeParser
+#
+# Depending on where this is run from, you might need to modify $MANDIR below.
+#
+# Hacked together by Peter Boettcher <boettcher@ll.mit.edu>
+# Last modified: <Mon Jan 28 17:24:38 2002 by pwb>
+
+require HTML::TokeParser;
+
+# use strict; # I can dream...
+
+$MANDIR = "./man";
+
+# HTML files to convert. Also include per-file info here:
+# name of man page, man section, 'see also' section
+%manfiles = (
+ 'ntpd' => ['ntpd', @NTPD_MS@, 'ntp.conf(5), ntpq(@NTPQ_MS@), ntpdc(@NTPDC_MS@)'],
+ 'ntpq' => ['ntpq', @NTPQ_MS@, 'ntp_decode(5), ntpd(@NTPD_MS@), ntpdc(@NTPDC_MS@)'],
+ 'ntpdate' => ['ntpdate', @NTPDATE_MS@, 'ntpd(@NTPD_MS@)'],
+ 'ntpdc' => ['ntpdc', @NTPDC_MS@, 'ntpd(@NTPD_MS@)'],
+ 'ntptime' => ['ntptime', @NTPTIME_MS@, 'ntpd(@NTPD_MS@), ntpdate(@NTPDATE_MS@)'],
+ 'ntptrace' => ['ntptrace', @NTPTRACE_MS@, 'ntpd(@NTPD_MS@)'],
+ 'ntp-wait' => ['ntp-wait', @NTP_WAIT_MS@, 'ntpd(@NTPD_MS@)'],
+ 'keygen' => ['ntp-keygen', @NTP_KEYGEN_MS@, 'ntpd(@NTPD_MS@), ntp_auth(5)'],
+ 'tickadj' => ['tickadj', @TICKADJ_MS@, 'ntpd(@NTPD_MS@)'],
+ 'confopt' => ['ntp.conf', 5, 'ntpd(@NTPD_MS@), ntp_auth(5), ntp_mon(5), ntp_acc(5), ntp_clock(5), ntp_misc(5)'],
+ 'authopt' => ['ntp_auth', 5, 'ntp.conf(5), ntpd(@NTPD_MS@)'],
+ 'monopt' => ['ntp_mon', 5, 'ntp.conf(5), ntp_decode(5)'],
+ 'accopt' => ['ntp_acc', 5, 'ntp.conf(5)'],
+ 'clockopt' => ['ntp_clock', 5, 'ntp.conf(5)'],
+ 'decode' => ['ntp_decode', 5, 'ntpq(@NTPQ_MS@), ntp_mon(5)'],
+ 'miscopt' => ['ntp_misc', 5, 'ntp.conf(5)']);
+
+%table_headers = (
+ 'ntpd' => 'l l l l.',
+ 'ntpq' => 'l l.',
+ 'monopt' => 'l l l.',
+ 'decode' => 'l l l l.',
+ 'authopt' => 'c c c c c c.'
+);
+
+# Disclaimer to go in SEE ALSO section of the man page
+$seealso_disclaimer = "The official HTML documentation.\n\n" .
+ "This file was automatically generated from HTML source.\n";
+
+mkdir $MANDIR, 0777;
+mkdir "$MANDIR/man8", 0777;
+mkdir "$MANDIR/man5", 0777;
+
+# Do the actual processing
+foreach $file (keys %manfiles) {
+ process($file);
+}
+# End of main function
+
+
+
+# Do the real work
+sub process {
+ my($filename) = @_;
+ $fileinfo = $manfiles{$filename};
+
+ $p = HTML::TokeParser->new("$filename.html") || die "Can't open $filename.html: $!";
+ $fileout = "$MANDIR/man$fileinfo->[1]/$fileinfo->[0].$fileinfo->[1]";
+ open(MANOUT, ">$fileout")
+ || die "Can't open: $!";
+
+ $p->get_tag("title");
+ $name = $p->get_text("/title");
+ $p->get_tag("hr"); # Skip past image and quote, hopefully
+
+ # Setup man header
+ print MANOUT ".TH " . $fileinfo->[0] . " " . $fileinfo->[1] . "\n";
+ print MANOUT ".SH NAME\n";
+ $pat = $fileinfo->[0];
+ if ($name =~ /$pat/) {
+ } else {
+ # Add the manpage name, if not in the HTML title already
+ print MANOUT "$fileinfo->[0] - ";
+ }
+ print MANOUT "$name\n.SH \\ \n\n";
+
+ @fontstack = ();
+ $deflevel = 0;
+ $pre = 0;
+ $ignore = 0;
+ $first_td = 1;
+ # Now start scanning. We basically print everything after translating some tags.
+ # $token->[0] has "T", "S", "E" for Text, Start, End
+ # $token->[1] has the tag name, or text (for "T" case)
+ # Theres lots more in the world of tokens, but who cares?
+ while (my $token = $p->get_token) {
+ if($token->[0] eq "T") {
+ my $text = $token->[1];
+ if (!$pre) {
+ if($tag) {
+ $text =~ s/^[\n\t ]*//;
+ }
+ $text =~ s/^[\n\t ][\n\t ]+$//;
+ $text =~ s/[\n\t ]+/ /g;
+ $text =~ s/&nbsp\;/ /g;
+ $text =~ s/&gt\;/>/g;
+ $text =~ s/&lt\;/</g;
+ $text =~ s/&quot\;/"/g;
+ $text =~ s/&amp\;/&/g;
+ $text =~ s/^\./\\[char46]/;
+ }
+ print MANOUT "$text";
+ $tag = 0;
+ }
+ if($token->[0] eq "S") {
+ if($token->[1] eq "h4") {
+ my $text = uc($p->get_trimmed_text("/h4"));
+ # ignore these sections in ntpd.html
+ if ($filename eq "ntpd" &&
+ ($text eq "CONFIGURATION OPTIONS")) {
+ $ignore = 1;
+ close(MANOUT);
+ open(MANOUT, ">/dev/null");
+ } elsif ($ignore) {
+ $ignore = 0;
+ close(MANOUT);
+ open(MANOUT, ">>$fileout");
+ }
+ print MANOUT "\n\n.SH $text\n";
+ }
+ if($token->[1] eq "tt") {
+ push @fontstack, "tt";
+ print MANOUT "\\fB";
+ }
+ if($token->[1] eq "i") {
+ push @fontstack, "i";
+ print MANOUT "\\fI";
+ }
+ if($token->[1] eq "address") {
+ my $text = $p->get_trimmed_text("/address");
+ print MANOUT "\n.SH AUTHOR\n$text\n";
+ }
+ if($token->[1] eq "dt" || $token->[1] eq "br" && $deflevel > 0) {
+ print MANOUT "\n.TP 8\n";
+ $tag = 1;
+ }
+ if($token->[1] eq "dd") {
+ print MANOUT "\n";
+ $tag = 1;
+ }
+ if($token->[1] eq "dl") {
+ $deflevel+=1;
+ if ($deflevel > 0) {
+ print MANOUT "\n.RS ", $deflevel > 1 ? 8 : 0;
+ }
+ }
+ if($token->[1] eq "p") {
+ print MANOUT "\n";
+ }
+ if($token->[1] eq "pre") {
+ print MANOUT "\n.nf";
+ $pre = 1;
+ }
+ if($token->[1] eq "table") {
+ print MANOUT "\n.TS\n";
+ print MANOUT "expand allbox tab(%);\n";
+ print MANOUT $table_headers{$filename};
+ print MANOUT "\n";
+ }
+ if($token->[1] eq "td") {
+ if ($first_td == 0) {
+ print MANOUT " % ";
+ }
+ $first_td = 0;
+ }
+ }
+ elsif($token->[0] eq "E") {
+ if($token->[1] eq "h4") {
+ $tag = 1;
+ }
+ if($token->[1] eq "tt") {
+ $f = pop @fontstack;
+ if($f ne "tt") {
+ warn "Oops, mismatched font! Trying to continue\n";
+ }
+ if ($#fontstack < 0) { $fontswitch = "\\fR"; }
+ elsif ($fontstack[$#fontstack] eq "tt") { $fontswitch = "\\fB"; }
+ else { $fontswitch = "\\fI"; }
+ print MANOUT "$fontswitch";
+ }
+ if($token->[1] eq "i") {
+ $f = pop @fontstack;
+ if($f ne "i") {
+ warn "Oops, mismatched font! Trying to continue\n";
+ }
+ if ($#fontstack < 0) { $fontswitch = "\\fR"; }
+ elsif ($fontstack[$#fontstack] eq "tt") { $fontswitch = "\\fB"; }
+ else { $fontswitch = "\\fI"; }
+ print MANOUT "$fontswitch";
+ }
+ if($token->[1] eq "dl") {
+ if ($deflevel > 0) {
+ print MANOUT "\n.RE";
+ }
+ print MANOUT "\n";
+ $deflevel-=1;
+ }
+ if($token->[1] eq "p") {
+ print MANOUT "\n";
+ $tag = 1;
+ }
+ if($token->[1] eq "pre") {
+ print MANOUT "\n.fi";
+ $pre = 0;
+ }
+ if($token->[1] eq "table") {
+ print MANOUT ".TE\n";
+ }
+ if($token->[1] eq "tr") {
+ print MANOUT "\n";
+ $first_td = 1;
+ }
+ }
+ }
+ if ($ignore) {
+ close(MANOUT);
+ open(MANOUT, ">>$fileout");
+ }
+ print MANOUT "\n.SH SEE ALSO\n\n";
+ print MANOUT "$fileinfo->[2]\n\n";
+ print MANOUT "$seealso_disclaimer\n";
+ close(MANOUT);
+}
diff --git a/scripts/deprecated/ntp-close b/scripts/deprecated/ntp-close
new file mode 100755
index 0000000..b5077e6
--- /dev/null
+++ b/scripts/deprecated/ntp-close
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+lynx -source http://www.eecis.udel.edu/~mills/ntp/clock2.htm |
+ sed -n -e 's,).*,,' -e' /([0-9.]*$/s/.*(//p' |
+ xargs ntpdate -q |
+ sort -n +7 > /tmp/ntp-close
+
+# From: Neal McBurnett <neal@bcn.boulder.co.us>
diff --git a/scripts/deprecated/ntp-groper b/scripts/deprecated/ntp-groper
new file mode 100755
index 0000000..1fd0cfe
--- /dev/null
+++ b/scripts/deprecated/ntp-groper
@@ -0,0 +1,95 @@
+#!/bin/sh
+#
+# ntpgroper host ...
+#
+# This script checks each hostname given as an argument to see if
+# it is running NTP. It reports one of the following messages (assume
+# the host is named "dumbo.hp.com":
+#
+# dumbo.hp.com not registered in DNS
+# dumbo.hp.com not responding to ping
+# dumbo.hp.com refused ntpq connection
+# dumbo.hp.com not responding to NTP
+# dumbo.hp.com answers NTP version 2, stratum: 3, ref: telford.nsa.hp.com
+# dumbo.hp.com answers NTP version 3, stratum: 3, ref: telford.nsa.hp.com
+#
+# It ain't pretty, but it is kinda useful.
+#
+# Walter Underwood, 11 Feb 1993, wunder@hpl.hp.com
+#
+# converted to /bin/sh from /bin/ksh by scott@ee.udel.edu 24 Mar 1993
+
+PATH="/usr/local/etc:$PATH" export PATH
+
+verbose=1
+logfile=/tmp/cntp-log$$
+ntpqlog=/tmp/cntp-ntpq$$
+
+# I wrap the whole thing in parens so that it is possible to redirect
+# all the output somewhere, if desired.
+(
+for host in $*
+do
+ # echo "Trying $host."
+
+ gethost $host > /dev/null 2>&1
+ if [ $? -ne 0 ]
+ then
+ echo "$host not registered in DNS"
+ continue
+ fi
+
+ ping $host 64 1 > /dev/null 2>&1
+ if [ $? -ne 0 ]
+ then
+ echo "$host not responding to ping"
+ continue
+ fi
+
+ # Attempt to contact with version 3 ntp, then try version 2.
+ for version in 3 2
+ do
+
+ ntpq -c "ntpversion $version" -p $host > $ntpqlog 2>&1
+
+ if fgrep -s 'Connection refused' $ntpqlog
+ then
+ echo "$host refused ntpq connection"
+ break
+ fi
+
+ responding=1
+ fgrep -s 'timed out, nothing received' $ntpqlog > /dev/null && responding=0
+
+ if [ $responding -eq 1 ]
+ then
+ ntpq -c "ntpversion $version" -c rl $host > $ntpqlog
+
+ # First we extract the reference ID (usually a host or a clock)
+ synchost=`fgrep "refid=" $ntpqlog`
+ #synchost=${synchost##*refid=} # strip off the beginning of the line
+ #synchost=${synchost%%,*} # strip off the end
+ synchost=`expr "$synchost" : '.*refid=\([^,]*\),.*'`
+
+ # Next, we get the stratum
+ stratum=`fgrep "stratum=" $ntpqlog`
+ #stratum=${stratum##*stratum=}
+ #stratum=${stratum%%,*}
+ stratum=`expr "$stratum" : '.*stratum=\([^,]*\),.*'`
+
+ echo "$host answers NTP version $version, stratum: $stratum, ref: $synchost"
+ break;
+ fi
+
+ if [ $version -eq 2 -a $responding -eq 0 ]
+ then
+ echo "$host not responding to NTP"
+ fi
+ done
+done
+)
+# ) >> $logfile
+
+if [ -f $ntpqlog ]; then
+ rm $ntpqlog
+fi
diff --git a/scripts/deprecated/ntp-restart b/scripts/deprecated/ntp-restart
new file mode 100755
index 0000000..0a1d58a
--- /dev/null
+++ b/scripts/deprecated/ntp-restart
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# This script can be used to kill and restart the NTP daemon. Edit the
+# /usr/local/bin/ntpd line to fit.
+#
+kill -INT `ps -ax | egrep "ntpd" | egrep -v "egrep" | sed 's/^\([ 0-9]*\) .*/\1'/`
+sleep 10
+/usr/local/bin/ntpd -g
+/usr/local/bin/ntp-wait
+exit 0
diff --git a/scripts/deprecated/ntp-status b/scripts/deprecated/ntp-status
new file mode 100755
index 0000000..4109124
--- /dev/null
+++ b/scripts/deprecated/ntp-status
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# From: Marc Brett <Marc.Brett@westgeo.com>
+
+# Here's a quick hack which can give you the stratum, delay, offset
+# for any number of ntp servers.
+
+NTPDATE=/usr/local/bin/ntpdate
+NSLOOKUP=/usr/sbin/nslookup
+EGREP=/bin/egrep
+AWK=/bin/awk
+RM=/bin/rm
+FILE=/tmp/ntp.$$
+
+USAGE="Usage: $0 hostname [hostname ...]"
+
+if [ $# -le 0 ]
+then
+ echo $USAGE 2>&1
+ exit 1
+fi
+
+trap '$RM -f $FILE; exit' 1 2 3 4 13 15
+
+for HOST in $*
+do
+ HOSTNAME=`$NSLOOKUP $HOST | $EGREP "Name:" | $AWK '{print $2}'`
+ if [ -n "$HOSTNAME" ]
+ then
+ $NTPDATE -d $HOST 2>/dev/null | $EGREP '^stratum|^delay|^offset|^originate' > $FILE
+ STRATUM=`$EGREP '^stratum' $FILE | $AWK '{print $2}'`
+ OFFSET=`$EGREP '^offset' $FILE | $AWK '{print $2}'`
+ DELAY=`$EGREP '^delay' $FILE | $AWK '{print $2}'`
+ TIMESTAMP=`$EGREP '^originate' $FILE | $AWK '{print $4 " " $5 " " $6 " " $7 " " $8}'`
+ if [ "$STRATUM" -ne 0 ]
+ then
+ echo "$HOSTNAME: stratum:$STRATUM delay:$DELAY offset:$OFFSET $TIMESTAMP"
+ else
+ echo $HOSTNAME: Not running NTP
+ fi
+ fi
+
+done
+
+$RM -f $FILE