示例#1
0
/*
 * Execute a series of external utility programs.
 * Returns 1 if everything executed OK, 0 if one of the
 * critical commands failed or if the user cancelled.
 */
int
commands_execute(struct i_fn_args *a, struct commands *cmds)
{
	struct dfui_progress *pr;
	struct command *cmd;
	int i;
	int n = 0;
	int result = 0;
	int return_val = 1;

	cmd = cmds->head;
	while (cmd != NULL) {
		n++;
		cmd = cmd->next;
	}

	pr = dfui_progress_new(dfui_info_new(
	    "Executing Commands",
	    "Executing Commands",
	    ""),
	    0);

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

	i = 1;
	for (cmd = cmds->head; cmd != NULL; cmd = cmd->next, i++) {
		result = command_execute(a, pr, cmd);
		if (result == COMMAND_RESULT_CANCELLED) {
			return_val = 0;
			break;
		}
		if (result > 0 && result < 256) {
			return_val = 0;
			if (cmd->failure_mode == COMMAND_FAILURE_ABORT) {
				break;
			}
		}
		dfui_progress_set_amount(pr, (i * 100) / n);
	}

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

	dfui_progress_free(pr);

	return(return_val);
}
示例#2
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;
}
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);
}
示例#4
0
void
fn_show_atacontrol(struct i_fn_args *a)
{
	struct aura_buffer *e;
	struct dfui_form *f;
	struct dfui_response *r;

	e = aura_buffer_new(1024);
	aura_buffer_cat_pipe(e, "atacontrol list");

	f = dfui_form_create(
	    "atacontrol",
	    _("ATA Devices"),
	    aura_buffer_buf(e),
	    "",

	    "p", "role", "informative",
	    "p", "minimum_width", "72",
	    "p", "monospaced", "true",

	    "a", "ok", _("OK"), "", "",
	    "p", "accelerator", "ESC",

	    NULL
	);

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

	dfui_form_free(f);
	dfui_response_free(r);

	aura_buffer_free(e);
}
示例#5
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();
	}
}
示例#6
0
void
view_memtest_log(struct i_fn_args *a)
{
	struct aura_buffer *error_log;
	struct dfui_form *f;
	struct dfui_response *r;

	error_log = aura_buffer_new(1024);
	aura_buffer_cat_file(error_log, "%smemtest.log", a->tmp);

	f = dfui_form_create(
	    "error_log",
	    _("Error Log"),
	    aura_buffer_buf(error_log),
	    "",

	    "p", "role", "informative",
	    "p", "minimum_width", "72",
	    "p", "monospaced", "true",

	    "a", "ok", _("OK"), "", "",
	    "p", "accelerator", "ESC",

	    NULL
	);

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

	dfui_form_free(f);
	dfui_response_free(r);

	aura_buffer_free(error_log);
}
示例#7
0
void 
fn_show_dmesg(struct i_fn_args *a)
{
	struct aura_buffer *e;
	struct dfui_form *f;
	struct dfui_response *r;

	e = aura_buffer_new(1024);
	aura_buffer_cat_file(e, "%s%s", a->os_root, cmd_name(a, "DMESG_BOOT"));

	f = dfui_form_create(
	    "dmesg",
	    _("System Startup Messages (dmesg)"),
	    aura_buffer_buf(e),
	    "",

	    "p", "role", "informative",
	    "p", "minimum_width", "72",
	    "p", "monospaced", "true",

	    "a", "ok", _("OK"), "", "",
	    "p", "accelerator", "ESC",

	    NULL
	);

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

	dfui_form_free(f);
	dfui_response_free(r);

	aura_buffer_free(e);
}
示例#8
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();
	}
}
示例#9
0
void
state_lang_menu(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_response *r;
	int done = 0;
	char *id;
	int cancelled = 0;

	while (!done) {
		f = dfui_form_create(
			"main_menu",
			_("Select Language"),
			_("Please select the language you wish you use."),
			"",

			"p", "role", "menu",

			"a", "default", "English",
			"English Standard Default", "",
			"a", "ru", "Russian",
			"Russian KOI8-R", "",
			NULL
		);

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

		id = aura_strdup(dfui_response_get_action_id(r));

		if (strcmp(id, "default") == 0) {
			state = state_welcome;
			return;
		} else {
			state = state_welcome;
			done = 1;
		}

		dfui_form_free(f);
		dfui_response_free(r);
	}

	/* set keymap, scrnmap, fonts */
	if (!set_lang_syscons(id))
		return;

	/* set envars */
	if (!set_lang_envars(id))
		return;

	dfui_be_set_global_setting(a->c, "lang", id, &cancelled);

	/* XXX if (!cancelled) ... ? */

	/* let gettext know about changes */
	++_nl_msg_cat_cntr;
}
示例#10
0
void
state_diagnostics_menu(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_action *k;
	struct dfui_response *r;
	int done = 0;

	while (!done) {
		f = dfui_form_create(
		    "utilities_menu",
		    _("Live CD Diagnostics Menu"),
		    _("These functions can help you diagnose this system."),
		    "",
		    "p", "role", "menu",

		    "a", "show_dmesg",
		    _("Display system startup messages"),
		    _("Display system startup messages (dmesg)"), "",
		    "a", "pciconf",
		    _("Display PCI devices"),
		    _("Display PCI devices (pciconf)"), "",
		    "a", "pnpinfo",
		    _("Display Plug'n'Play ISA devices"),
		    _("Display Plug'n'Play ISA devices (pnpinfo)"), "",
		    "a", "natacontrol",
		    _("Display ATA devices"),
		    _("Display ATA devices (natacontrol)"), "",
		    NULL
		);

		k = dfui_form_action_add(f, "cancel",
		    dfui_info_new(_("Return to Utilities Menu"), "", ""));
		dfui_action_property_set(k, "accelerator", "ESC");

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

		/* XXX set up a */
		if (strcmp(dfui_response_get_action_id(r), "show_dmesg") == 0) {
			fn_show_dmesg(a);
		} else if (strcmp(dfui_response_get_action_id(r), "pciconf") == 0) {
			fn_show_pciconf(a);
		} else if (strcmp(dfui_response_get_action_id(r), "pnpinfo") == 0) {
			fn_show_pnpinfo(a);
		} else if (strcmp(dfui_response_get_action_id(r), "natacontrol") == 0) {
			fn_show_natacontrol(a);
		} else if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
			state = state_utilities_menu;
			done = 1;
		}

		dfui_form_free(f);
		dfui_response_free(r);
	}
}
示例#11
0
void
state_utilities_menu(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_response *r;

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

	f = dfui_form_create(
	    "utilities_menu",
	    _("Live CD Utilities Menu"),
	    _("On these submenus you will find utilities to help "
	    "you set up your Live CD environment, diagnose "
	    "and analyse this system, and work with "
	    "the devices attached to this computer."),
	    "",
	    "p", "role", "menu",
	    "a", "environment", _("LiveCD Environment"),
	    _("Configure the LiveCD Environment"), "",
	    "a", "diagnostics", _("System Diagnostics"),
	    _("Probe and display detailed information about this system"), "",
	    "a", "diskutil", _("Disk Utilities"),
	    _("Format and check hard drives and floppy disks"), "",
	    "a", "livecd", _("Exit to Live CD"),
	    _("Exit this program to a login prompt with access to the LiveCD"), "",
	    "a", "reboot",
	    _("Reboot this Computer"), "", "",
	    "a", "cancel",
	    _("Return to Welcome Menu"), "", "",
	    "p", "accelerator", "ESC",
	    NULL
	);

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

	if (strcmp(dfui_response_get_action_id(r), "environment") == 0)
		state = state_environment_menu;
	else if (strcmp(dfui_response_get_action_id(r), "diagnostics") == 0)
		state = state_diagnostics_menu;
	else if (strcmp(dfui_response_get_action_id(r), "diskutil") == 0)
		state = state_diskutil_menu;
	else if (strcmp(dfui_response_get_action_id(r), "livecd") == 0)
		state = NULL;
	else if (strcmp(dfui_response_get_action_id(r), "reboot") == 0)
		state = state_reboot;
	else if (strcmp(dfui_response_get_action_id(r), "cancel") == 0)
		state = state_welcome;

	dfui_form_free(f);
	dfui_response_free(r);
}
示例#12
0
/*
 * Returns:
 *	-1 = the form should be redisplayed
 *	 0 = failure, function is over
 *	 1 = success, function is over
 */
