]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - src/install+setup/setup/networking.c
setup: change persistent network rules for new udev.
[people/teissler/ipfire-2.x.git] / src / install+setup / setup / networking.c
index 6a2bb128fc3b8f43115456f91d60fbdbe838fb03..edd3c71af0d60560c64b0f41616640c1eb3c60cd 100644 (file)
@@ -47,7 +47,7 @@ int configtypecards[] = {
 
 int netaddresschange;
 
-int oktoleave(char *errormessage);
+int oktoleave(void);
 int firstmenu(void);
 int configtypemenu(void);
 int drivermenu(void);
@@ -61,7 +61,6 @@ int handlenetworking(void)
        int done;
        int choice;
        int found;
-       char errormessage[STRING_SIZE];
        
        netaddresschange = 0;
 
@@ -92,10 +91,7 @@ int handlenetworking(void)
                                break;
                                
                        case 0:
-                               if (oktoleave(errormessage))
-                                       done = 1;
-                               else
-                                       errorbox(errormessage);
+                               if (oktoleave()) done = 1;
                                break;
                                
                        default:
@@ -116,16 +112,19 @@ int handlenetworking(void)
                        runcommandwithstatus("/etc/rc.d/init.d/network start",
                                ctr[TR_PULLING_NETWORK_UP]);
                }
+       } else {
+               rename_nics();
        }
        create_udev();
        return 1;
 }
 
-int oktoleave(char *errormessage)
+int oktoleave(void)
 {
        struct keyvalue *kv = initkeyvalues();
        char temp[STRING_SIZE];
        int configtype;
+       int rc;
        
        if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
        {
@@ -142,27 +141,35 @@ int oktoleave(char *errormessage)
                strcpy(temp, ""); findkey(kv, "GREEN_DEV", temp);
                if (!(strlen(temp)))
                {
-                       strcpy(errormessage, ctr[TR_NO_GREEN_INTERFACE]);
-                       goto EXIT;
+                       errorbox(ctr[TR_NO_GREEN_INTERFACE]);
+                       freekeyvalues(kv);
+                       return 0;
                }
                if (!(interfacecheck(kv, "GREEN")))
                {
-                       strcpy(errormessage, ctr[TR_MISSING_GREEN_IP]);
-                       goto EXIT;
+                       errorbox(ctr[TR_MISSING_GREEN_IP]);
+                       freekeyvalues(kv);
+                       return 0;
                }
        }
        if (HAS_RED)
        {
+
                strcpy(temp, ""); findkey(kv, "RED_DEV", temp);
                if (!(strlen(temp)))
                {
-                       strcpy(errormessage, ctr[TR_NO_RED_INTERFACE]);
-                       goto EXIT;
+                       rc = newtWinChoice(ctr[TR_ERROR], ctr[TR_OK], ctr[TR_IGNORE], ctr[TR_NO_RED_INTERFACE]);
+                       if (rc == 0 || rc == 1)
+                       {
+                               freekeyvalues(kv);
+                               return 0;
+                       }
                }
                if (!(interfacecheck(kv, "RED")))
                {
-                       strcpy(errormessage, ctr[TR_MISSING_RED_IP]);
-                       goto EXIT;
+                       errorbox(ctr[TR_MISSING_RED_IP]);
+                       freekeyvalues(kv);
+                       return 0;
                }
        }
        if (HAS_ORANGE)
@@ -170,13 +177,15 @@ int oktoleave(char *errormessage)
                strcpy(temp, ""); findkey(kv, "ORANGE_DEV", temp);
                if (!(strlen(temp)))
                {
-                       strcpy(errormessage, ctr[TR_NO_ORANGE_INTERFACE]);
-                       goto EXIT;
+                       errorbox(ctr[TR_NO_ORANGE_INTERFACE]);
+                       freekeyvalues(kv);
+                       return 0;
                }
                if (!(interfacecheck(kv, "ORANGE")))
                {
-                       strcpy(errormessage, ctr[TR_MISSING_ORANGE_IP]);
-                       goto EXIT;
+                       errorbox(ctr[TR_MISSING_ORANGE_IP]);
+                       freekeyvalues(kv);
+                       return 0;
                }
        }
        if (HAS_BLUE)
