Revision: 2804
http://ipcop.svn.sourceforge.net/ipcop/?rev=2804&view=rev
Author: owes
Date: 2009-05-06 20:59:38 +0000 (Wed, 06 May 2009)
Log Message:
-----------
Add a method to quickly synchronise the clock, using ntpd -q (not ntpdate).
NTPd can take up to several minutes before it is sync'ed.
Normally not a problem, but if the clock is wrong (or RTC battery dead) this
can keep VPN tunnels from working, provide wrong time to clients, etc.
We probably may want to make this optional through the GUI.
Modified Paths:
--------------
ipcop/trunk/src/misc-progs/restartntpd.c
Modified: ipcop/trunk/src/misc-progs/restartntpd.c
===================================================================
--- ipcop/trunk/src/misc-progs/restartntpd.c 2009-05-06 18:06:00 UTC (rev
2803)
+++ ipcop/trunk/src/misc-progs/restartntpd.c 2009-05-06 20:59:38 UTC (rev
2804)
@@ -20,7 +20,7 @@
* along with IPCop. If not, see <http://www.gnu.org/licenses/>.
*
* (c) Darren Critchley 2003
- * (c) 2006-2008, the IPCop team
+ * (c) 2006-2009, the IPCop team
*
* $Id$
*
@@ -44,6 +44,7 @@
printf("Usage: %s [OPTION]\n\n", prg);
printf("Options:\n");
printf(" -b, --boot after booting\n");
+ printf(" -f, --force force a quick NTP sync\n");
printf(" -v, --verbose be verbose\n");
printf(" --help display this help and exit\n");
exit(exit_code);
@@ -54,11 +55,13 @@
{
NODEKV *kv = NULL;
int flag_boot = 0;
+ int flag_quick = 0;
int enabled = 0;
static struct option long_options[] =
{
{ "boot", no_argument, 0, 'b' },
+ { "force", no_argument, 0, 'f' },
{ "verbose", no_argument, 0, 'v' },
{ "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0}
@@ -69,11 +72,14 @@
if (!(initsetuid()))
exit(1);
- while ((c = getopt_long(argc, argv, "bv", long_options, &option_index)) !=
-1) {
+ while ((c = getopt_long(argc, argv, "bfv", long_options, &option_index))
!= -1) {
switch (c) {
case 'b': /* booting */
flag_boot = 1;
break;
+ case 'f': /* force quick sync */
+ flag_quick = 1;
+ break;
case 'v': /* verbose */
flag_verbose++;
break;
@@ -120,6 +126,20 @@
}
}
+ /* Synchronise clock now! */
+ if (enabled && (flag_boot || flag_quick)) {
+ /* ntpd -q produces some output which we may want to know about */
+ if (flag_verbose) {
+ verbose_printf(1, "Starting NTPd quick sync ... \n");
+ safe_system("/usr/bin/ntpd -q");
+ }
+ else {
+ if (safe_system("/usr/bin/ntpd -q >/dev/null 2>/dev/null")) {
+ verbose_printf(1, "ntpd -q failed\n");
+ }
+ }
+ }
+
/* Start ntpd if enabled */
if (enabled) {
verbose_printf(1, "Starting NTPd ... \n");
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Ipcop-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipcop-svn