static int
show_create_subpartitions_form(struct dfui_form *f, struct i_fn_args *a)
{
	struct dfui_dataset *ds;
	struct dfui_response *r;

	for (;;) {
		if (dfui_form_dataset_get_first(f) == NULL)
			populate_create_subpartitions_form(f, a);

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

		if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
			dfui_response_free(r);
			return(0);
		} else if (strcmp(dfui_response_get_action_id(r), "switch") == 0) {
			if (check_subpartition_selections(r, a)) {
				save_subpartition_selections(r, a);
				expert = expert ? 0 : 1;
				dfui_response_free(r);
				return(-1);
			}
		} else {
			if (check_subpartition_selections(r, a)) {
				save_subpartition_selections(r, a);
				if (!warn_subpartition_selections(a) &&
				    !warn_encrypted_boot(a)) {
					if (!create_subpartitions(a)) {
						inform(a->c, _("The subpartitions you chose were "
							"not correctly created, and the "
							"primary partition may "
							"now be in an inconsistent state. "
							"We recommend re-formatting it "
							"before proceeding."));
						dfui_response_free(r);
						return(0);
					} else {
						dfui_response_free(r);
						return(1);
					}
				}
			}
		}

		dfui_form_datasets_free(f);
		/* dfui_form_datasets_add_from_response(f, r); */
		for (ds = dfui_response_dataset_get_first(r); ds != NULL;
		    ds = dfui_dataset_get_next(ds)) {
			dfui_form_dataset_add(f, dfui_dataset_dup(ds));
		}
	}
}
示例#13
0
/*
 * Ask the user which slice on a the selected disk they want.
 * Changes ss->selected_slice.
 */
