2006-10-23 23:45:56 +04:00
|
|
|
/* $NetBSD: main.c,v 1.52 2006/10/23 19:45:56 he Exp $ */
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1997 Piermont Information Systems Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Philip A. Nelson for Piermont Information Systems Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1999-06-20 10:08:13 +04:00
|
|
|
* This product includes software developed for the NetBSD Project by
|
1997-09-27 03:02:53 +04:00
|
|
|
* Piermont Information Systems Inc.
|
|
|
|
* 4. The name of Piermont Information Systems Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* main sysinst program. */
|
|
|
|
|
1998-10-25 22:15:04 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/uio.h>
|
1997-09-27 03:02:53 +04:00
|
|
|
#include <stdio.h>
|
1997-11-21 15:08:06 +03:00
|
|
|
#include <signal.h>
|
1997-09-27 03:02:53 +04:00
|
|
|
#include <curses.h>
|
1997-11-04 04:39:03 +03:00
|
|
|
#include <unistd.h>
|
1998-10-25 22:15:04 +03:00
|
|
|
#include <fcntl.h>
|
2003-06-28 02:20:14 +04:00
|
|
|
#include <dirent.h>
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "md.h"
|
|
|
|
#include "msg_defs.h"
|
|
|
|
#include "menu_defs.h"
|
1998-10-25 22:15:04 +03:00
|
|
|
#include "txtwalk.h"
|
1997-09-27 03:02:53 +04:00
|
|
|
|
2003-06-16 23:42:13 +04:00
|
|
|
int main(int, char **);
|
2003-06-28 02:20:14 +04:00
|
|
|
static void select_language(void);
|
2003-06-16 23:42:13 +04:00
|
|
|
static void usage(void);
|
|
|
|
static void miscsighandler(int);
|
|
|
|
static void ttysighandler(int);
|
|
|
|
static void cleanup(void);
|
|
|
|
static void process_f_flag(char *);
|
1997-12-05 16:38:59 +03:00
|
|
|
|
|
|
|
static int exit_cleanly = 0; /* Did we finish nicely? */
|
1999-01-21 11:02:17 +03:00
|
|
|
int logging; /* are we logging everything? */
|
|
|
|
int scripting; /* are we building a script? */
|
2002-12-05 04:17:15 +03:00
|
|
|
FILE *logfp; /* log file */
|
1999-01-21 11:02:17 +03:00
|
|
|
FILE *script; /* script file */
|
1997-09-27 03:02:53 +04:00
|
|
|
|
1999-03-31 04:44:48 +04:00
|
|
|
#ifdef DEBUG
|
2003-06-16 23:42:13 +04:00
|
|
|
extern int log_flip(void);
|
1999-03-31 04:44:48 +04:00
|
|
|
#endif
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
/* String defaults and stuff for processing the -f file argument. */
|
|
|
|
|
|
|
|
struct f_arg {
|
|
|
|
const char *name;
|
|
|
|
const char *dflt;
|
|
|
|
char *var;
|
|
|
|
int size;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct f_arg fflagopts[] = {
|
|
|
|
{"release", REL, rel, sizeof rel},
|
|
|
|
{"machine", MACH, machine, sizeof machine},
|
|
|
|
{"xfer dir", "/usr/INSTALL", xfer_dir, sizeof xfer_dir},
|
|
|
|
{"ext dir", "", ext_dir, sizeof ext_dir},
|
|
|
|
{"ftp host", SYSINST_FTP_HOST, ftp.host, sizeof ftp.host},
|
|
|
|
{"ftp dir", SYSINST_FTP_DIR, ftp.dir, sizeof ftp.dir},
|
|
|
|
{"ftp prefix", "/" MACH "/binary/sets", set_dir, sizeof set_dir},
|
|
|
|
{"ftp user", "ftp", ftp.user, sizeof ftp.user},
|
|
|
|
{"ftp pass", "", ftp.pass, sizeof ftp.pass},
|
|
|
|
{"ftp proxy", "", ftp.proxy, sizeof ftp.proxy},
|
|
|
|
{"nfs host", "", nfs_host, sizeof nfs_host},
|
|
|
|
{"nfs dir", "/bsd/release", nfs_dir, sizeof nfs_dir},
|
|
|
|
{"cd dev", "cd0a", cdrom_dev, sizeof cdrom_dev},
|
2006-02-25 23:21:00 +03:00
|
|
|
{"fd dev", "/dev/fd0a", fd_dev, sizeof fd_dev},
|
2006-01-13 01:02:44 +03:00
|
|
|
{"local dev", "", localfs_dev, sizeof localfs_dev},
|
|
|
|
{"local fs", "ffs", localfs_fs, sizeof localfs_fs},
|
|
|
|
{"local dir", "release", localfs_dir, sizeof localfs_dir},
|
|
|
|
{"targetroot mount", "/targetroot", targetroot_mnt, sizeof targetroot_mnt},
|
|
|
|
{"dist postfix", ".tgz", dist_postfix, sizeof dist_postfix},
|
|
|
|
{"diskname", "mydisk", bsddiskname, sizeof bsddiskname},
|
|
|
|
|
2006-10-23 23:45:56 +04:00
|
|
|
{NULL, NULL, NULL, 0}
|
2006-01-13 01:02:44 +03:00
|
|
|
};
|
|
|
|
|
2004-06-06 10:06:59 +04:00
|
|
|
static void
|
|
|
|
init(void)
|
|
|
|
{
|
2006-01-13 01:02:44 +03:00
|
|
|
const struct f_arg *arg;
|
|
|
|
|
2004-06-06 10:06:59 +04:00
|
|
|
sizemult = 1;
|
|
|
|
disktype = "unknown";
|
|
|
|
tmp_mfs_size = 0;
|
|
|
|
doessf = "";
|
2006-01-13 01:02:44 +03:00
|
|
|
clean_xfer_dir = 0;
|
2004-06-06 10:06:59 +04:00
|
|
|
mnt2_mounted = 0;
|
2006-02-26 13:25:52 +03:00
|
|
|
fd_type = "msdos";
|
2006-01-13 01:02:44 +03:00
|
|
|
|
|
|
|
for (arg = fflagopts; arg->name != NULL; arg++)
|
|
|
|
strlcpy(arg->var, arg->dflt, arg->size);
|
2004-06-06 10:06:59 +04:00
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
int
|
2003-06-16 23:42:13 +04:00
|
|
|
main(int argc, char **argv)
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
|
|
|
WINDOW *win;
|
1997-11-04 04:39:03 +03:00
|
|
|
int ch;
|
1997-09-27 03:02:53 +04:00
|
|
|
|
1999-01-21 11:02:17 +03:00
|
|
|
logging = 0; /* shut them off unless turned on by the user */
|
2004-06-06 10:06:59 +04:00
|
|
|
init();
|
1999-03-31 04:44:48 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
log_flip();
|
|
|
|
#endif
|
1999-01-21 11:02:17 +03:00
|
|
|
scripting = 0;
|
|
|
|
|
1997-11-01 02:00:32 +03:00
|
|
|
/* Check for TERM ... */
|
|
|
|
if (!getenv("TERM")) {
|
1998-06-20 17:05:48 +04:00
|
|
|
(void)fprintf(stderr,
|
2003-06-16 23:42:13 +04:00
|
|
|
"sysinst: environment variable TERM not set.\n");
|
1997-11-01 02:00:32 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1997-11-04 04:39:03 +03:00
|
|
|
/* argv processing */
|
2003-06-25 19:45:21 +04:00
|
|
|
while ((ch = getopt(argc, argv, "Dr:f:")) != -1)
|
1997-11-04 04:39:03 +03:00
|
|
|
switch(ch) {
|
2003-06-25 19:45:21 +04:00
|
|
|
case 'D': /* set to get past certain errors in testing */
|
|
|
|
debug = 1;
|
|
|
|
break;
|
1997-11-04 04:39:03 +03:00
|
|
|
case 'r':
|
|
|
|
/* Release name other than compiled in release. */
|
2006-01-13 01:02:44 +03:00
|
|
|
strncpy(rel, optarg, sizeof rel);
|
1997-11-04 04:39:03 +03:00
|
|
|
break;
|
1998-10-25 22:15:04 +03:00
|
|
|
case 'f':
|
|
|
|
/* Definition file to read. */
|
2003-06-16 23:42:13 +04:00
|
|
|
process_f_flag(optarg);
|
1998-10-25 22:15:04 +03:00
|
|
|
break;
|
1997-11-04 04:39:03 +03:00
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
}
|
2000-10-02 13:26:26 +04:00
|
|
|
|
|
|
|
md_init();
|
1997-11-04 04:39:03 +03:00
|
|
|
|
1997-09-27 03:02:53 +04:00
|
|
|
/* initialize message window */
|
1999-06-19 10:52:22 +04:00
|
|
|
if (menu_init()) {
|
|
|
|
__menu_initerror();
|
|
|
|
exit(1);
|
|
|
|
}
|
2001-11-17 05:06:47 +03:00
|
|
|
|
1999-06-19 10:52:22 +04:00
|
|
|
/*
|
2006-01-13 01:02:44 +03:00
|
|
|
* Put 'messages' in a window that has a one-character border
|
|
|
|
* on the real screen.
|
1999-06-19 10:52:22 +04:00
|
|
|
*/
|
|
|
|
win = newwin(getmaxy(stdscr) - 2, getmaxx(stdscr) - 2, 1, 1);
|
2003-06-05 00:05:12 +04:00
|
|
|
if (win == NULL) {
|
|
|
|
(void)fprintf(stderr,
|
|
|
|
"sysinst: screen too small\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2001-11-17 05:06:47 +03:00
|
|
|
if (has_colors()) {
|
|
|
|
/*
|
|
|
|
* XXX This color trick should be done so much better,
|
|
|
|
* but is it worth it?
|
|
|
|
*/
|
|
|
|
wbkgd(win, COLOR_PAIR(1));
|
|
|
|
wattrset(win, COLOR_PAIR(1));
|
|
|
|
}
|
2003-06-10 21:47:15 +04:00
|
|
|
msg_window(win);
|
1997-09-27 03:02:53 +04:00
|
|
|
|
1999-06-22 04:43:57 +04:00
|
|
|
/* Watch for signals and clean up */
|
1998-06-20 17:05:48 +04:00
|
|
|
(void)atexit(cleanup);
|
1999-06-22 04:43:57 +04:00
|
|
|
(void)signal(SIGINT, ttysighandler);
|
|
|
|
(void)signal(SIGQUIT, ttysighandler);
|
|
|
|
(void)signal(SIGHUP, miscsighandler);
|
1997-11-21 15:08:06 +03:00
|
|
|
|
2002-07-27 14:02:50 +04:00
|
|
|
/* redraw screen */
|
|
|
|
touchwin(stdscr);
|
|
|
|
refresh();
|
|
|
|
|
2003-07-10 00:02:35 +04:00
|
|
|
/* Ensure we have mountpoint for target filesystems */
|
|
|
|
mkdir(targetroot_mnt, S_IRWXU| S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH);
|
|
|
|
|
2003-06-28 02:20:14 +04:00
|
|
|
select_language();
|
2004-06-12 23:18:24 +04:00
|
|
|
get_kb_encoding();
|
2003-06-28 02:20:14 +04:00
|
|
|
|
1997-09-27 03:02:53 +04:00
|
|
|
/* Menu processing */
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_netbsd, NULL);
|
1997-09-27 03:02:53 +04:00
|
|
|
|
1997-12-05 16:38:59 +03:00
|
|
|
exit_cleanly = 1;
|
2003-06-16 23:42:13 +04:00
|
|
|
return 0;
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
2003-06-28 02:20:14 +04:00
|
|
|
|
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
set_language(menudesc *m, void *arg)
|
2003-06-28 02:20:14 +04:00
|
|
|
{
|
|
|
|
char **fnames = arg;
|
|
|
|
|
2003-07-27 11:45:08 +04:00
|
|
|
msg_file(fnames[m->cursel]);
|
2003-06-28 02:20:14 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
select_language(void)
|
|
|
|
{
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dirent;
|
|
|
|
char **lang_msg, **fnames;
|
|
|
|
int max_lang = 16, num_lang = 0;
|
|
|
|
const char *cp;
|
|
|
|
menu_ent *opt = 0;
|
|
|
|
int lang_menu = -1;
|
|
|
|
int lang;
|
|
|
|
|
|
|
|
dir = opendir(".");
|
|
|
|
if (!dir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
lang_msg = malloc(max_lang * sizeof *lang_msg);
|
|
|
|
fnames = malloc(max_lang * sizeof *fnames);
|
|
|
|
if (!lang_msg || !fnames)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
lang_msg[0] = strdup(msg_string(MSG_sysinst_message_language));
|
|
|
|
fnames[0] = 0;
|
|
|
|
num_lang = 1;
|
|
|
|
|
|
|
|
while ((dirent = readdir(dir)) != 0) {
|
|
|
|
if (memcmp(dirent->d_name, "sysinstmsgs.", 12))
|
|
|
|
continue;
|
|
|
|
if (msg_file(dirent->d_name))
|
|
|
|
continue;
|
|
|
|
cp = msg_string(MSG_sysinst_message_language);
|
|
|
|
if (!strcmp(cp, lang_msg[0]))
|
|
|
|
continue;
|
|
|
|
if (num_lang == max_lang) {
|
|
|
|
char **new;
|
|
|
|
max_lang *= 2;
|
|
|
|
new = realloc(lang_msg, max_lang * sizeof *lang_msg);
|
|
|
|
if (!new)
|
|
|
|
break;
|
|
|
|
lang_msg = new;
|
|
|
|
new = realloc(fnames, max_lang * sizeof *fnames);
|
|
|
|
if (!new)
|
|
|
|
break;
|
|
|
|
fnames = new;
|
|
|
|
}
|
|
|
|
fnames[num_lang] = strdup(dirent->d_name);
|
|
|
|
lang_msg[num_lang++] = strdup(cp);
|
|
|
|
}
|
|
|
|
msg_file(0);
|
|
|
|
closedir(dir);
|
|
|
|
dir = 0;
|
|
|
|
|
|
|
|
if (num_lang == 1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
opt = calloc(num_lang, sizeof *opt);
|
|
|
|
if (!opt)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
for (lang = 0; lang < num_lang; lang++) {
|
|
|
|
opt[lang].opt_name = lang_msg[lang];
|
|
|
|
opt[lang].opt_menu = OPT_NOMENU;
|
|
|
|
opt[lang].opt_action = set_language;
|
|
|
|
}
|
|
|
|
|
|
|
|
lang_menu = new_menu(NULL, opt, num_lang, -1, 12, 0, 0, MC_NOEXITOPT,
|
2003-07-07 16:30:19 +04:00
|
|
|
NULL, NULL, NULL, NULL, NULL);
|
2003-06-28 02:20:14 +04:00
|
|
|
|
|
|
|
if (lang_menu != -1) {
|
|
|
|
msg_display(MSG_hello);
|
|
|
|
process_menu(lang_menu, fnames);
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (dir)
|
|
|
|
closedir(dir);
|
|
|
|
if (lang_menu != -1)
|
|
|
|
free_menu(lang_menu);
|
|
|
|
free(opt);
|
|
|
|
while (num_lang) {
|
|
|
|
free(lang_msg[--num_lang]);
|
|
|
|
free(fnames[num_lang]);
|
|
|
|
}
|
|
|
|
free(lang_msg);
|
|
|
|
free(fnames);
|
|
|
|
}
|
1997-11-04 04:39:03 +03:00
|
|
|
|
1997-12-04 12:05:35 +03:00
|
|
|
/* toplevel menu handler ... */
|
1998-06-20 17:05:48 +04:00
|
|
|
void
|
2003-06-16 23:42:13 +04:00
|
|
|
toplevel(void)
|
1997-12-04 12:05:35 +03:00
|
|
|
{
|
1998-06-20 17:05:48 +04:00
|
|
|
|
2000-05-11 06:23:53 +04:00
|
|
|
/* Display banner message in (english, francais, deutsch..) */
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(MSG_hello);
|
2000-12-03 04:54:46 +03:00
|
|
|
msg_display_add(MSG_md_hello);
|
|
|
|
msg_display_add(MSG_thanks);
|
1997-12-04 12:05:35 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Undo any stateful side-effects of previous menu choices.
|
|
|
|
* XXX must be idempotent, since we get run each time the main
|
|
|
|
* menu is displayed.
|
|
|
|
*/
|
|
|
|
unwind_mounts();
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-04 04:39:03 +03:00
|
|
|
/* The usage ... */
|
|
|
|
|
1997-12-05 16:38:59 +03:00
|
|
|
static void
|
2003-06-16 23:42:13 +04:00
|
|
|
usage(void)
|
1997-11-04 04:39:03 +03:00
|
|
|
{
|
1998-06-20 17:05:48 +04:00
|
|
|
|
|
|
|
(void)fprintf(stderr, msg_string(MSG_usage));
|
1997-11-04 04:39:03 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
1997-11-21 15:08:06 +03:00
|
|
|
|
|
|
|
/* ARGSUSED */
|
1997-12-05 16:38:59 +03:00
|
|
|
static void
|
2003-06-16 23:42:13 +04:00
|
|
|
miscsighandler(int signo)
|
1997-11-21 15:08:06 +03:00
|
|
|
{
|
1998-06-20 17:05:48 +04:00
|
|
|
|
1999-06-18 12:54:28 +04:00
|
|
|
/*
|
|
|
|
* we need to cleanup(), but it was already scheduled with atexit(),
|
|
|
|
* so it'll be invoked on exit().
|
|
|
|
*/
|
1997-11-21 15:08:06 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
1997-12-05 16:38:59 +03:00
|
|
|
|
1999-06-22 04:43:57 +04:00
|
|
|
static void
|
2003-06-16 23:42:13 +04:00
|
|
|
ttysighandler(int signo)
|
1999-06-22 04:43:57 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if we want to ignore a TTY signal (SIGINT or SIGQUIT), then we
|
|
|
|
* just return. If we want to forward a TTY signal, we forward it
|
|
|
|
* to the specified process group.
|
|
|
|
*
|
|
|
|
* This functionality is used when setting up and displaying child
|
|
|
|
* output so that the child gets the signal and presumably dies,
|
|
|
|
* but sysinst continues. We use this rather than actually ignoring
|
|
|
|
* the signals, because that will be be passed on to a child
|
|
|
|
* through fork/exec, whereas special handlers get reset on exec..
|
|
|
|
*/
|
|
|
|
if (ttysig_ignore)
|
|
|
|
return;
|
|
|
|
if (ttysig_forward) {
|
|
|
|
killpg(ttysig_forward, signo);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we need to cleanup(), but it was already scheduled with atexit(),
|
|
|
|
* so it'll be invoked on exit().
|
|
|
|
*/
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1997-12-05 16:38:59 +03:00
|
|
|
static void
|
2003-06-16 23:42:13 +04:00
|
|
|
cleanup(void)
|
1997-12-05 16:38:59 +03:00
|
|
|
{
|
1999-01-21 11:02:17 +03:00
|
|
|
time_t tloc;
|
1998-06-20 17:05:48 +04:00
|
|
|
|
1999-01-21 11:02:17 +03:00
|
|
|
(void)time(&tloc);
|
2003-07-18 13:46:11 +04:00
|
|
|
|
2004-04-19 01:34:56 +04:00
|
|
|
#if 0
|
2003-07-18 13:46:11 +04:00
|
|
|
restore_etc();
|
2004-04-19 01:34:56 +04:00
|
|
|
#endif
|
2003-07-28 15:32:21 +04:00
|
|
|
/* Ensure we aren't inside the target tree */
|
|
|
|
chdir(getenv("HOME"));
|
1997-12-05 16:38:59 +03:00
|
|
|
unwind_mounts();
|
2003-10-20 00:17:31 +04:00
|
|
|
umount_mnt2();
|
2003-07-18 13:46:11 +04:00
|
|
|
|
1999-01-21 11:02:17 +03:00
|
|
|
endwin();
|
2003-07-18 13:46:11 +04:00
|
|
|
|
1999-01-21 11:02:17 +03:00
|
|
|
if (logging) {
|
2002-12-05 04:17:15 +03:00
|
|
|
fprintf(logfp, "Log ended at: %s\n", asctime(localtime(&tloc)));
|
|
|
|
fflush(logfp);
|
|
|
|
fclose(logfp);
|
1999-01-21 11:02:17 +03:00
|
|
|
}
|
|
|
|
if (scripting) {
|
2003-06-16 23:42:13 +04:00
|
|
|
fprintf(script, "# Script ended at: %s\n",
|
|
|
|
asctime(localtime(&tloc)));
|
1999-01-21 11:02:17 +03:00
|
|
|
fflush(script);
|
|
|
|
fclose(script);
|
|
|
|
}
|
|
|
|
|
1997-12-05 16:38:59 +03:00
|
|
|
if (!exit_cleanly)
|
1999-06-18 12:54:28 +04:00
|
|
|
fprintf(stderr, "\n\nsysinst terminated.\n");
|
1997-12-05 16:38:59 +03:00
|
|
|
}
|
1998-10-25 22:15:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* process function ... */
|
|
|
|
|
2003-06-16 23:42:13 +04:00
|
|
|
void
|
|
|
|
process_f_flag(char *f_name)
|
1998-10-25 22:15:04 +03:00
|
|
|
{
|
2006-01-13 01:02:44 +03:00
|
|
|
char buffer[STRSIZE];
|
|
|
|
int len;
|
|
|
|
const struct f_arg *arg;
|
|
|
|
FILE *fp;
|
|
|
|
char *cp, *cp1;
|
2003-06-16 23:42:13 +04:00
|
|
|
|
2004-11-11 23:17:48 +03:00
|
|
|
/* open the file */
|
2006-01-13 01:02:44 +03:00
|
|
|
fp = fopen(f_name, "r");
|
|
|
|
if (fp == NULL) {
|
2004-11-11 23:17:48 +03:00
|
|
|
fprintf(stderr, msg_string(MSG_config_open_error), f_name);
|
2003-06-16 23:42:13 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
while (fgets(buffer, sizeof buffer, fp) != NULL) {
|
|
|
|
cp = buffer + strspn(buffer, " \t");
|
|
|
|
if (strchr("#\r\n", *cp) != NULL)
|
|
|
|
continue;
|
|
|
|
for (arg = fflagopts; arg->name != NULL; arg++) {
|
|
|
|
len = strlen(arg->name);
|
|
|
|
if (memcmp(cp, arg->name, len) != 0)
|
|
|
|
continue;
|
|
|
|
cp1 = cp + len;
|
|
|
|
cp1 += strspn(cp1, " \t");
|
|
|
|
if (*cp1++ != '=')
|
|
|
|
continue;
|
|
|
|
cp1 += strspn(cp1, " \t");
|
|
|
|
len = strcspn(cp1, " \n\r\t");
|
|
|
|
cp1[len] = 0;
|
|
|
|
strlcpy(arg->var, cp1, arg->size);
|
|
|
|
break;
|
|
|
|
}
|
2003-06-16 23:42:13 +04:00
|
|
|
}
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
fclose(fp);
|
1998-10-25 22:15:04 +03:00
|
|
|
}
|