]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
installer: Create a config struct
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Oct 2014 20:30:36 +0000 (22:30 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Oct 2014 20:30:36 +0000 (22:30 +0200)
src/installer/main.c

index 36f8dfec8110a48bb6fb1f73c07c35350503550a..761293fe86b2913e81eaf9fca03764b025ff0e08 100644 (file)
@@ -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[]) {
        struct hw* hw = hw_init();
        const char* logfile = NULL;
 int main(int argc, char *argv[]) {
        struct hw* hw = hw_init();
        const char* logfile = NULL;
@@ -247,10 +255,6 @@ int main(int argc, char *argv[]) {
        char line[STRING_SIZE];
                
        int unattended = 0;
        char line[STRING_SIZE];
                
        int unattended = 0;
-       int serialconsole = 0;
-       int require_networking = 0;
-       struct keyvalue *unattendedkv = initkeyvalues();
-       char restore_file[STRING_SIZE] = "";
 
        setlocale (LC_ALL, "");
        sethostname( SNAME , 10);
 
        setlocale (LC_ALL, "");
        sethostname( SNAME , 10);
@@ -296,12 +300,12 @@ int main(int argc, char *argv[]) {
 
                // check if the installer should start networking
                if (strstr(line, "installer.net") != NULL) {
 
                // check if the installer should start networking
                if (strstr(line, "installer.net") != NULL) {
-                       require_networking = 1;
+                       config.require_networking = 1;
                }
 
                // check if we have to patch for serial console
                if (strstr (line, "console=ttyS0") != NULL) {
                }
 
                // check if we have to patch for serial console
                if (strstr (line, "console=ttyS0") != NULL) {
-                   serialconsole = 1;
+                       config.serial_console = 1;
                }
        }
 
                }
        }
 
@@ -354,7 +358,7 @@ int main(int argc, char *argv[]) {
                if (!unattended) {
                        // Show the right message to the user
                        char reason[STRING_SIZE];
                if (!unattended) {
                        // Show the right message to the user
                        char reason[STRING_SIZE];
-                       if (require_networking) {
+                       if (config.require_networking) {
                                snprintf(reason, sizeof(reason),
                                        _("The installer will now try downloading the installation image."));
                        } else {
                                snprintf(reason, sizeof(reason),
                                        _("The installer will now try downloading the installation image."));
                        } 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) {
                        statuswindow(60, 4, title, _("Trying to start networking (DHCP)..."));
 
                while (1) {
                        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) {
                // Read the license file.
                if (!(copying = fopen(LICENSE_FILE, "r"))) {
        if (!unattended) {
                // Read the license file.
                if (!(copying = fopen(LICENSE_FILE, "r"))) {
@@ -686,7 +682,7 @@ int main(int argc, char *argv[]) {
        statuswindow(60, 4, title, _("Installing the bootloader..."));
 
        /* Serial console ? */
        statuswindow(60, 4, title, _("Installing the bootloader..."));
 
        /* Serial console ? */
-       if (serialconsole) {
+       if (config.serial_console) {
                /* grub */
                FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/default/grub", "a");
                if (!f) {
                /* grub */
                FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/default/grub", "a");
                if (!f) {