mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
installer: Create a config struct
This commit is contained in:
@@ -226,6 +226,14 @@ static struct lang {
|
|||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct config {
|
||||||
|
int serial_console;
|
||||||
|
int require_networking;
|
||||||
|
} config = {
|
||||||
|
.serial_console = 0,
|
||||||
|
.require_networking = 0,
|
||||||
|
};
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
struct hw* hw = hw_init();
|
struct hw* hw = hw_init();
|
||||||
const char* logfile = NULL;
|
const char* logfile = NULL;
|
||||||
@@ -247,10 +255,6 @@ int main(int argc, char *argv[]) {
|
|||||||
char line[STRING_SIZE];
|
char line[STRING_SIZE];
|
||||||
|
|
||||||
int unattended = 0;
|
int unattended = 0;
|
||||||
int serialconsole = 0;
|
|
||||||
int require_networking = 0;
|
|
||||||
struct keyvalue *unattendedkv = initkeyvalues();
|
|
||||||
char restore_file[STRING_SIZE] = "";
|
|
||||||
|
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
sethostname( SNAME , 10);
|
sethostname( SNAME , 10);
|
||||||
@@ -296,12 +300,12 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// check if the installer should start networking
|
// check if the installer should start networking
|
||||||
if (strstr(line, "installer.net") != NULL) {
|
if (strstr(line, "installer.net") != NULL) {
|
||||||
require_networking = 1;
|
config.require_networking = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we have to patch for serial console
|
// check if we have to patch for serial console
|
||||||
if (strstr (line, "console=ttyS0") != NULL) {
|
if (strstr (line, "console=ttyS0") != NULL) {
|
||||||
serialconsole = 1;
|
config.serial_console = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +358,7 @@ int main(int argc, char *argv[]) {
|
|||||||
if (!unattended) {
|
if (!unattended) {
|
||||||
// Show the right message to the user
|
// Show the right message to the user
|
||||||
char reason[STRING_SIZE];
|
char reason[STRING_SIZE];
|
||||||
if (require_networking) {
|
if (config.require_networking) {
|
||||||
snprintf(reason, sizeof(reason),
|
snprintf(reason, sizeof(reason),
|
||||||
_("The installer will now try downloading the installation image."));
|
_("The installer will now try downloading the installation image."));
|
||||||
} else {
|
} else {
|
||||||
@@ -373,11 +377,11 @@ int main(int argc, char *argv[]) {
|
|||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_networking = 1;
|
config.require_networking = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try starting the networking if we require it
|
// Try starting the networking if we require it
|
||||||
if (require_networking) {
|
if (config.require_networking) {
|
||||||
while (1) {
|
while (1) {
|
||||||
statuswindow(60, 4, title, _("Trying to start networking (DHCP)..."));
|
statuswindow(60, 4, title, _("Trying to start networking (DHCP)..."));
|
||||||
|
|
||||||
@@ -428,14 +432,6 @@ int main(int argc, char *argv[]) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load unattended configuration */
|
|
||||||
if (unattended) {
|
|
||||||
fprintf(flog, "unattended: Reading unattended.conf\n");
|
|
||||||
|
|
||||||
(void) readkeyvalues(unattendedkv, UNATTENDED_CONF);
|
|
||||||
findkey(unattendedkv, "RESTORE_FILE", restore_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unattended) {
|
if (!unattended) {
|
||||||
// Read the license file.
|
// Read the license file.
|
||||||
if (!(copying = fopen(LICENSE_FILE, "r"))) {
|
if (!(copying = fopen(LICENSE_FILE, "r"))) {
|
||||||
@@ -686,7 +682,7 @@ int main(int argc, char *argv[]) {
|
|||||||
statuswindow(60, 4, title, _("Installing the bootloader..."));
|
statuswindow(60, 4, title, _("Installing the bootloader..."));
|
||||||
|
|
||||||
/* Serial console ? */
|
/* Serial console ? */
|
||||||
if (serialconsole) {
|
if (config.serial_console) {
|
||||||
/* grub */
|
/* grub */
|
||||||
FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/default/grub", "a");
|
FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/default/grub", "a");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
|||||||
Reference in New Issue
Block a user