@@ -184,38 +193,37 @@ int oktoleave(char *errormessage)
                strcpy(temp, ""); findkey(kv, "BLUE_DEV", temp);
                if (!(strlen(temp)))
                {
-                       strcpy(errormessage, ctr[TR_NO_BLUE_INTERFACE]);
-                       goto EXIT;
+                       errorbox(ctr[TR_NO_BLUE_INTERFACE]);
+                       freekeyvalues(kv);
+                       return 0;
                }
                if (!(interfacecheck(kv, "BLUE")))
                {
-                       strcpy(errormessage, ctr[TR_MISSING_BLUE_IP]);
-                       goto EXIT;
+                       errorbox(ctr[TR_MISSING_BLUE_IP]);
+                       freekeyvalues(kv);
+                       return 0;
                }
        }
-       if (configtype == 0)
+       
+       strcpy(temp, ""); findkey(kv, "RED_TYPE", temp);
+       if ((configtype == 0) || (strcmp(temp, "STATIC") == 0))
        {
                strcpy(temp, ""); findkey(kv, "DNS1", temp);
                if (!(strlen(temp)))
                {
-                       strcpy(errormessage, ctr[TR_MISSING_DNS]);
-                       goto EXIT;
+                       errorbox(ctr[TR_MISSING_DNS]);
+                       freekeyvalues(kv);
+                       return 0;
                }
                strcpy(temp, ""); findkey(kv, "DEFAULT_GATEWAY", temp);
                if (!(strlen(temp)))
                {
-                       strcpy(errormessage, ctr[TR_MISSING_DEFAULT]);
-                       goto EXIT;
+                       errorbox(ctr[TR_MISSING_DEFAULT]);
+                       freekeyvalues(kv);
+                       return 0;
                }
        }
-       strcpy(errormessage, "");
-EXIT:
-       freekeyvalues(kv);
-       
-       if (strlen(errormessage))
-               return 0;
-       else
-               return 1;
+       return 1;
 }
 
        
@@ -284,8 +292,6 @@ int configtypemenu(void)
        findkey(kv, "CONFIG_TYPE", temp); choise = atol(temp);
        choise--;
 
-       do
-       {
                sprintf(message, ctr[TR_NETWORK_CONFIGURATION_TYPE_LONG], NAME);
                rc = newtWinMenu(ctr[TR_NETWORK_CONFIGURATION_TYPE], message, 50, 5, 5,
                        6, configtypenames, &choise, ctr[TR_OK], ctr[TR_CANCEL], NULL);
@@ -293,8 +299,6 @@ int configtypemenu(void)
                        sprintf(message, ctr[TR_NOT_ENOUGH_INTERFACES] , configtypecards[choise], found);
                        errorbox(message);
                }
-       }
-       while ( configtypecards[choise] > found);
 
        if (rc == 0 || rc == 1)
        {
@@ -334,9 +338,15 @@ int drivermenu(void)
                return 0;
        }
 
-       findkey(kv, "CONFIG_TYPE", temp);
-       configtype = atol(temp);
-       
+       if (findkey(kv, "CONFIG_TYPE", temp))
+               configtype = atol(temp);
+       else {
+               fprintf(flog,"setting CONFIG_TYPE = %s\n",temp);
+               configtype = atol(temp);
+               replacekeyvalue(kv, "CONFIG_TYPE", temp);
+               writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
+       }
+
        strcpy(message, ctr[TR_CONFIGURE_NETWORK_DRIVERS]);
 
        kcount = 0;
@@ -434,6 +444,8 @@ int changedrivers(void)
                { green = 1; red = 1; blue = 1; }
        else if (configtype == 4)
                { green = 1; red=1; orange=1; blue = 1; }
+       else if (configtype == "")
+         { green = 1; red = 1; }
 
        do
        {