void
fn_select_slice(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_action *k;
	struct dfui_response *r;
	struct slice *s;
	char string[16];

	f = dfui_form_create(
	    "select_slice",
	    _("Select Primary Partition"),
	    a->short_desc,
	    "",

	    "p", "role", "menu",
	    "p", "special", "dfinstaller_select_slice",

	    NULL
	);

	for (s = disk_slice_first(storage_get_selected_disk(a->s));
	     s != NULL; s = slice_next(s)) {
		snprintf(string, 16, "%d", slice_get_number(s));
		dfui_form_action_add(f, string,
		    dfui_info_new(slice_get_desc(s), "", ""));
	}

	k = dfui_form_action_add(f, "cancel",
	    dfui_info_new(a->cancel_desc, "", ""));
	dfui_action_property_set(k, "accelerator", "ESC");

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

	if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
		a->result = 0;
	} else {
		s = slice_find(storage_get_selected_disk(a->s),
		    atoi(dfui_response_get_action_id(r)));
		if (s == NULL) {
			inform(a->c, _("Internal error - response from frontend "
			    "should be a valid slice number."));
			a->result = 0;
		} else {
			storage_set_selected_slice(a->s, s);
			a->result = 1;
		}
	}

	dfui_form_free(f);
	dfui_response_free(r);
}
示例#14
0
/*
 * Ask the user which physical disk they want.
 * Changes ss->selected_disk if successful.
 */
void
fn_select_disk(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_action *k;
	struct dfui_response *r;
	struct disk *d;

	f = dfui_form_create(
	    "select_disk",
	    _("Select Disk"),
	    a->short_desc,
	    "",

	    "p", "role",  "menu",
	    "p", "special", "dfinstaller_select_disk",

	    NULL
	);

	for (d = storage_disk_first(a->s); d != NULL; d = disk_next(d)) {
		dfui_form_action_add(f, disk_get_device_name(d),
		    dfui_info_new(disk_get_desc(d), "", ""));
	}

	k = dfui_form_action_add(f, "cancel",
	    dfui_info_new(a->cancel_desc, "", ""));
	dfui_action_property_set(k, "accelerator", "ESC");

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

	if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
		a->result = 0;
	} else {
		d = disk_find(a->s, dfui_response_get_action_id(r));
		if (d == NULL) {
			inform(a->c, _("Internal error - response from frontend "
			    "should be a valid device name."));
			a->result = 0;
		} else {
			storage_set_selected_disk(a->s, d);
			a->result = 1;
		}
	}

	dfui_form_free(f);
	dfui_response_free(r);
}
示例#15
0
/*
 * state_install_os: actually put DragonFly on the disk.
 */
void
state_install_os(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_response *r;
	char msg_buf[1][1024];

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("Everything is now ready to install the actual files which "
	    "comprise the %s operating system "
	    "on the selected partition of the selected disk.\n\n"
	    "Note that this process will take quite a while to finish. "
	    "You may wish to take a break now and come back to the "
	    "computer in a short while."),
	    OPERATING_SYSTEM_NAME);

	f = dfui_form_create(
	    "install_os",
	    _("Install OS"),
	    msg_buf[0],

	    "",

	    "p", "role", "confirm",
	    "p", "special", "dfinstaller_install_os",

	    "a", "ok", _("Begin Installing Files"), "", "",
	    "a", "cancel", _("Return to Create Subpartitions"), "", "",
	    "p", "accelerator", "ESC",

	    NULL
	);

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

	if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
		state = state_create_subpartitions;
	} else {
		fn_install_os(a);
		if (a->result)
			state = state_install_bootstrap;
	}

	dfui_form_free(f);
	dfui_response_free(r);
}
示例#16
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();
	}
}
示例#17
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;
	}
}
示例#18
0
/*
 * state_reboot: reboot the machine.
 */
