1994-10-20 02:51:55 +00:00
|
|
|
/*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
|
|
* <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
|
|
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
|
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*
|
1995-02-13 06:52:16 +00:00
|
|
|
* $Id: main.c,v 1.20 1995/01/30 03:19:52 phk Exp $
|
1994-10-20 02:51:55 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1994-10-20 05:00:00 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
1994-11-11 23:22:56 +00:00
|
|
|
#include <signal.h>
|
1994-10-20 05:00:00 +00:00
|
|
|
|
|
|
|
#include <dialog.h>
|
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
1994-10-21 02:14:54 +00:00
|
|
|
#include <sys/reboot.h>
|
1994-10-20 05:00:00 +00:00
|
|
|
|
|
|
|
#define EXTERN /* only in main.c */
|
|
|
|
|
|
|
|
#include "sysinstall.h"
|
|
|
|
|
1994-11-11 23:22:56 +00:00
|
|
|
void
|
|
|
|
handle_intr(int sig)
|
|
|
|
{
|
1994-11-17 23:36:49 +00:00
|
|
|
dialog_clear_norefresh();
|
1994-11-11 23:22:56 +00:00
|
|
|
dialog_msgbox("User Interrupt",
|
|
|
|
"User interrupted. Aborting the installation",
|
1994-11-17 19:44:55 +00:00
|
|
|
-1, -1, 1);
|
1994-11-11 23:22:56 +00:00
|
|
|
ExitSysinstall();
|
|
|
|
}
|
|
|
|
|
1994-10-20 02:51:55 +00:00
|
|
|
int
|
1994-10-20 05:00:00 +00:00
|
|
|
main(int argc, char **argv)
|
1994-10-20 02:51:55 +00:00
|
|
|
{
|
1994-11-11 23:22:56 +00:00
|
|
|
signal(SIGINT, SIG_IGN);
|
|
|
|
|
1994-10-20 05:00:00 +00:00
|
|
|
/* Are we running as init? */
|
1995-02-13 06:52:16 +00:00
|
|
|
cpio_fd = -1;
|
1994-10-20 05:00:00 +00:00
|
|
|
if (getpid() == 1) {
|
1994-11-08 18:44:14 +00:00
|
|
|
setsid();
|
1995-02-13 06:52:16 +00:00
|
|
|
if (argc > 1 && strchr(argv[1],'C')) {
|
|
|
|
/* Kernel told us that we are on a CDROM root */
|
|
|
|
close(0); open("/bootcd/dev/console",O_RDWR);
|
|
|
|
close(1); dup(0);
|
|
|
|
close(2); dup(0);
|
|
|
|
cpio_fd = open("/floppies/cpio.flp",O_RDONLY);
|
|
|
|
on_cdrom++;
|
|
|
|
chroot("/bootcd");
|
|
|
|
} else {
|
|
|
|
close(0); open("/dev/console",O_RDWR);
|
|
|
|
close(1); dup(0);
|
|
|
|
close(2); dup(0);
|
|
|
|
}
|
1994-10-29 10:01:40 +00:00
|
|
|
printf("sysinstall running as init\n\r");
|
1994-11-08 18:44:14 +00:00
|
|
|
ioctl(0,TIOCSCTTY,(char *)NULL);
|
1994-10-20 05:00:00 +00:00
|
|
|
setlogin("root");
|
1995-01-29 02:31:38 +00:00
|
|
|
setbuf(stdin,0);
|
|
|
|
setbuf(stdout,0);
|
|
|
|
setbuf(stderr,0);
|
1994-10-20 05:00:00 +00:00
|
|
|
}
|
|
|
|
if (set_termcap() == -1) {
|
|
|
|
Fatal("Can't find terminal entry\n");
|
|
|
|
}
|
|
|
|
/* XXX too early to use fatal ! */
|
|
|
|
|
|
|
|
/* XXX - libdialog has particularly bad return value checking */
|
|
|
|
init_dialog();
|
|
|
|
/* If we haven't crashed I guess dialog is running ! */
|
|
|
|
dialog_active = 1;
|
|
|
|
|
1994-11-11 23:22:56 +00:00
|
|
|
signal(SIGINT, handle_intr);
|
|
|
|
|
1994-11-06 04:05:45 +00:00
|
|
|
if (getpid() != 1) {
|
|
|
|
stage0();
|
|
|
|
stage1();
|
1994-11-06 04:34:46 +00:00
|
|
|
end_dialog();
|
|
|
|
dialog_active=0;
|
1994-11-06 04:05:45 +00:00
|
|
|
} else if (!access("/this_is_boot_flp",R_OK)) {
|
1994-11-12 05:40:28 +00:00
|
|
|
while(1) {
|
|
|
|
stage0();
|
|
|
|
if(!stage1())
|
|
|
|
break;
|
|
|
|
}
|
1994-10-20 05:00:00 +00:00
|
|
|
stage2();
|
1994-11-06 04:05:45 +00:00
|
|
|
end_dialog();
|
|
|
|
dialog_active=0;
|
1994-10-21 02:14:54 +00:00
|
|
|
reboot(RB_AUTOBOOT);
|
1994-10-20 06:14:29 +00:00
|
|
|
} else {
|
1994-10-26 02:53:15 +00:00
|
|
|
stage3();
|
|
|
|
stage5();
|
1994-10-20 06:48:40 +00:00
|
|
|
}
|
1994-10-20 02:51:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|