示例#1
0
void
state_ask_fs(struct i_fn_args *a)
{
	use_hammer = 0;

	switch (dfui_be_present_dialog(a->c, _("Select file system"),
	    _("Use HAMMER|Use UFS|Return to Select Disk"),
	    _("Please select the file system you want to use with %s.\n\n"
	      "HAMMER is the new %s file system.  UFS is the traditional BSD file system."),
	    OPERATING_SYSTEM_NAME,
	    OPERATING_SYSTEM_NAME))
	{
	case 1:
		/* HAMMER */
		use_hammer = 1;
		break;
	case 2:
		/* UFS */
		break;
	case 3:
		state = state_select_disk;
		return;
		/* NOTREACHED */
		break;
	default:
		abort_backend();
		break;
	}
	state = state_create_subpartitions;
}
示例#2
0
void
fn_format_msdos_floppy(struct i_fn_args *a)
{
	struct commands *cmds;

	switch (dfui_be_present_dialog(a->c, _("Format MSDOS Floppy"),
	    _("Format Floppy|Return to Utilities Menu"),
	    _("Please insert the floppy to be formatted "
	    "in unit 0 (``drive A:'')."))) {
	case 1:
		cmds = commands_new();
		command_add(cmds, "%s%s -y -f 1440 /dev/fd0",
		    a->os_root, cmd_name(a, "FDFORMAT"));
		command_add(cmds, "%s%s -f 1440 fd0",
		    a->os_root, cmd_name(a, "NEWFS_MSDOS"));
		if (commands_execute(a, cmds))
			inform(a->c, _("Floppy successfully formatted!"));
		else
			inform(a->c, _("Floppy was not successfully formatted."));
		break;
	case 2:
		return;
	default:
		abort_backend();
	}
}
示例#3
0
/*
 * Finish up the install.
 */
void
state_finish_install(struct i_fn_args *a)
{
	char msg_buf[1][1024];
	during_install = 1;

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    "%s is Installed!",
	    OPERATING_SYSTEM_NAME);

	switch (dfui_be_present_dialog(a->c, msg_buf[0],
	    _("Configure this System|Reboot|Return to Welcome Menu"),
	    _("Congratulations!\n\n"
	    "%s has successfully been installed on "
	    "this computer. You may now proceed to configure "
	    "the installation. Alternately, you may wish to "
	    "reboot the computer and boot into the installed "
	    "system to confirm that it works."),
	    OPERATING_SYSTEM_NAME)) {
	case 1:
		state = state_configure_menu;
		break;
	case 2:
		state = state_reboot;
		break;
	case 3:
		state = state_welcome;
		break;
	default:
		abort_backend();
	}
}
static int
warn_encrypted_boot(struct i_fn_args *a)
{
	int valid = 1;

	struct subpartition *sp;

	sp = subpartition_find(storage_get_selected_slice(a->s), "/boot");
	if (sp == NULL)
		return(!valid);

	if (subpartition_is_encrypted(sp)) {
		switch (dfui_be_present_dialog(a->c, _("/boot cannot be encrypted"),
		    _("Leave /boot unencrypted|Return to Create Subpartitions"),
		    _("You have selected encryption for the /boot partition which "
		    "is not supported."))) {
		case 1:
			subpartition_clr_encrypted(sp);
			valid = 1;
			break;
		case 2:
			valid = 0;
			break;
		default:
			abort_backend();
		}
	}

	return(!valid);
}
示例#5
0
static void
ask_to_wipe_boot_sector(struct i_fn_args *a, struct commands *fcmds)
{
	struct commands *cmds;
	struct command *cmd;
	char *disk;

	for (cmd = command_get_first(fcmds); cmd != NULL;
	     cmd = command_get_next(cmd)) {
		disk = command_get_tag(cmd);
		if (disk != NULL &&
		    command_get_result(cmd) > 0 &&
		    command_get_result(cmd) < 256) {
			switch (dfui_be_present_dialog(a->c,
			    _("Bootblock Install Failed"),
			    _("Re-Initialize Bootblock|Cancel"),
			    _("Warning: bootblocks were not successfully "
			    "installed on the disk `%s'. This may be "
			    "because the disk is new and not yet "
			    "formatted. If this is the case, it might "
			    "help to re-initialize the boot sector, "
			    "then try installing the bootblock again. "
			    "Note that this should not affect the "
			    "partition table of the disk."),
			    disk)) {
			case 1:
				cmds = commands_new();
				command_add(cmds,
				    "%s%s | %s%s -B /dev/%s",
				    a->os_root, cmd_name(a, "YES"),
				    a->os_root, cmd_name(a, "FDISK"),
				    disk);
				if (commands_execute(a, cmds)) {
					inform(a->c, _("Boot sector successfully initialized."));
				} else {
					inform(a->c, _("Some errors occurred. "
					    "Boot sector was not successfully initialized."));
				}
				commands_free(cmds);
				break;
			default:
				break;
			}
		}
	}
}
示例#6
0
void
fn_create_cdboot_floppy(struct i_fn_args *a)
{
	struct commands *cmds;
	char msg_buf[1][1024];

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    "%s cannot be installed from a floppy; "
	    "it must be installed from a booted CD-ROM. "
	    "However, many older systems do not support booting "
	    "from a CD-ROM. For these systems, a boot disk can be "
	    "created. This boot disk contains the Smart Boot "
	    "Manager program, which can boot a CD-ROM even "
	    "on systems with BIOSes which do not support booting "
	    "from the CD-ROM.\n\n"
	    "Smart Boot Manager is not a part of %s; "
	    "the Smart Boot Manager project can be found here:\n\n"
	    "http://btmgr.sourceforge.net/\n\n"
	    "To create a CDBoot floppy, insert a blank floppy "
	    "in unit 0 (``drive A:'') before proceeding."
	    "",
	    OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_NAME);

	switch (dfui_be_present_dialog(a->c, _("Create CDBoot Floppy"),
	    _("Create CDBoot Floppy|Return to Utilities Menu"),
	    "%s", msg_buf[0])) {
	case 1:
		cmds = commands_new();
		command_add(cmds, "%s%s -c %sboot/cdboot.flp.bz2 | "
		    "%s%s of=/dev/fd0 bs=32k",
		    a->os_root, cmd_name(a, "BUNZIP2"),
		    a->os_root,
		    a->os_root, cmd_name(a, "DD"));
		if (commands_execute(a, cmds))
			inform(a->c, _("CDBoot floppy successfully created!"));
		else
			inform(a->c, _("CDBoot floppy was not successfully created."));
		break;
	case 2:
		return;
	default:
		abort_backend();
	}
}
示例#7
0
/*
 * state_format_disk: ask the user if they wish to format the disk they
 * selected.
 */
