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); } }
/* * 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); }
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); } }
/* * * 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; }
static void set_dfui_properties_from_lua_table(lua_State *L, int table_idx, int dfui_obj_type, void *dfui_obj) { const char *key, *value; /* * Traverse the table, looking for key->value pairs that we can use * to modify the field. * For each entry, if it is standard (id, name, short_desc, long_desc) * ignore it; if it is anything else, assume it is a property. */ lua_pushnil(L); while (lua_next(L, table_idx) != 0) { if (lua_isstring(L, -2) && lua_isstring(L, -1)) { key = lua_tostring(L, -2); value = lua_tostring(L, -1); if (strcmp(key, "id") == 0 || strcmp(key, "name") == 0 || strcmp(key, "short_desc") == 0 || strcmp(key, "long_desc") == 0) { /* * Skip it, we've already done it. */ } else if (strcmp(key, "multiple") == 0 && dfui_obj_type == DFUI_OBJ_FORM) { dfui_form_set_multiple( (struct dfui_form *)dfui_obj, strcmp(value, "true") == 0 ); } else if (strcmp(key, "extensible") == 0 && dfui_obj_type == DFUI_OBJ_FORM) { dfui_form_set_extensible( (struct dfui_form *)dfui_obj, strcmp(value, "true") == 0 ); } else { /* * It's a property. */ switch (dfui_obj_type) { case DFUI_OBJ_FORM: dfui_form_property_set( (struct dfui_form *)dfui_obj, key, value); break; case DFUI_OBJ_FIELD: dfui_field_property_set( (struct dfui_field *)dfui_obj, key, value); break; case DFUI_OBJ_ACTION: dfui_action_property_set( (struct dfui_action *)dfui_obj, key, value); break; } } } else if (lua_isstring(L, -2) && lua_istable(L, -1)) { key = lua_tostring(L, -2); if (strcmp(key, "options") == 0 && dfui_obj_type == DFUI_OBJ_FIELD) { dfui_field_options_from_lua_table(L, (struct dfui_field *)dfui_obj ); } } else { /* * Either the key or the value is not a string, * so just skip it. */ } /* * Remove the value, but leave the key for the next iteration. */ lua_pop(L, 1); } }