void
state_reboot(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_response *r;

	f = dfui_form_create(
	    "reboot",
	    _("Reboot"),
	    _("This machine is about to be shut down. "
	    "After the machine has reached its shutdown state, "
	    "you may remove the CD from the CD-ROM drive tray "
	    "and press Enter to reboot from the HDD."),

	    "",

	    "p", "role", "confirm",

	    "a", "ok", _("Reboot"), "", "",
	    "a", "cancel", _("Return to Welcome Menu"), "", "",
	    "p", "accelerator", "ESC",
	    NULL
	);

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

	if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
		state = state_welcome;
	} else {
		do_reboot = 1;
		state = NULL;
	}

	dfui_form_free(f);
	dfui_response_free(r);
}
示例#19
0
void
fn_install_bootblocks(struct i_fn_args *a, const char *device)
{
	struct dfui_form *f;
	struct dfui_response *r;
	struct dfui_dataset *ds;
	struct disk *d;
	struct commands *cmds;
	struct command *cmd;
	char disk[64], boot0cfg[32], packet[32];
	char msg_buf[1][1024];

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    "'Packet Mode' refers to using newer BIOS calls to boot "
	    "from a partition of the disk.  It is generally not "
	    "required unless:\n\n"
	    "- your BIOS does not support legacy mode; or\n"
	    "- your %s primary partition resides on a "
	    "cylinder of the disk beyond cylinder 1024; or\n"
	    "- you just can't get it to boot without it.",
	    OPERATING_SYSTEM_NAME);

	f = dfui_form_create(
	    "install_bootstrap",
	    _("Install Bootblock(s)"),
	    a->short_desc,

	    msg_buf[0],

	    "p", "special", "dfinstaller_install_bootstrap",

	    "f", "disk", _("Disk Drive"),
	    _("The disk on which you wish to install a bootblock"), "",
	    "p", "editable", "false",
	    "f", "boot0cfg", _("Install Bootblock?"),
	    _("Install a bootblock on this disk"), "",
	    "p", "control", "checkbox",
	    "f", "packet", _("Packet Mode?"),
	    _("Select this to use 'packet mode' to boot the disk"), "",
	    "p", "control", "checkbox",

	    "a", "ok", _("Accept and Install Bootblocks"), "", "",
	    "a", "cancel", a->cancel_desc, "", "",
	    "p", "accelerator", "ESC",

	    NULL
	);

	dfui_form_set_multiple(f, 1);

	if (device != NULL) {
		ds = dfui_dataset_new();
		dfui_dataset_celldata_add(ds, "disk", device);
		dfui_dataset_celldata_add(ds, "boot0cfg", "Y");
		dfui_dataset_celldata_add(ds, "packet", "Y");
		dfui_form_dataset_add(f, ds);
	} else {
		for (d = storage_disk_first(a->s); d != NULL; d = disk_next(d)) {
			ds = dfui_dataset_new();
			dfui_dataset_celldata_add(ds, "disk",
			    disk_get_device_name(d));
			dfui_dataset_celldata_add(ds, "boot0cfg", "Y");
			dfui_dataset_celldata_add(ds, "packet", "Y");
			dfui_form_dataset_add(f, ds);
		}
	}

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

	a->result = 0;
	if (strcmp(dfui_response_get_action_id(r), "ok") == 0) {
		cmds = commands_new();

		for (ds = dfui_response_dataset_get_first(r); ds != NULL;
		     ds = dfui_dataset_get_next(ds)) {
			strlcpy(disk, dfui_dataset_get_value(ds, "disk"), 64);
			strlcpy(boot0cfg, dfui_dataset_get_value(ds, "boot0cfg"), 32);
			strlcpy(packet, dfui_dataset_get_value(ds, "packet"), 32);

			if (strcasecmp(boot0cfg, "Y") == 0) {
				cmd = command_add(cmds, "%s%s -B -o %spacket %s",
				    a->os_root, cmd_name(a, "BOOT0CFG"),
				    strcasecmp(packet, "Y") == 0 ? "" : "no",
				    disk);
				command_set_failure_mode(cmd, COMMAND_FAILURE_WARN);
				command_set_tag(cmd, "%s", disk);
				cmd = command_add(cmds, "%s%s -v %s",
				    a->os_root, cmd_name(a, "BOOT0CFG"),
				    disk);
				command_set_failure_mode(cmd, COMMAND_FAILURE_WARN);
				command_set_tag(cmd, "%s", disk);
			}
		}

		if (!commands_execute(a, cmds)) {
			ask_to_wipe_boot_sector(a, cmds);
		} else {
			inform(a->c, _("Bootblocks were successfully installed!"));
			a->result = 1;
		}
		commands_free(cmds);
	}

	dfui_form_free(f);
	dfui_response_free(r);
}
示例#20
0
/*
 * state_begin_install: Briefly describe the install process
 * to the user, and let them proceed (or not.)
 */
