Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Jul 2009 11:11:21 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r195339 - head/usr.sbin/tzsetup
Message-ID:  <200907041111.n64BBLH6011263@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: attilio
Date: Sat Jul  4 11:11:21 2009
New Revision: 195339
URL: http://svn.freebsd.org/changeset/base/195339

Log:
  Add a new options (-s) that, when specified, skips the question about
  adjusting the clock to UTC.
  That avoids to write on /etc/wall_cmos_clock which is useful in some
  cases (example: host user in a jail).
  
  Sponsored by:	Sandvine Incorporated
  Initially submitted by:	Matt Koivisto <mkoivisto at sandvine dot com>
  Approved by:	re (kib)

Modified:
  head/usr.sbin/tzsetup/tzsetup.8
  head/usr.sbin/tzsetup/tzsetup.c

Modified: head/usr.sbin/tzsetup/tzsetup.8
==============================================================================
--- head/usr.sbin/tzsetup/tzsetup.8	Sat Jul  4 10:15:01 2009	(r195338)
+++ head/usr.sbin/tzsetup/tzsetup.8	Sat Jul  4 11:11:21 2009	(r195339)
@@ -23,7 +23,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd January 24, 1996
+.Dd July 4, 2009
 .Dt TZSETUP 8
 .Os
 .Sh NAME
@@ -31,7 +31,7 @@
 .Nd set local timezone
 .Sh SYNOPSIS
 .Nm
-.Op Fl n
+.Op Fl ns
 .Op Ar default
 .Sh DESCRIPTION
 The
@@ -51,6 +51,9 @@ The following option is available:
 .Bl -tag -offset indent -width Fl
 .It Fl n
 Do not create or copy files.
+.It Fl s 
+Skip the initial question about adjusting the clock if not set to
+.Tn UTC .
 .El
 .Pp
 It is possible to short-circuit the menu system by specifying a

Modified: head/usr.sbin/tzsetup/tzsetup.c
==============================================================================
--- head/usr.sbin/tzsetup/tzsetup.c	Sat Jul  4 10:15:01 2009	(r195338)
+++ head/usr.sbin/tzsetup/tzsetup.c	Sat Jul  4 11:11:21 2009	(r195339)
@@ -652,7 +652,7 @@ static void
 usage(void)
 {
 
-	fprintf(stderr, "usage: tzsetup [-n]\n");
+	fprintf(stderr, "usage: tzsetup [-ns]\n");
 	exit(1);
 }
 
@@ -666,14 +666,17 @@ int
 main(int argc, char **argv)
 {
 	char		title[64], prompt[128];
-	int		c, fd;
+	int		c, fd, skiputc;
 
-	while ((c = getopt(argc, argv, "n")) != -1) {
+	skiputc = 0;
+	while ((c = getopt(argc, argv, "ns")) != -1) {
 		switch(c) {
 		case 'n':
 			reallydoit = 0;
 			break;
-
+		case 's':
+			skiputc = 1;
+			break;
 		default:
 			usage();
 		}
@@ -690,27 +693,30 @@ main(int argc, char **argv)
 	sort_countries();
 	make_menus();
 
-	snprintf(title, sizeof(title),
-	    "Select local or UTC (Greenwich Mean Time) clock");
-	snprintf(prompt, sizeof(prompt),
-	    "Is this machine's CMOS clock set to UTC?  "
-	    "If it is set to local time,\n"
-	    "or you don't know, please choose NO here!");
 	init_dialog();
-	if (!DIALOG_UTC(title, prompt, 7, 72)) {
-		if (reallydoit)
-			unlink(_PATH_WALL_CMOS_CLOCK);
-	} else {
-		if (reallydoit) {
-			fd = open(_PATH_WALL_CMOS_CLOCK,
-			    O_WRONLY | O_CREAT | O_TRUNC,
-			    S_IRUSR | S_IRGRP | S_IROTH);
-			if (fd < 0)
-				err(1, "create %s", _PATH_WALL_CMOS_CLOCK);
-			close(fd);
+	if (skiputc == 0) {
+		snprintf(title, sizeof(title),
+		    "Select local or UTC (Greenwich Mean Time) clock");
+		snprintf(prompt, sizeof(prompt),
+		    "Is this machine's CMOS clock set to UTC?  "
+		    "If it is set to local time,\n"
+		    "or you don't know, please choose NO here!");
+		if (!DIALOG_UTC(title, prompt, 7, 72)) {
+			if (reallydoit)
+				unlink(_PATH_WALL_CMOS_CLOCK);
+		} else {
+			if (reallydoit) {
+				fd = open(_PATH_WALL_CMOS_CLOCK,
+				    O_WRONLY | O_CREAT | O_TRUNC,
+				    S_IRUSR | S_IRGRP | S_IROTH);
+				if (fd < 0)
+					err(1, "create %s",
+					    _PATH_WALL_CMOS_CLOCK);
+				close(fd);
+			}
 		}
+		dialog_clear_norefresh();
 	}
-	dialog_clear_norefresh();
 	if (optind == argc - 1) {
 		snprintf(title, sizeof(title), "Default timezone provided");
 		snprintf(prompt, sizeof(prompt),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907041111.n64BBLH6011263>