void
state_format_disk(struct i_fn_args *a)
{
	switch (dfui_be_present_dialog(a->c, _("How Much Disk?"),
	    _("Use Entire Disk|Use Part of Disk|Return to Select Disk"),
	    _("Select how much of this disk you want to use for %s.\n\n%s"),
	    OPERATING_SYSTEM_NAME,
	    disk_get_desc(storage_get_selected_disk(a->s)))) {
	case 1:
		/* Entire Disk */
		if (measure_activated_swap_from_disk(a, storage_get_selected_disk(a->s)) > 0) {
			if (swapoff_all(a) == NULL) {
				inform(a->c, _("Warning: swap could not be turned off."));
				state = state_select_disk;
				return;
			}
		}

		fn_format_disk(a);
		if (a->result)
			state = state_ask_fs;
		else
			state = state_format_disk;
		break;
	case 2:
		/* Part of Disk */
		state = state_select_slice;
		break;
	case 3:
		/* Return */
		state = state_select_disk;
		break;
	default:
		abort_backend();
		break;
	}
}
示例#8
0
void
state_configure_menu(struct i_fn_args *a)
{
	struct dfui_form *f = NULL;
	struct dfui_response *r = NULL;
	struct commands *cmds;
	int done = 0;
	char msg_buf[2][1024];

	if (storage_get_selected_disk(a->s) == NULL || storage_get_selected_slice(a->s) == NULL) {
		if (!survey_storage(a)) {
			inform(a->c, _("Errors occurred while probing "
			    "the system for its storage capabilities."));
		}

		a->short_desc = _("Select the disk containing the installation.");
		a->cancel_desc = _("Return to Welcome Menu");
		fn_select_disk(a);
		if (!a->result || storage_get_selected_disk(a->s) == NULL) {
			state = state_welcome;
			return;
		}

		a->short_desc = _("Select the primary partition containing the installation.");
		a->cancel_desc = _("Return to Welcome Menu");
		fn_select_slice(a);

		if (!a->result || storage_get_selected_slice(a->s) == NULL) {
			state = state_welcome;
			return;
		}
	}

	a->cfg_root = "mnt";

	if (during_install == 0) {
		switch (dfui_be_present_dialog(a->c, _("Select file system"),
		    _("HAMMER|UFS|Return to Welcome Menu"),
		    _("Please select the file system installed on the disk.\n\n")))
		{
		case 1:
			/* HAMMER */
			use_hammer = 1;
			break;
		case 2:
			/* UFS */
			use_hammer = 0;
			break;
		case 3:
			state = state_welcome;
			return;
			/* NOTREACHED */
			break;
		default:
			abort_backend();
			break;
		}
	}

	if (!mount_target_system(a)) {
		inform(a->c, _("Target system could not be mounted."));
		state = state_welcome;
		return;
	}

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("The options on this menu allow you to configure a "
	    "%s system after it has already been "
	    "installed."), OPERATING_SYSTEM_NAME);

	while (!done) {
		f = dfui_form_create(
		    "configure_menu",
		    _("Configure an Installed System"),
		    msg_buf[0],
		    "",
		    "p", "role", "menu",

		    "a", "set_timezone",
		    _("Select timezone"),
		    _("Set the Time Zone of your physical location"), "",
		    "a", "set_datetime",
		    _("Set date and time"),
		    _("Set the Time and Date of your machine"), "",

		    "a", "set_kbdmap",
		    _("Set keyboard map"),
		    _("Set what kind of keyboard layout you have"), "",
		    "a", "root_passwd",	_("Set root password"),
		    _("Set the password that the root (superuser) account will use"), "",
		    "a", "add_user", _("Add a user"),
		    _("Add a user to the system"), "",
		    "a", "assign_ip", _("Configure network interfaces"),
		    _("Set up network interfaces (NICs, ethernet, TCP/IP, etc)"), "",
		    "a", "assign_hostname_domain",
		    _("Configure hostname and domain"),
		    _("Configure the hostname and domain for this system"), "",
		    /*
		    "a", "select_services", "Select Services",
		    "Enable/Disable system services (servers, daemons, etc.)", "",
		    */
		    "a", "set_vidfont",
		    _("Set console font"),
		    _("Set how the characters on your video console look"), "",
		    "a", "set_scrnmap",
		    _("Set screen map"),
		    _("Set how characters are translated before console display"), "",
		    /*
		    "a", "install_pkgs", _("Install extra software packages"),
		    _("Install third-party software packages from the LiveCD"), "",
		    */
		    "a", "remove_pkgs",	_("Remove software packages"),
		    _("Remove third-party software packages from the installed system"), "",

		    "a", "cancel", _("Return to Welcome Menu"), "", "",
		    "p", "accelerator", "ESC",

		    NULL
		);

		if (!dfui_be_present(a->c, f, &r))
			abort_backend();

		/* XXX set up a */
		a->cfg_root = "mnt/";
		if (strcmp(dfui_response_get_action_id(r), "root_passwd") == 0) {
			fn_root_passwd(a);
		} else if (strcmp(dfui_response_get_action_id(r), "add_user") == 0) {
			fn_add_user(a);
		} else if (strcmp(dfui_response_get_action_id(r), "install_pkgs") == 0) {
			fn_install_packages(a);
		} else if (strcmp(dfui_response_get_action_id(r), "remove_pkgs") == 0) {
			fn_remove_packages(a);
		} else if (strcmp(dfui_response_get_action_id(r), "assign_ip") == 0) {
			fn_assign_ip(a);
		} else if (strcmp(dfui_response_get_action_id(r), "assign_hostname_domain") == 0) {
			fn_assign_hostname_domain(a);
		} else if (strcmp(dfui_response_get_action_id(r), "select_services") == 0) {
			fn_select_services(a);
		} else if (strcmp(dfui_response_get_action_id(r), "set_kbdmap") == 0) {
			fn_set_kbdmap(a);
		} else if (strcmp(dfui_response_get_action_id(r), "set_vidfont") == 0) {
			fn_set_vidfont(a);
		} else if (strcmp(dfui_response_get_action_id(r), "set_scrnmap") == 0) {
			fn_set_scrnmap(a);
		} else if (strcmp(dfui_response_get_action_id(r), "set_timezone") == 0) {
			fn_set_timezone(a);
		} else if (strcmp(dfui_response_get_action_id(r), "set_datetime") == 0) {
			fn_assign_datetime(a);
		} else if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
			state = state_welcome;
			done = 1;
		}

		dfui_form_free(f);
		dfui_response_free(r);
	}

	/*
	 * Before unmounting the system, write out any changes to rc.conf.
	 */
	config_vars_write(rc_conf, CONFIG_TYPE_SH,
	    "%s%setc/rc.conf", a->os_root, a->cfg_root);

	/*
	 * Clear out configuration variable table in memory.
	 */
	config_vars_free(rc_conf);
	rc_conf = config_vars_new();

	/*
	 * Finally, unmount the system we mounted on /mnt and remove mappings.
	 */
	cmds = commands_new();
	unmount_all_under(a, cmds, "%smnt", a->os_root);
	commands_execute(a, cmds);
	commands_free(cmds);

	if (remove_all_mappings(a) == NULL)
		inform(a->c, _("Warning: mappings could not be removed."));
}
示例#9
0
/*
 *
 *  state_setup_remote_installation_server:
 *  Setup a remote boot installation environment where a machine
 *  can boot via DHCP/TFTP/NFS and have a running environment
 *  where the installer can setup the machine.
 *
 */