void
state_begin_install(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_response *r;
	char msg_buf[3][1024];

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("This experimental application will install %s"
	    " on one of the hard disk drives attached to this computer. "
	    "It has been designed to make it easy to install "
	    "%s in the typical case. "
	    "If you have special requirements that are not addressed "
	    "by this installer, or if you have problems using it, you "
	    "are welcome to install %s manually. "
	    "To do so select Exit to Live CD, login as root, and follow "
	    "the instructions given in the file /README ."
	    "\n\n"
	    "NOTE! As with any installation process, YOU ARE "
	    "STRONGLY ENCOURAGED TO BACK UP ANY IMPORTANT DATA ON THIS "
	    "COMPUTER BEFORE PROCEEDING!"
	    ""),
	    OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_NAME,
	    OPERATING_SYSTEM_NAME);

	snprintf(msg_buf[1], sizeof(msg_buf[1]),
	    _("Some situations in which you might not wish to use this "
	    "installer are:\n\n"
	    "- you want to install %s onto a "
	    "logical/extended partition;\n"
	    "- you want to install %s "
	    "onto a ``dangerously dedicated'' disk; or\n"
	    "- you want full and utter control over the install process."
	    ""),
	    OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_NAME);

	snprintf(msg_buf[2], sizeof(msg_buf[2]),
	    _("Install %s"), OPERATING_SYSTEM_NAME);

	f = dfui_form_create(
	    "begin_install",
	    _("Begin Installation"),
	    msg_buf[0],

	    msg_buf[1],
	    "p", "special", "dfinstaller_begin_install",
	    "p", "minimum_width", "76",

	    "a", "proceed", msg_buf[2],
	    "", "",
	    "a", "cancel", _("Return to Welcome Menu"),
	    "", "",
	    "p", "accelerator", "ESC",
	    "a", "livecd", _("Exit to Live CD"),
	    "", "",
	    NULL
	);

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

	if (strcmp(dfui_response_get_action_id(r), "proceed") == 0) {
		if (!survey_storage(a)) {
			inform(a->c, _("Errors occurred while probing "
			    "the system for its storage capabilities."));
		}
		state = state_select_disk;
	} else if (strcmp(dfui_response_get_action_id(r), "livecd") == 0) {
		state = NULL;
	} else if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
		state = state_welcome;
	}

	dfui_form_free(f);
	dfui_response_free(r);
}
示例#21
0
void
state_diskutil_menu(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_action *k;
	struct dfui_response *r;
	int done = 0;

	while (!done) {
		f = dfui_form_create(
		    "utilities_menu",
		    _("Disk Utilities Menu"),
		    _("These functions let you manipulate the storage devices "
		    "attached to this computer."),
		    "",

		    "p", "role", "menu",

		    "a", "format_hdd",
		    _("Format a hard disk drive"), "", "",
		    "a", "wipe_start_of_disk",
		    _("Wipe out the start of a disk"), "", "",
		    "a", "wipe_start_of_slice",
		    _("Wipe out the start of a primary partition"), "", "",
		    "a", "install_bootblocks",
		    _("Install bootblocks on disks"), "", "",
		    "a", "format_msdos_floppy",
		    _("Format an MSDOS floppy"), "", "",
		    NULL
		);

		if (is_file("%sboot/cdboot.flp.bz2", a->os_root)) {
			dfui_form_action_add(f, "create_cdboot_floppy",
			    dfui_info_new(_("Create a CDBoot floppy"),
			    "",
			    ""));
		}

		k = dfui_form_action_add(f, "cancel",
		    dfui_info_new(_("Return to Utilities Menu"), "", ""));
		dfui_action_property_set(k, "accelerator", "ESC");

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

		/* XXX set up a */
		if (strcmp(dfui_response_get_action_id(r), "format_hdd") == 0) {
			storage_set_selected_disk(a->s, NULL);
			storage_set_selected_slice(a->s, NULL);
			fn_format_disk(a);
		} else if (strcmp(dfui_response_get_action_id(r), "wipe_start_of_disk") == 0) {
			fn_wipe_start_of_disk(a);
		} else if (strcmp(dfui_response_get_action_id(r), "wipe_start_of_slice") == 0) {
			fn_wipe_start_of_slice(a);
		} else if (strcmp(dfui_response_get_action_id(r), "install_bootblocks") == 0) {
			a->short_desc = _("Select the disks on which "
			    "you wish to install bootblocks.");
			a->cancel_desc = _("Return to Utilities Menu");
			fn_install_bootblocks(a, NULL);
		} else if (strcmp(dfui_response_get_action_id(r), "format_msdos_floppy") == 0) {
			fn_format_msdos_floppy(a);
		} else if (strcmp(dfui_response_get_action_id(r), "create_cdboot_floppy") == 0) {
			fn_create_cdboot_floppy(a);
		} else if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) {
			state = state_utilities_menu;
			done = 1;
		}

		dfui_form_free(f);
		dfui_response_free(r);
	}
}
示例#22
0
/*
 * Read from the pipe that was opened to the executing commands
 * and update the progress bar as data comes and (and/or as the
 * read from the pipe times out.)
 */
