Ejemplo n.º 1
0
/*
 * state_select_disk: ask the user on which physical disk they wish
 * to install DragonFly.
 */
void
state_select_disk(struct i_fn_args *a)
{
	struct disk *d;
	int num_disks = 0;
	char msg_buf[1][1024];

	for (d = storage_disk_first(a->s); d != NULL; d = disk_next(d))
		num_disks++;

	if (num_disks == 0) {
		inform(a->c, _("The installer could not find any disks suitable "
		    "for installation (IDE or SCSI) attached to this "
		    "computer.  If you wish to install %s"
		    " on an unorthodox storage device, you will have to "
		    "exit to a LiveCD command prompt and install it "
		    "manually, using the file /README as a guide."),
		    OPERATING_SYSTEM_NAME);
		state = state_welcome;
		return;
	}

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("Select a disk on which to install %s"),
	    OPERATING_SYSTEM_NAME);
	a->short_desc = msg_buf[0];
	a->cancel_desc = _("Return to Begin Installation");
	fn_select_disk(a);
	if (!a->result || storage_get_selected_disk(a->s) == NULL) {
		state = state_begin_install;
	} else {
#if 0
		if (disk_get_capacity(storage_get_selected_disk(a->s)) < DISK_MIN) {
			inform(a->c, _("WARNING: you should have a disk "
			    "at least %dM in size, or "
			    "you may encounter problems trying to "
			    "install %s."), DISK_MIN, OPERATING_SYSTEM_NAME);
		}
#endif
		state = state_format_disk;
	}
}
Ejemplo n.º 2
0
/*
 * state_begin_upgrade: Ask the user where the freebsd
 * 4.X install is and make sure its safe to proceed.
 *
 */
void
state_begin_upgrade(struct i_fn_args *a)
{
        //struct dfui_form *f = NULL;
        //struct dfui_response *r = NULL;
        //int done = 0;

        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 that you would like to upgrade.");
                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 you would like to upgrade.");
                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 (!mount_target_system(a)) {
                inform(a->c, _("Target system could not be mounted."));
                state = state_welcome;
                return;
        }
}
Ejemplo n.º 3
0
/*
 * Wipes the start of the selected disk.
 */
void
fn_wipe_start_of_disk(struct i_fn_args *a)
{
	struct commands *cmds;

	a->short_desc = _("If you are having problems formatting a disk, "
	    "it may be because of junk that has accumulated "
	    "in the boot block and the partition table. "
	    "A cure for this is to wipe out everything on "
	    "the first few sectors of the disk.  However, this "
	    "is a rather drastic action to take, so it is not "
	    "recommended unless you are otherwise "
	    "encountering problems.");
	a->cancel_desc = _("Return to Utilities Menu");
	fn_select_disk(a);
	if (!a->result)
		return;

	/* XXX check to make sure no slices on this disk are mounted first? */
	if (storage_get_selected_disk(a->s) != NULL && confirm_dangerous_action(a->c,
	    _("WARNING!  ALL data in ALL partitions on the disk\n\n"
	    "%s\n\nwill be IRREVOCABLY ERASED!\n\nAre you ABSOLUTELY "
	    "SURE you wish to take this action?  This is your "
	    "LAST CHANCE to cancel!"), disk_get_desc(storage_get_selected_disk(a->s)))) {
		cmds = commands_new();
		command_add(cmds,
		    "%s%s if=/dev/zero of=/dev/%s bs=32k count=16",
		    a->os_root, cmd_name(a, "DD"),
		    disk_get_device_name(storage_get_selected_disk(a->s)));
		if (commands_execute(a, cmds)) {
			inform(a->c, _("Start of disk was successfully wiped."));
		} else {
			inform(a->c, _("Some errors occurred. "
			    "Start of disk was not successfully wiped."));
		}
		commands_free(cmds);
	}
}
Ejemplo n.º 4
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."));
}
Ejemplo n.º 5
0
/*
 * If ss->selected_disk == NULL, user will be asked for which disk.
 * Returns 1 if disk was formatted, 0 if it wasn't.
 * If it was, ss->selected_disk and ss->selected_slice are set to it.
 */
void
fn_format_disk(struct i_fn_args *a)
{
	struct commands *cmds;
	char *selected_disk_string;

	if (storage_get_selected_disk(a->s) == NULL) {
		a->short_desc = _("Select a disk to format.");
		a->cancel_desc = _("Return to Utilities Menu");
		fn_select_disk(a);
		if (!a->result || storage_get_selected_disk(a->s) == NULL) {
			a->result = 0;
			return;
		}
	}

	if (confirm_dangerous_action(a->c,
	    _("WARNING!  ALL data in ALL partitions on the disk\n\n"
	    "%s\n\nwill be IRREVOCABLY ERASED!\n\nAre you ABSOLUTELY "
	    "SURE you wish to take this action?  This is your "
	    "LAST CHANCE to cancel!"), disk_get_desc(storage_get_selected_disk(a->s)))) {
		cmds = commands_new();

		command_add(cmds, "%s%s -BI %s",
		    a->os_root, cmd_name(a, "FDISK"),
		    disk_get_device_name(storage_get_selected_disk(a->s)));

		if (!commands_execute(a, cmds)) {
			inform(a->c, _("The disk\n\n%s\n\nwas "
			    "not correctly formatted, and may "
			    "now be in an inconsistent state. "
			    "We recommend re-formatting it "
			    "before attempting to install "
			    "%s on it."),
			    disk_get_desc(storage_get_selected_disk(a->s)),
			    OPERATING_SYSTEM_NAME);
			commands_free(cmds);
			a->result = 0;
			return;
		}
		commands_free(cmds);

		/*
		 * Since one of the disks has now changed, we must
		 * refresh our view of them and re-select the disk
		 * since the selected_disk pointer will be invalidated.
		 */
		selected_disk_string = aura_strdup(
		    disk_get_device_name(storage_get_selected_disk(a->s)));
		if (!survey_storage(a)) {
			inform(a->c, _("Errors occurred while probing "
			    "the system for its storage capabilities."));
		}
		storage_set_selected_disk(a->s, disk_find(a->s, selected_disk_string));
		free(selected_disk_string);

		/*
		 * Note that we formatted this disk and that we want
		 * to use the first (and only) slice of it.
		 */
		disk_set_formatted(storage_get_selected_disk(a->s), 1);
		storage_set_selected_slice(a->s, disk_slice_first(storage_get_selected_disk(a->s)));

		if (!format_slice(a)) {
			inform(a->c, _("The sole primary partition of "
			    "the disk\n\n%s\n\nwas "
			    "not correctly formatted, and may "
			    "now be in an inconsistent state. "
			    "We recommend re-formatting the "
			    "disk before attempting to install "
			    "%s on it."),
			    disk_get_desc(storage_get_selected_disk(a->s)),
			    OPERATING_SYSTEM_NAME);
			a->result = 0;
			return;
		}

		inform(a->c, _("The disk\n\n%s\n\nwas formatted."),
		    disk_get_desc(storage_get_selected_disk(a->s)));
		a->result = 1;
	} else {
		inform(a->c, _("Action cancelled - no disks were formatted."));
		a->result = 0;
	}
}