1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-04 12:52:15 +00:00

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)
This commit is contained in:
Attilio Rao 2009-07-04 11:11:21 +00:00
parent 121fd46175
commit 5d279e6530
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=195339
2 changed files with 33 additions and 24 deletions

View File

@ -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

View File

@ -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),