static int
pipe_loop(struct i_fn_args *a, struct dfui_progress *pr,
	  struct command *cmd, int *cancelled)
{
	FILE *cmdout = NULL;
	struct timeval tv = { 1, 0 };
	char cline[256];
	char *command;
	pid_t pid;
	fd_set r;
	int n;

	asprintf(&command, "(%s) 2>&1 </dev/null", cmd->cmdline);
	fflush(stdout);
	cmdout = aura_popen(command, "r");
	free(command);

	if (cmdout == NULL) {
		i_log(a, "! could not aura_popen() command");
		return(COMMAND_RESULT_POPEN_ERR);
	}
	pid = aura_pgetpid(cmdout);
#ifdef DEBUG
	fprintf(stderr, "+ pid = %d\n", pid);
#endif

	/*
	 * Loop, selecting on the command and a timeout.
	 */
	for (;;) {
		if (*cancelled)
			break;
		FD_ZERO(&r);
		FD_SET(fileno(cmdout), &r);
		n = select(fileno(cmdout) + 1, &r, NULL, NULL, &tv);
#ifdef DEBUG
		fprintf(stderr, "+ select() = %d\n", n);
#endif
		if (n < 0) {
			/* Error */
			i_log(a, "! select() failed\n");
			aura_pclose(cmdout);
			return(COMMAND_RESULT_SELECT_ERR);
		} else if (n == 0) {
			/* Timeout */
			if (!dfui_be_progress_update(a->c, pr, cancelled))
				abort_backend();
#ifdef DEBUG
			fprintf(stderr, "+ cancelled = %d\n", *cancelled);
#endif
		} else {
			/* Data came in */
			fgets(cline, 255, cmdout);
			while (strlen(cline) > 0 && cline[strlen(cline) - 1] == '\n')
				cline[strlen(cline) - 1] = '\0';
			if (feof(cmdout))
				break;
			if (!dfui_be_progress_update(a->c, pr, cancelled))
				abort_backend();
			if (cmd->log_mode == COMMAND_LOG_VERBOSE) {
				i_log(a, "| %s", cline);
			} else if (cmd->log_mode != COMMAND_LOG_SILENT) {
				fprintf(stderr, "| %s\n", cline);
			}
		}
	}

	if (*cancelled) {
#ifdef DEBUG
		fprintf(stderr, "+ killing %d\n", pid);
#endif
		n = kill(pid, SIGTERM);
#ifdef DEBUG
		fprintf(stderr, "+ kill() = %d\n", n);
#endif
	}

#ifdef DEBUG
	fprintf(stderr, "+ pclosing %d\n", fileno(cmdout));
#endif
	n = aura_pclose(cmdout) / 256;
#ifdef DEBUG
	fprintf(stderr, "+ pclose() = %d\n", n);
#endif
	return(n);
}
示例#23
0
void
state_environment_menu(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_response *r;
	int done = 0;
	char msg_buf[2][1024];

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("On this menu you will find utilities to help you "
	    "set up your Live CD environment.\n\nNote "
	    "that these functions affect only the LiveCD "
	    "environment you are currently using, and they will "
	    "not affect any system that may be installed on "
	    "this computer UNLESS you subsequently choose to "
	    "install %s from this environment, in which "
	    "case they will be copied to the newly installed "
	    "system."), OPERATING_SYSTEM_NAME);

	while (!done) {
		f = dfui_form_create(
		    "environment_menu",
		    _("Live CD Environment Menu"),
		    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", "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", "assign_hostname_domain",
		    _("Configure hostname and domain"),
		    _("Configure the hostname and domain for this system"), "",
		    "a", "assign_ip",
		    _("Configure network interfaces"),
		    _("Set up network interfaces (NICs, ethernet, TCP/IP, etc)"), "",

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

		    NULL
		);

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

		/* Set up a */
		a->cfg_root = "";
		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), "assign_hostname_domain") == 0) {
			fn_assign_hostname_domain(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), "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_utilities_menu;
			done = 1;
		}

		dfui_form_free(f);
		dfui_response_free(r);
	}
}
示例#24
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);
}
示例#25
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."));
}
示例#26
0
/*
 * state_welcome_system: the start state of the installer state machine,
 * when run from the installed system.  Allow the user to configure the
 * system.
 */
