/* * 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)); } } }
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); }
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); }
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); }
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; }
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); } }
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); }
/* * 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); }
/* * 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); }
/* * 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); }
static int lua_dfui_be_present(lua_State *L) { struct dfui_connection *c; struct dfui_form *f; struct dfui_response *r; c = lua_check_dfui_connection(L, 1); luaL_checktype(L, 2, LUA_TTABLE); f = dfui_form_from_lua_table(L, 2); if (dfui_be_present(c, f, &r)) { lua_table_from_dfui_response(L, r); } else { lua_pushnil(L); } dfui_response_free(r); dfui_form_free(f); return(1); }
/* * 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); }
/* * 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); }
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); } }
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); }
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); } }
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); }
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.")); }
/* * 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); }
/* * 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); }
/* * * 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; }