void
state_setup_remote_installation_server(struct i_fn_args *a)
{
        FILE *p;
        struct commands *cmds;
        struct dfui_form *f;
	struct dfui_action *k;
        struct dfui_response *r;
        char *word;
        char interface[256];
        char line[256];

        switch (dfui_be_present_dialog(a->c, _("Enable Netboot Installation Services?"),
            _("Enable NetBoot Installation Services|No thanks"),
            _("NetBoot Installation Services allows this machine to become "
            "a Installation Server that will allow the clients to boot over the network "
	    "via PXE and start the Installation Environment."
	    "\n\n*NOTE!*  This will assign the IP Address of 10.1.0.1/24 to the selected interface."
            "\n\nWould you like to provision this machine to serve up the LiveCD/Installer?"))) {
		case 1:
			/*
			 * Get interface list.
			 */
			p = popen("/sbin/ifconfig -l", "r");
			/* XXX it's possible (though extremely unlikely) this will fail. */
			while (fgets(line, 255, p) != NULL)
				line[strlen(line) - 1] = '\0';
			pclose(p);

			f = dfui_form_create(
			    "assign_ip",
			    _("Setup NetBoot Installation Environment"),
			    _("Please select which interface you would like to configure:"),
			    "",
			    "p",        "role", "menu",
			    NULL
			);

			/* Loop through array. */
			word = strtok(line, " \t");
			while (word != NULL) {
				dfui_form_action_add(f, word,
				    dfui_info_new(word, "", ""));
				word = strtok(NULL, " ");
			}

			k = dfui_form_action_add(f, "cancel",
			    dfui_info_new("Cancel", "", ""));
			dfui_action_property_set(k, "accelerator", "ESC");

			if (!dfui_be_present(a->c, f, &r))
			abort_backend();

			strlcpy(interface, dfui_response_get_action_id(r), 256);

			if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
				dfui_form_free(f);
				dfui_response_free(r);
				return;
			}

			/*
			 *
			 * Issues the necessary commands to setup the remote boot environment
			 *
			 */
			cmds = commands_new();
			command_add(cmds, "%s%s %s 10.1.0.1 netmask 255.255.255.0",
			    a->os_root, cmd_name(a, "IFCONFIG"), interface);
			command_add(cmds, "%s%s -p %stftpdroot",
			    a->os_root, cmd_name(a, "MKDIR"), a->tmp);
			command_add(cmds, "%s%s %sboot/pxeboot %stftpdroot",
			    a->os_root, cmd_name(a, "CP"), a->os_root, a->tmp);
			command_add(cmds, "%s%s %s -ro -alldirs -maproot=root: -network 10.1.0.0 -mask 255.255.255.0 >> %setc/exports",
			    a->os_root, cmd_name(a, "ECHO"), a->os_root, a->os_root);
			command_add(cmds, "%s%s tftp dgram udp wait root %s%s tftpd -l -s %stftpdroot >> %setc/inetd.conf",
			    a->os_root, cmd_name(a, "ECHO"),
			    a->os_root, cmd_name(a, "TFTPD"),
			    a->tmp, a->os_root);
			command_add(cmds, "%s%s",
			    a->os_root, cmd_name(a, "INETD"));
			command_add(cmds, "%s%s %svar/db/dhcpd.leases",
			    a->os_root, cmd_name(a, "TOUCH"), a->os_root);
			command_add(cmds, "%s%s -cf /etc/dhcpd.conf >%sdev/null 2>&1",
			    a->os_root, cmd_name(a, "DHCPD"), a->os_root);
			command_add(cmds, "%s%s >%sdev/null 2>&1",
			    a->os_root, cmd_name(a, "RPCBIND"), a->os_root);
			command_add(cmds, "%s%s -ln >%sdev/null 2>&1",
			    a->os_root, cmd_name(a, "MOUNTD"), a->os_root);
			command_add(cmds, "%s%s -u -t -n 6 >%sdev/null 2>&1",
			    a->os_root, cmd_name(a, "NFSD"), a->os_root);

			if (commands_execute(a, cmds)) {
				inform(a->c, _("NetBoot installation services are now started."));
			} else {
				inform(a->c, _("A failure occurred while provisioning the NetBoot environment.  Please check the logs."));
			}

			commands_free(cmds);
			dfui_form_free(f);
			dfui_response_free(r);

			break;
		case 2:

			break;

	};

	state = state_welcome;

}
示例#10
0
/*
 * Execute a single command.
 * Return value is a COMMAND_RESULT_* constant, or
 * a value from 0 to 255 to indicate the exit code
 * from the utility.
 */