void
state_welcome_system(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_response *r;
	char msg_buf[2][1024];

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("Configure this %s System"), OPERATING_SYSTEM_NAME);

	snprintf(msg_buf[1], sizeof(msg_buf[1]),
	    _("Thank you for choosing %s."
	    "\n\n"
	    "For up-to-date news and information on %s, "
	    "make sure to check out"
	    "\n\n"
	    "%s"
	    "\n\n"
	    "You can use this automated application to assist "
	    "you in setting up this %s system."
	    ""),
	    OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_NAME,
	    OPERATING_SYSTEM_URL, OPERATING_SYSTEM_NAME);


	f = dfui_form_create(
	    "welcome",
	    msg_buf[0],

	    msg_buf[1],

	    "",

	    "p",	"special", 	"dfinstaller_welcome",

	    NULL
	);

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("Configure this %s system"), OPERATING_SYSTEM_NAME);

	dfui_form_action_add(f, "environment",
	    dfui_info_new(_("Configure this System"),
	    msg_buf[0], ""));

	dfui_form_action_add(f, "utilities",
	    dfui_info_new(_("Utilities"),
	    _("Utilities to work with and diagnose disks and other subsystems"), ""));

	dfui_form_action_add(f, "exit",
	    dfui_info_new(_("Exit Installer"),
	    _("Exit this program and return to the system"), ""));

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

	if (strcmp(dfui_response_get_action_id(r), "environment") == 0) {
		state = state_environment_menu;
	} else if (strcmp(dfui_response_get_action_id(r), "utilities") == 0) {
		state = state_utilities_menu;
	} else if (strcmp(dfui_response_get_action_id(r), "exit") == 0) {
		state = NULL;
	} else if (strcmp(dfui_response_get_action_id(r), "reboot") == 0) {
		state = state_reboot;
	}

	dfui_form_free(f);
	dfui_response_free(r);
}
示例#27
0
/*
 * state_welcome_livecd: the start state of the installer state machine,
 * when run from the Live CD.  Briefly describe DragonFly to the user,
 * and present them with a set of reasonable options of how to proceed.
 */
