#!/usr/bin/perl

# dialog requires a shell, unfortunately.  But I guess we
# wanted to have a shell anyway.

# Copyright (C) 1995 Red Hat Software, Inc.

require "dialog";
require "mount_rh";
require "probe_cd";
require "misc";
require "net";
require "nfs_mount";
require "xinst";
require "pcmcia";
require "fdisk";
require "swap";
require "mouse";
require "dispatch";
require "xinstall";

$express_install = 0;

$rh_testing = 0;

$fsmount = "/mnt";

#$rh_mounted = 1;
#$rh_available = 1;
#$rh_mountpath = "/mnt/rhscd";

$* = 1;

# The boot disk is on    /bootdisk
# The 2nd rootdisk is on /ramdisk
# The CD instimage is on /image

$ENV{'PATH'} = "/bin:/usr/bin:/usr/bin/X11:/usr/X11/bin:/sbin:/usr/sbin";
$ENV{'PATH'} .= ":/mnt/bin:/mnt/usr/bin:/mnt/sbin:/mnt/usr/sbin";

# Set $scr_lines here if we need to
# This is used by the perl interface to dialog
$scr_lines = 24;

&rhs_msgbox ( "Red Hat Commercial Linux",
<<EOM
Welcome to the Red Hat Commercial Linux installation program!
>
Red Hat Software has worked very hard to bring you the highest
quality Linux system and the easiest and most
flexible installation procedure.
>
If you managed to get this far with all your hardware
detected, the hard part is done!
>
This script will walk you through each step
of the installation.
>
PLEASE BE SURE YOU HAVE READ AND UNDERSTOOD THE INSTALLATION
GUIDE IN THE MANUAL BEFORE YOU PROCEED.  It is probably a good
idea to have the manual available for reference too.
>
Copyright (C) 1995 Red Hat Software, Inc.
EOM
	     , 74);

&rhs_msgbox ( "Boot Floppy",
<<EOM
>
Now please remove the root floppy and insert the boot
floppy.  During the installation, the kernel will be
copied from the boot floppy to your hard drive.
>
Please insert your BOOT disk (not the ROOT disk) in /dev/fd0 (DOS drive A:).
>
EOM
	     , 70);

&invoke("mount /dev/fd0 /bootdisk");

while (! -f "/bootdisk/vmlinuz") {
    &invoke_no_output("umount /bootdisk");

    &rhs_msgbox ( "Boot Floppy",
<<EOM
>
That was not the boot floppy disk!
>
Be sure you are inserting the BOOT FLOPPY DISK in
/dev/fd0 (DOS drive A:).
>
EOM
	     , 70);

    &invoke("mount /dev/fd0 /bootdisk");
}

$ret = &pcmcia_init;

$express_install = &rhs_yesno("Red Hat Commercial Linux",
<<EOM
>
The Express Install provides the simplest installation by
taking you through each installation step in order.
>
Do you want to do an Express Install?
>
EOM
			      , 70);

$installtype = "";
while ($installtype eq "") {
    if (&rhs_yesno("Installation Type",
<<EOM
>
Will you be doing an FTP installation?
> 
EOM
		   , 70)) {
	$installtype = "FTP";
    } else {
	# Find out if they want to do a X based install or a text mode one
	if (&rhs_menu("Installation Type",
<<EOM
>
Red Hat supports two types of CD (or NFS) based installation interfaces. One 
is a X based graphical interface which is more powerful
and much easier to use. However, some people have difficulty
getting X set up, so we provide a simpler text only installation
procedure as an alternative.
>
Which would you prefer?
> 
EOM
		      , 70, 2, 
		      "X", "Graphical Installation",
		      "text", "Text based install"
		      )) {
	    $installtype = $dialog_result;
	}
    }
}

&install_dispatcher;

system("umount /bootdisk");

&rhs_msgbox ( "Installation Complete",
<<EOM
>
When you hit enter your computer will be rebooted.
>
Be sure to remove the boot floppy from your floppy drive!
>
EOM
	     , 70);

exit 0;
