1: <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN"
2: "http://lpml.sourceforge.net/DTD/piml.dtd">
3: <!-- ntpcheck.piml -->
4: <!-- Matthew Hall -->
5:
6: <!-- $Id: ntpcheck.piml,v 1.55 2024/04/24 21:57:16 raeburn Exp $ -->
7:
8: <!--
9:
10: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
11:
12: LON-CAPA is free software; you can redistribute it and/or modify
13: it under the terms of the GNU General Public License as published by
14: the Free Software Foundation; either version 2 of the License, or
15: (at your option) any later version.
16:
17: LON-CAPA is distributed in the hope that it will be useful,
18: but WITHOUT ANY WARRANTY; without even the implied warranty of
19: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: GNU General Public License for more details.
21:
22: You should have received a copy of the GNU General Public License
23: along with LON-CAPA; if not, write to the Free Software
24: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25:
26: /home/httpd/html/adm/gpl.txt
27:
28: http://www.lon-capa.org/
29:
30: -->
31:
32: <piml>
33: <targetroot>/</targetroot>
34: <files>
35: <file>
36: <target dist="default"></target>
37: <perlscript mode="fg">
38: print "Checking to be sure the Network Time Protocol is running properly.\n";
39: if (('<DIST />' eq 'fedora26') || ('<DIST />' eq 'fedora27') ||
40: ('<DIST />' eq 'fedora28') || ('<DIST />' eq 'fedora29') ||
41: ('<DIST />' eq 'fedora30') || ('<DIST />' eq 'fedora31') ||
42: ('<DIST />' eq 'fedora32') || ('<DIST />' eq 'fedora33') ||
43: ('<DIST />' eq 'fedora34') || ('<DIST />' eq 'fedora35') ||
44: ('<DIST />' eq 'fedora36') || ('<DIST />' eq 'fedora37') ||
45: ('<DIST />' eq 'fedora38') || ('<DIST />' eq 'sles15') ||
46: ('<DIST />' eq 'centos8') || ('<DIST />' eq 'rhes8') ||
47: ('<DIST />' eq 'oracle7') || ('<DIST />' eq 'oracle8') ||
48: ('<DIST />' eq 'ubuntu18') || ('<DIST />' eq 'ubuntu20') ||
49: ('<DIST />' eq 'ubuntu22') || ('<DIST />' eq 'ubuntu24') ||
50: ('<DIST />' eq 'rocky8') || ('<DIST />' eq 'alma8') ||
51: ('<DIST />' eq 'centos8-stream') || ('<DIST />' eq 'centos9-stream') ||
52: ('<DIST />' eq 'rhes9') || ('<DIST />' eq 'oracle9') ||
53: ('<DIST />' eq 'rocky9') || ('<DIST />' eq 'alma9')) {
54: print "For more information on chronyd please see https://chrony.tuxfamily.org/\n";
55: } else {
56: print "For more information on ntpd please see http://www.ntp.org/\n";
57: }
58: my $NTPD;
59: my $name = 'ntp';
60: my $checkcmd = 'ps -ef |grep ntp |grep -v grep |grep -v ntpcheck';
61: my $startntpcmd;
62: my $is_running;
63: if (('<DIST />' eq 'fedora15') || ('<DIST />' eq 'fedora16') ||
64: ('<DIST />' eq 'fedora17') || ('<DIST />' eq 'fedora18') ||
65: ('<DIST />' eq 'fedora19') || ('<DIST />' eq 'fedora20') ||
66: ('<DIST />' eq 'fedora21') || ('<DIST />' eq 'fedora22') ||
67: ('<DIST />' eq 'fedora23') || ('<DIST />' eq 'fedora24') ||
68: ('<DIST />' eq 'fedora25') || ('<DIST />' eq 'fedora26') ||
69: ('<DIST />' eq 'fedora27') || ('<DIST />' eq 'fedora28') ||
70: ('<DIST />' eq 'fedora29') || ('<DIST />' eq 'fedora30') ||
71: ('<DIST />' eq 'fedora31') || ('<DIST />' eq 'fedora32') ||
72: ('<DIST />' eq 'fedora33') || ('<DIST />' eq 'fedora34') ||
73: ('<DIST />' eq 'fedora35') || ('<DIST />' eq 'fedora36') ||
74: ('<DIST />' eq 'fedora37') || ('<DIST />' eq 'fedora38') ||
75: ('<DIST />' eq 'centos7') || ('<DIST />' eq 'rhes7') ||
76: ('<DIST />' eq 'oracle7') || ('<DIST />' eq 'scientific7') ||
77: ('<DIST />' eq 'sles12') || ('<DIST />' eq 'sles15') ||
78: ('<DIST />' eq 'ubuntu18') || ('<DIST />' eq 'ubuntu20') ||
79: ('<DIST />' eq 'ubuntu22') || ('<DIST />' eq 'ubuntu24') ||
80: ('<DIST />' eq 'rhes8') || ('<DIST />' eq 'centos8') ||
81: ('<DIST />' eq 'oracle8') || ('<DIST />' eq 'rocky8') ||
82: ('<DIST />' eq 'alma8') || ('<DIST />' eq 'centos8-stream') ||
83: ('<DIST />' eq 'centos9-stream') || ('<DIST />' eq 'rhes9') ||
84: ('<DIST />' eq 'oracle9') || ('<DIST />' eq 'rocky9') ||
85: ('<DIST />' eq 'alma9')) {
86: $NTPD = 'ntpd';
87: my $binname = $NTPD;
88: if (('<DIST />' eq 'ubuntu18') || ('<DIST />' eq 'ubuntu20') ||
89: ('<DIST />' eq 'ubuntu22') || ('<DIST />' eq 'ubuntu24')) {
90: $NTPD = 'chrony';
91: $name = $NTPD;
92: $binname = 'chronyd';
93: } elsif (('<DIST />' eq 'fedora26') || ('<DIST />' eq 'fedora27') ||
94: ('<DIST />' eq 'fedora28') || ('<DIST />' eq 'fedora29') ||
95: ('<DIST />' eq 'fedora30') || ('<DIST />' eq 'fedora31') ||
96: ('<DIST />' eq 'fedora32') || ('<DIST />' eq 'fedora33') ||
97: ('<DIST />' eq 'fedora34') || ('<DIST />' eq 'fedora35') ||
98: ('<DIST />' eq 'fedora36') || ('<DIST />' eq 'fedora37') ||
99: ('<DIST />' eq 'fedora38') || ('<DIST />' eq 'sles15') ||
100: ('<DIST />' eq 'rhes8') || ('<DIST />' eq 'centos8') ||
101: ('<DIST />' eq 'oracle7') || ('<DIST />' eq 'oracle8') ||
102: ('<DIST />' eq 'rocky8') || ('<DIST />' eq 'alma8') ||
103: ('<DIST />' eq 'centos8-stream') || ('<DIST />' eq 'centos9-stream') ||
104: ('<DIST />' eq 'rhes9') || ('<DIST />' eq 'oracle9') ||
105: ('<DIST />' eq 'rocky9') || ('<DIST />' eq 'alma9')) {
106: $NTPD = 'chronyd';
107: $name = $NTPD;
108: $binname = $NTPD;
109: }
110: $checkcmd = "systemctl is-enabled $NTPD.service";
111: $startntpcmd = "systemctl start $NTPD.service";
112: if (!-e "/usr/sbin/$binname") {
113: print "$name is not installed.\n";
114: exit;
115: }
116: } else {
117: if (-e "/etc/init.d/ntpd") {
118: $NTPD = "ntpd";
119: } elsif (-e "/etc/init.d/xntpd") {
120: $NTPD = "xntpd";
121: } elsif (-e "/etc/init.d/ntp") {
122: $NTPD = "ntp";
123: } else {
124: print "ntp is not installed.\n";
125: exit;
126: }
127: $startntpcmd = "/etc/init.d/$NTPD start";
128: }
129:
130: if (open(PIPE,'-|',$checkcmd)) {
131: $is_running = <PIPE>;
132: chomp($is_running);
133: close(PIPE);
134: if (!$is_running) {
135: print "WARNING: $name is installed but is not currently running.\n";
136: if ($name eq 'ntp') {
137: print "Please verify the configuration of ntp in /etc/ntp.conf and /etc/ntp/step-tickers\n";
138: }
139: print "Start $name by executing\n $startntpcmd\n";
140: } else {
141: print "$name is installed and running\n";
142: }
143: } else {
144: print "Could not determine $name status.\n";
145: }
146:
147: # chkconfig barfs to stderr if the target isn't set up right.
148: if (('<DIST />' eq 'fedora15') || ('<DIST />' eq 'fedora16') ||
149: ('<DIST />' eq 'fedora17') || ('<DIST />' eq 'fedora18') ||
150: ('<DIST />' eq 'fedora19') || ('<DIST />' eq 'fedora20') ||
151: ('<DIST />' eq 'fedora21') || ('<DIST />' eq 'fedora22') ||
152: ('<DIST />' eq 'fedora23') || ('<DIST />' eq 'fedora24') ||
153: ('<DIST />' eq 'fedora25') || ('<DIST />' eq 'fedora26') ||
154: ('<DIST />' eq 'fedora27') || ('<DIST />' eq 'fedora28') ||
155: ('<DIST />' eq 'fedora29') || ('<DIST />' eq 'fedora30') ||
156: ('<DIST />' eq 'fedora31') || ('<DIST />' eq 'fedora32') ||
157: ('<DIST />' eq 'fedora33') || ('<DIST />' eq 'fedora34') ||
158: ('<DIST />' eq 'fedora35') || ('<DIST />' eq 'fedora36') ||
159: ('<DIST />' eq 'fedora37') || ('<DIST />' eq 'fedora38') ||
160: ('<DIST />' eq 'centos7') || ('<DIST />' eq 'scientific7') ||
161: ('<DIST />' eq 'rhes7') || ('<DIST />' eq 'oracle7') ||
162: ('<DIST />' eq 'sles12') || ('<DIST />' eq 'sles15') ||
163: ('<DIST />' eq 'ubuntu18') || ('<DIST />' eq 'ubuntu20') ||
164: ('<DIST />' eq 'ubuntu22') || ('<DIST />' eq 'ubuntu24') ||
165: ('<DIST />' eq 'rhes8') || ('<DIST />' eq 'centos8') ||
166: ('<DIST />' eq 'oracle8') || ('<DIST />' eq 'rocky8') ||
167: ('<DIST />' eq 'alma8') || ('<DIST />' eq 'centos8-stream') ||
168: ('<DIST />' eq 'centos9-stream') || ('<DIST />' eq 'rhes9') ||
169: ('<DIST />' eq 'oracle9') || ('<DIST />' eq 'rocky9') ||
170: ('<DIST />' eq 'alma9')) {
171: if (!-l "/etc/systemd/system/multi-user.target.wants/$NTPD.service") {
172: print "**** WARNING: $NTPD is not configured to run at boot. To correct this run:\nsystemctl enable $NTPD.service\n";
173: }
174: exit;
175: } else {
176: my $checking_bin;
177: my $restartchk;
178: if (('<DIST />' eq 'debian5') || ('<DIST />' eq 'debian6') || ('<DIST />' eq 'ubuntu6') ||
179: ('<DIST />' eq 'ubuntu8') || ('<DIST />' eq 'ubuntu10') || ('<DIST />' eq 'ubuntu12') ||
180: ('<DIST />' eq 'ubuntu14') || ('<DIST />' eq 'ubuntu16')) {
181: $checking_bin = '/usr/sbin/sysv-rc-conf';
182: } else {
183: $checking_bin = '/sbin/chkconfig';
184: }
185: $restartchk = `$checking_bin --list $NTPD 2>/dev/null`;
186: if ($restartchk eq '') {
187: print "**** WARNING: ntpd is either not installed or not configured to run at boot.\n";
188: exit;
189: }
190: if ($restartchk =~ /^error reading information on service / ||
191: $restartchk !~ /\d:(on|off)/) {
192: print "**** WARNING: Unable to check status $NTPD with $checking_bin.\n";
193: exit;
194: }
195: if ($restartchk !~ /\s3:on/) {
196: print "**** WARNING: ntpd is not set to start at runlevel 3. To correct this run:\n$checking_bin --level 345 $NTPD on\n";
197: exit;
198: }
199: if ($restartchk !~ /\s5:on/) {
200: print "**** WARNING: ntpd is not set to start at runlevel 5. To correct this run:\n$checking_bin --level 345 $NTPD on\n";
201: exit;
202: }
203: }
204: </perlscript>
205: </file>
206: </files>
207: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>