static int
command_execute(struct i_fn_args *a, struct dfui_progress *pr,
		struct command *cmd)
{
	FILE *log = NULL;
	char *filename;
	int cancelled = 0, done = 0, report_done = 0;

	if (cmd->desc != NULL)
		dfui_info_set_short_desc(dfui_progress_get_info(pr), cmd->desc);
	else
		dfui_info_set_short_desc(dfui_progress_get_info(pr), cmd->cmdline);

	if (!dfui_be_progress_update(a->c, pr, &cancelled))
		  abort_backend();

	while (!done) {
		asprintf(&filename, "%sinstall.log", a->tmp);
		log = fopen(filename, "a");
		free(filename);

		if (cmd->log_mode != COMMAND_LOG_SILENT)
			i_log(a, ",-<<< Executing `%s'", cmd->cmdline);
		cmd->result = pipe_loop(a, pr, cmd, &cancelled);
		if (cmd->log_mode != COMMAND_LOG_SILENT)
			i_log(a, "`->>> Exit status: %d\n", cmd->result);

		if (log != NULL)
			fclose(log);

		if (cancelled) {
			if (!dfui_be_progress_end(a->c))
				abort_backend();

			report_done = 0;
			while (!report_done) {
				switch (dfui_be_present_dialog(a->c, "Cancelled",
				    "View Log|Retry|Cancel|Skip",
				    "Execution of the command\n\n%s\n\n"
				    "was cancelled.",
				    cmd->cmdline)) {
				case 1:
					/* View Log */
					view_command_log(a);
					break;
				case 2:
					/* Retry */
					cancelled = 0;
					report_done = 1;
					break;
				case 3:
					/* Cancel */
					cmd->result = COMMAND_RESULT_CANCELLED;
					report_done = 1;
					done = 1;
					break;
				case 4:
					/* Skip */
					cmd->result = COMMAND_RESULT_SKIPPED;
					report_done = 1;
					done = 1;
					break;
				}
			}

			if (!dfui_be_progress_begin(a->c, pr))
				abort_backend();

		} else if (cmd->failure_mode == COMMAND_FAILURE_IGNORE) {
			cmd->result = 0;
			done = 1;
		} else if (cmd->result != 0 && cmd->failure_mode != COMMAND_FAILURE_WARN) {
			if (!dfui_be_progress_end(a->c))
				abort_backend();

			report_done = 0;
			while (!report_done) {
				switch (dfui_be_present_dialog(a->c, "Command Failed!",
				    "View Log|Retry|Cancel|Skip",
				    "Execution of the command\n\n%s\n\n"
				    "FAILED with a return code of %d.",
				    cmd->cmdline, cmd->result)) {
				case 1:
					/* View Log */
					view_command_log(a);
					break;
				case 2:
					/* Retry */
					report_done = 1;
					break;
				case 3:
					/* Cancel */
					/* XXX need a better way to retain actual result */
					cmd->result = COMMAND_RESULT_CANCELLED;
					report_done = 1;
					done = 1;
					break;
				case 4:
					/* Skip */
					/* XXX need a better way to retain actual result */
					cmd->result = COMMAND_RESULT_SKIPPED;
					report_done = 1;
					done = 1;
					break;
				}
			}

			if (!dfui_be_progress_begin(a->c, pr))
				abort_backend();

		} else {
			done = 1;
		}
	}

	return(cmd->result);
}