void
state_welcome(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_action *k;
	struct dfui_response *r;
	char msg_buf[2][1024];

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("Welcome to %s"), OPERATING_SYSTEM_NAME);

	snprintf(msg_buf[1], sizeof(msg_buf[1]),
	    _("Welcome to the %s Live CD."
	    "\n\n"
	    "%s is an efficient and elegant BSD "
	    "Unix-derived operating system.  For more information, see %s"
	    "\n\n"
	    "From this CD, you can boot into %s ``live'' "
	    "(without installing it) to evaluate it, to install it "
	    "manually, or to troubleshoot problems with an "
	    "existing installation, using either a command prompt "
	    "or menu-driven utilities."
	    "\n\n"
	    "Also, you can use this automated application to assist "
	    "you in installing %s on this computer and "
	    "configuring it once it is installed."
	    ""),
	    OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_URL,
	    OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_NAME);

	if (!a->booted_from_livecd) {
		state = state_welcome_system;
		return;
	}

	f = dfui_form_create(
	    "welcome",
	    msg_buf[0],

	    msg_buf[1],

	    "",

	    "p",	"special", 	"dfinstaller_welcome",

	    NULL
	);

	if (a->upgrade_menu_toggle) {
		snprintf(msg_buf[0], sizeof(msg_buf[0]),
		    _("Upgrade a FreeBSD 4.X system to %s"),
		    OPERATING_SYSTEM_NAME);
		dfui_form_action_add(f, "upgrade",
		    dfui_info_new(_("Upgrade"),
		    msg_buf[0], ""));
	} else {
		snprintf(msg_buf[0], sizeof(msg_buf[0]),
		    _("Install %s"), OPERATING_SYSTEM_NAME);
		snprintf(msg_buf[1], sizeof(msg_buf[1]),
		    _("Install %s on a HDD or HDD partition on this computer"),
		    OPERATING_SYSTEM_NAME);
		dfui_form_action_add(f, "install",
		    dfui_info_new(msg_buf[0],
		    msg_buf[1], ""));
	}

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("Configure a %s system once it has been installed on HDD"),
	    OPERATING_SYSTEM_NAME);
	dfui_form_action_add(f, "configure",
	    dfui_info_new(_("Configure an Installed System"),
	    msg_buf[0], ""));

	dfui_form_action_add(f, "utilities",
	    dfui_info_new(_("Live CD Utilities"),
	    _("Utilities to work with disks, diagnostics, and the LiveCD Environment"), ""));

	k = dfui_form_action_add(f, "exit",
	    dfui_info_new(_("Exit to Live CD"),
	    _("Exit this program to a login prompt with access to the LiveCD"), ""));

	dfui_form_action_add(f, "reboot",
	    dfui_info_new(_("Reboot this Computer"),
	    _("Reboot this computer (e.g. to boot into a newly installed system)"), ""));

	dfui_form_action_add(f, "configure_netboot",
	    dfui_info_new(_("Setup NetBoot Install Services"),
	    _("Setup machine as remote installation server"), ""));

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

	if (strcmp(dfui_response_get_action_id(r), "install") == 0) {
		state = state_begin_install;
	} else if (strcmp(dfui_response_get_action_id(r), "upgrade") == 0) {
		state = state_begin_upgrade;
	} else if (strcmp(dfui_response_get_action_id(r), "configure") == 0) {
		storage_set_selected_disk(a->s, NULL);
		storage_set_selected_slice(a->s, NULL);
		state = state_configure_menu;
	} else if (strcmp(dfui_response_get_action_id(r), "utilities") == 0) {
		state = state_utilities_menu;
	} else if (strcmp(dfui_response_get_action_id(r), "exit") == 0) {
		state = NULL;
        } else if (strcmp(dfui_response_get_action_id(r), "configure_netboot") == 0) {
                state = state_setup_remote_installation_server;
	} else if (strcmp(dfui_response_get_action_id(r), "reboot") == 0) {
		state = state_reboot;
	}

	dfui_form_free(f);
	dfui_response_free(r);
}
示例#28
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;

}
示例#29
0
void
fn_memtest(struct i_fn_args *a)
{
	struct dfui_form *f;
	struct dfui_response *r;
	struct dfui_dataset *ds, *new_ds;
	struct commands *cmds;
	struct command *cmd;
	const char *memtestsize;

	f = dfui_form_create(
	    "memtest",
	    _("Memory test"),
	    _("Memory test - Enter the size in values such as 400M, 1G."),
	    "",

	    "f", "memtestsize", _("Memory test size"),
	    _("Enter the amount of memory you would like to check:"), "",

	    "a", "ok", _("OK"), "", "",
	    "a", "cancel", _("Cancel Memory Test"), "", "",
	    "p", "accelerator", "ESC",

	    NULL
	);

	ds = dfui_dataset_new();
	dfui_dataset_celldata_add(ds, "memtestsize", "");
	dfui_form_dataset_add(f, ds);

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

	if (strcmp(dfui_response_get_action_id(r), "ok") == 0) {
		new_ds = dfui_response_dataset_get_first(r);
		memtestsize = dfui_dataset_get_value(new_ds, "memtestsize");
		cmds = commands_new();
		cmd = command_add(cmds,
		    "cd %s && %s%s %s 1 --log",
		    a->tmp,
		    a->os_root, cmd_name(a, "MEMTEST"),
		    memtestsize);
		command_set_log_mode(cmd, COMMAND_LOG_QUIET);
		cmd = command_add(cmds,
		    "%s%s -E -v '^Unable to malloc' %smemtest.log > %smemtest.log.new",
		    a->os_root, cmd_name(a, "GREP"),
		    a->tmp, a->tmp);
		cmd = command_add(cmds, "%s%s %smemtest.log.new %smemtest.log",
		    a->os_root, cmd_name(a, "MV"),
		    a->tmp, a->tmp);
		cmd = command_add(cmds,
		    "%s%s -E -v '^Allocated.*failed' %smemtest.log > %smemtest.log.new",
		    a->os_root, cmd_name(a, "GREP"),
		    a->tmp, a->tmp);
		cmd = command_add(cmds, "%s%s %smemtest.log.new %smemtest.log",
		    a->os_root, cmd_name(a, "MV"),
		    a->tmp, a->tmp);
 		if (commands_execute(a, cmds)) {
			commands_free(cmds);
			view_memtest_log(a);
			cmds = commands_new();
			cmd = command_add(cmds, "%s%s -f %smemtest.log",
			    a->os_root, cmd_name(a, "RM"),
			    a->tmp);
			commands_execute(a, cmds);
		} else {
			inform(a->c, _("Memory test could not be run."));
		}
		commands_free(cmds);
	}

	dfui_form_free(f);
	dfui_response_free(r);
}