Änderungen am Installer/Setup vorgenommen. ISDN wird erstmal nicht über den Installer...
authorcasemaster <casemaster@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Sat, 12 May 2007 22:00:50 +0000 (22:00 +0000)
committercasemaster <casemaster@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Sat, 12 May 2007 22:00:50 +0000 (22:00 +0000)
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@556 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

src/install+setup/libsmooth/libsmooth.h
src/install+setup/libsmooth/netstuff.c
src/install+setup/setup/main.c
src/install+setup/setup/networking.c

index e48db18..d990de9 100644 (file)
@@ -93,8 +93,9 @@ int setnetaddress(struct keyvalue *kv, char *colour);
 void networkdialogcallbacktype(newtComponent cm, void *data);
 int interfacecheck(struct keyvalue *kv, char *colour);
 int scan_network_cards(void);
-int nicmenu(char *colour);
-int remove_nic_entry(char *colour);
+int nicmenu(int colour);
+int clear_card_entry(int cards);
+int ask_clear_card_entry(int cards);
 int manualdriver(char *driver, char *driveroptions);
          
 /* data.c */
index 8f9b489..cfed018 100644 (file)
@@ -19,6 +19,9 @@ extern char **ctr;
 extern struct nic nics[];
 extern struct knic knics[];
 
+char *ucolourcard[] = { "GREEN", "RED", "ORANGE", "BLUE", NULL };
+char *lcolourcard[] = { "green", "red", "orange", "blue", NULL };
+
 int scanned_nics_read_done = 0;
 
 newtComponent networkform;
@@ -351,7 +354,7 @@ void strupper(unsigned char *string)
 }
 */
 
-int write_configs_netudev(char *description, char *macaddr, char *colour)
+int write_configs_netudev(char *description, char *macaddr, int colour)
 {      
        #define UDEV_NET_CONF "/etc/udev/rules.d/30-persistent-network.rules"
        FILE *fp;
@@ -363,28 +366,10 @@ int write_configs_netudev(char *description, char *macaddr, char *colour)
 //     sprintf(ucolour, colour);       
 //     strupper(ucolour);
 
-       switch (*colour)
-       {
-               case 'g':       sprintf(ucolour, "GREEN");
-                               strcpy(knics[_GREEN_CARD_].description, description);
-                               strcpy(knics[_GREEN_CARD_].macaddr, macaddr);
-                               break;
-               case 'r':       sprintf(ucolour, "RED");
-                               strcpy(knics[_RED_CARD_].description, description);
-                               strcpy(knics[_RED_CARD_].macaddr, macaddr);
-                               break;
-               case 'o':       sprintf(ucolour, "ORANGE");
-                               strcpy(knics[_ORANGE_CARD_].description, description);
-                               strcpy(knics[_ORANGE_CARD_].macaddr, macaddr);
-                               break;
-               case 'b':       sprintf(ucolour, "BLUE");
-                               strcpy(knics[_BLUE_CARD_].description, description);
-                               strcpy(knics[_BLUE_CARD_].macaddr, macaddr);
-                               break;
-               default:        sprintf(ucolour, "DUMMY");
-                               break;
-       }
-
+       sprintf(ucolour, ucolourcard[colour]);
+       strcpy(knics[colour].description, description);
+       strcpy(knics[colour].macaddr, macaddr);
+       
        if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
        {
                freekeyvalues(kv);
@@ -394,7 +379,7 @@ int write_configs_netudev(char *description, char *macaddr, char *colour)
 
        sprintf(temp1, "%s_DEV", ucolour);
        sprintf(temp2, "%s_MACADDR", ucolour);
-       sprintf(temp3, "%s0", colour);
+       sprintf(temp3, "%s0", lcolourcard[colour]);
        replacekeyvalue(kv, temp1, temp3);
        replacekeyvalue(kv, temp2, macaddr);
        sprintf(temp1, "%s_DESCRIPTION", ucolour);
@@ -407,10 +392,10 @@ int write_configs_netudev(char *description, char *macaddr, char *colour)
        snprintf(commandstring, STRING_SIZE, "/usr/bin/touch "UDEV_NET_CONF" >/dev/null 2>&1");
        system(commandstring);
        
-       snprintf(commandstring, STRING_SIZE, "/bin/cat "UDEV_NET_CONF" | /bin/grep -v \"%s\" > "UDEV_NET_CONF" 2>/dev/null", macaddr);
-       system(commandstring);
+//     snprintf(commandstring, STRING_SIZE, "/bin/cat "UDEV_NET_CONF" | /bin/grep -v \"%s\" > "UDEV_NET_CONF" 2>/dev/null", macaddr);
+//     system(commandstring);
 
-       snprintf(commandstring, STRING_SIZE, "/bin/cat "UDEV_NET_CONF" | /bin/grep -v \"%s\" > "UDEV_NET_CONF" 2>/dev/null", colour);
+       snprintf(commandstring, STRING_SIZE, "/bin/cat "UDEV_NET_CONF" | /bin/grep -v \"%s0\" > "UDEV_NET_CONF" 2>/dev/null", lcolourcard[colour]);
        system(commandstring);
 
        if( (fp = fopen(UDEV_NET_CONF, "a")) == NULL )
@@ -418,7 +403,7 @@ int write_configs_netudev(char *description, char *macaddr, char *colour)
                fprintf(stderr,"Couldn't open" UDEV_NET_CONF);
                return 1;
        }
-       fprintf(fp,"ACTION==\"add\", SUBSYSTEM==\"net\", SYSFS{address}==\"%s\", NAME=\"%s0\" # %s\n", macaddr, colour, description);
+       fprintf(fp,"ACTION==\"add\", SUBSYSTEM==\"net\", SYSFS{address}==\"%s\", NAME=\"%s0\" # %s\n", macaddr, lcolourcard[colour], description);
        fclose(fp);     
        
        return 0;
@@ -451,14 +436,14 @@ int scan_network_cards(void)
                        }
                }
                fclose(fp);
-       }
-       scanned_nics_read_done = 1;
-       return count;
+               scanned_nics_read_done = count;
+       } else fprintf(flog,"Scan Networkcards does read.\n");
+       return scanned_nics_read_done;
 }
 
 
 
-int nicmenu(char *colour)
+int nicmenu(int colour)
 {
        int rc, choise = 0, count = 0, kcount = 0, mcount = 0, i, j, nic_in_use;
        int found_NIC_as_Card[4];
@@ -517,7 +502,7 @@ int nicmenu(char *colour)
 //             sprintf(message, "Es wurde(n) %d freie Netzwerkkarte(n) in Ihrem System gefunden.\nBitte waehlen Sie im naechsten Dialog eine davon aus.\n", count);
 //             newtWinMessage("NetcardMenu", ctr[TR_OK], message);
 
-               sprintf(message, "(TR) Bitte waehlen Sie eine der untenstehenden Netzwerkkarten fuer die Schnittstelle \"%s\" aus.\n", colour);
+               sprintf(message, "(TR) Bitte wählen Sie eine der untenstehenden Netzwerkkarten fuer die Schnittstelle \"%s\" aus.\n", ucolourcard[colour]);
                rc = newtWinMenu("(TR) NetcardMenu2", message, 50, 5, 5, 6, pMenuInhalt, &choise, ctr[TR_OK], ctr[TR_SELECT], ctr[TR_CANCEL], NULL);
                                
                if ( rc == 0 || rc == 1) {
@@ -533,15 +518,11 @@ int nicmenu(char *colour)
        }
 }
 
-int remove_nic_entry(char *colour)
+int clear_card_entry(int card)
 {
        struct keyvalue *kv = initkeyvalues();
-       char message[STRING_SIZE];
-       char temp1[STRING_SIZE], temp2[STRING_SIZE];
-       char ucolour[STRING_SIZE];
-       int rc;
+       char temp[STRING_SIZE];
 
-       
        if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
        {
                freekeyvalues(kv);
@@ -549,47 +530,43 @@ int remove_nic_entry(char *colour)
                return 0;
        }
 
-       switch (*colour)
-       {
-               case 'g':       sprintf(ucolour, "GREEN");
-                               strcpy(knics[_GREEN_CARD_].description, ctr[TR_UNSET]);
-                               strcpy(knics[_GREEN_CARD_].macaddr, "");
-                               strcpy(knics[_GREEN_CARD_].colour, "");
-                               break;
-               case 'r':       sprintf(ucolour, "RED");
-                               strcpy(knics[_RED_CARD_].description, ctr[TR_UNSET]);
-                               strcpy(knics[_RED_CARD_].macaddr, "");
-                               strcpy(knics[_RED_CARD_].colour, "");
-                               break;
-               case 'o':       sprintf(ucolour, "ORANGE");
-                               strcpy(knics[_ORANGE_CARD_].description, ctr[TR_UNSET]);
-                               strcpy(knics[_ORANGE_CARD_].macaddr, "");
-                               strcpy(knics[_ORANGE_CARD_].colour, "");
-                               break;
-               case 'b':       sprintf(ucolour, "BLUE");
-                               strcpy(knics[_BLUE_CARD_].description, ctr[TR_UNSET]);
-                               strcpy(knics[_BLUE_CARD_].macaddr, "");
-                               strcpy(knics[_BLUE_CARD_].colour, "");
-                               break;
-               default:        sprintf(ucolour, "DUMMY");
-                               break;
-       }
+       strcpy(knics[card].description, ctr[TR_UNSET]);
+       strcpy(knics[card].macaddr, "");
+       strcpy(knics[card].colour, "");
+       sprintf(temp, "%s_DEV", ucolourcard[card]);
+       replacekeyvalue(kv, temp, "");
+       sprintf(temp, "%s_MACADDR", ucolourcard[card]);
+       replacekeyvalue(kv, temp, "");
+       sprintf(temp, "%s_DESCRIPTION", ucolourcard[card]);
+       replacekeyvalue(kv, temp, "");
+
+       writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
+       freekeyvalues(kv);
+
+       fprintf(flog,"Card \"%s\" cleared\n",ucolourcard[card]); // #### Debug ####
+       return 0;
+}
+
+int ask_clear_card_entry(int card)
+{
+       char message[STRING_SIZE];
+       int rc;
 
-       sprintf(message, "(TR) Soll die Netzwerkkarte \"%s\" entfernt werden ?\n", colour);
+       sprintf(message, "(TR) Soll die Zuordnung der Netzwerkkarte \"%s\" entfernt werden ?\n", ucolourcard[card]);
        rc = newtWinChoice(ctr[TR_WARNING], ctr[TR_OK], ctr[TR_CANCEL], message);                               
 
        if ( rc = 0 || rc == 1) {
-               sprintf(temp1, "%s_DEV", ucolour);
-               sprintf(temp2, "%s_MACADDR", ucolour);
-               replacekeyvalue(kv, temp1, "");
-               replacekeyvalue(kv, temp2, "");
-               sprintf(temp1, "%s_DESCRIPTION", ucolour);
-               replacekeyvalue(kv, temp1, "");
-
-               writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
+               clear_card_entry(card);
+//             sprintf(temp1, "%s_DEV", ucolour);
+//             sprintf(temp2, "%s_MACADDR", ucolour);
+//             replacekeyvalue(kv, temp1, "");
+//             replacekeyvalue(kv, temp2, "");
+//             sprintf(temp1, "%s_DESCRIPTION", ucolour);
+//             replacekeyvalue(kv, temp1, "");
+
+//             writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
        } else return 1;
 
-       freekeyvalues(kv);
        return 0;
 }
 
index 5111153..1000a94 100644 (file)
@@ -62,6 +62,9 @@ int main(int argc, char *argv[])
 
        fprintf(flog, "Setup program started.\n");
 
+       if (!setlocale(LC_CTYPE,""))
+               fprintf(flog, "Locale not spezified. Check LANG, LC_CTYPE, RC_ALL.");
+
        kv = initkeyvalues();
        if (!(readkeyvalues(kv, CONFIG_ROOT "/main/settings")))
        {
@@ -178,8 +181,8 @@ int main(int argc, char *argv[])
                        goto EXIT;
                if (!(handledomainname()))
                        goto EXIT;
-               if (!(handleisdn()))
-                       goto EXIT;
+//             if (!(handleisdn()))
+//                     goto EXIT;
                if (!(handlenetworking()))
                        goto EXIT;
                if (!(handledhcp()))
index a86cf95..9bb9fd6 100644 (file)
@@ -25,15 +25,20 @@ extern char **ctr;
 extern int automode;
 
 #define HAS_GREEN 1
-#define HAS_ORANGE (configtype == 1 || configtype == 3 || configtype == 5 || configtype == 7)
-#define HAS_RED (configtype == 2 || configtype == 3 || configtype == 6 || configtype == 7)
-#define HAS_BLUE (configtype == 4 || configtype == 5 || configtype == 6 || configtype == 7)
-#define RED_IS_NOT_ETH (configtype == 0 || configtype == 1 || configtype == 4 || configtype == 5)
+#define HAS_RED (configtype == 1 || configtype == 2 || configtype == 3 || configtype == 4)
+#define HAS_ORANGE (configtype == 2 || configtype == 4)
+#define HAS_BLUE (configtype == 3 || configtype == 4)
+#define RED_IS_NOT_ETH (configtype == 0)
+
+//#define HAS_ORANGE (configtype == 1 || configtype == 3 || configtype == 5 || configtype == 7)
+//#define HAS_RED (configtype == 2 || configtype == 3 || configtype == 6 || configtype == 7)
+//#define HAS_BLUE (configtype == 4 || configtype == 5 || configtype == 6 || configtype == 7)
+//#define RED_IS_NOT_ETH (configtype == 0 || configtype == 1 || configtype == 4 || configtype == 5)
 
 extern struct nic nics[];
 extern struct knic knics[];
 
-char *configtypenames[] = { 
+/* char *configtypenames[] = { 
        "GREEN (RED is modem/ISDN)", 
        "GREEN + ORANGE (RED is modem/ISDN)", 
        "GREEN + RED",
@@ -43,6 +48,23 @@ char *configtypenames[] = {
        "GREEN + BLUE + RED",
        "GREEN + ORANGE + BLUE + RED",
        NULL };
+*/
+char *configtypenames[] = { 
+       "GREEN",
+       "GREEN + RED",
+       "GREEN + RED + ORANGE",
+       "GREEN + RED + BLUE",
+       "GREEN + RED + ORANGE + BLUE",
+       NULL };
+int configtypecards[] = {
+       1,      // "GREEN",
+       2,      // "GREEN + RED",
+       3,      // "GREEN + RED + ORANGE",
+       3,      // "GREEN + RED + BLUE",
+       4       // "GREEN + RED + ORANGE + BLUE",
+};
+
+
 int netaddresschange;
 
 int oktoleave(char *errormessage);
@@ -58,10 +80,16 @@ int handlenetworking(void)
 {
        int done;
        int choice;
+       int found;
        char errormessage[STRING_SIZE];
        
        netaddresschange = 0;
 
+       fprintf(flog,"Enter HandleNetworking\n"); // #### Debug ####
+
+       found = scan_network_cards();
+       fprintf(flog,"found %d cards\n",found); // #### Debug ####
+
        done = 0;
        while (!done)
        {
@@ -229,35 +257,48 @@ int configtypemenu(void)
        struct keyvalue *kv = initkeyvalues();
        char temp[STRING_SIZE] = "0";
        char message[1000];
-       int choice;
+       int choise, found;
        int rc;
 
+       fprintf(flog,"Enter ConfigMenu\n");
+
        if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
        {
                freekeyvalues(kv);
                errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
                return 0;
        }
+
+       found = scan_network_cards();
+       fprintf(flog,"found %d Card\'s\n", found ); // #### Debug ####
        
-       findkey(kv, "CONFIG_TYPE", temp); choice = atol(temp);
-       sprintf(message, ctr[TR_NETWORK_CONFIGURATION_TYPE_LONG], NAME);
-       rc = newtWinMenu(ctr[TR_NETWORK_CONFIGURATION_TYPE], message, 50, 5, 5,
-               6, configtypenames, &choice, ctr[TR_OK], ctr[TR_CANCEL], NULL);
+       findkey(kv, "CONFIG_TYPE", temp); choise = atol(temp);
+
+       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);
+               if ( configtypecards[choise] > found ) {
+                       sprintf(message, "(TR) Nicht genuegend Netzwerkkarten fuer diese Auswahl gefunden.\n\nBenoetigt: %d\nGefunden: %d\n", configtypecards[choise], found);
+                       errorbox(message);
+               }
+       }
+       while ( configtypecards[choise] > found);
 
        if (rc == 0 || rc == 1)
        {
-               runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
-                       ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
-       
-               sprintf(temp, "%d", choice);
+//     if (automode != 0) runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange", ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
+
+               sprintf(temp, "%d", choise);
                replacekeyvalue(kv, "CONFIG_TYPE", temp);
-               replacekeyvalue(kv, "ORANGE_DEV", "");
-               replacekeyvalue(kv, "BLUE_DEV", "");
-               replacekeyvalue(kv, "RED_DEV", "");
+               clear_card_entry(_RED_CARD_);
+               clear_card_entry(_ORANGE_CARD_);
+               clear_card_entry(_BLUE_CARD_);
+
                writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
                netaddresschange = 1;
        }
-       
        freekeyvalues(kv);
        
        return 0;
@@ -275,9 +316,9 @@ int drivermenu(void)
 //     struct knic *pknics = knics;
 //     pknics = knics;
        int configtype;
-       int rc, kcount = 0, found, neednics; //i = 0, count = 0,
+       int rc, kcount = 0, neednics; //i = 0, count = 0,
        
-       fprintf(flog,"enter drivermenu\n"); // #### Debug ####
+       fprintf(flog,"Enter driverenu\n"); // #### Debug ####
 
        if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
        {
@@ -298,8 +339,6 @@ int drivermenu(void)
 
        strcpy(message, ctr[TR_CONFIGURE_NETWORK_DRIVERS]);
 
-       found = scan_network_cards();
-       fprintf(flog,"found %d Card\'s\n", found ); // #### Debug ####
        kcount = 0;     // counter to find knowing nics.
        neednics = 0;   // counter to use needing nics.
        if (HAS_GREEN) {
@@ -412,6 +451,11 @@ int cardassigned(char *colour)
                return 1;
 }
 
+int set_menu_entry_for(int *nr, int *card)
+{
+
+}
+
 int changedrivers(void)
 {
        struct keyvalue *kv = initkeyvalues();
@@ -437,19 +481,19 @@ int changedrivers(void)
        if (configtype == 0)
                { green = 1; }
        else if (configtype == 1)
-               { green = 1; orange = 1; }
-       else if (configtype == 2)
                { green = 1; red = 1; }
-       else if (configtype == 3)
+       else if (configtype == 2)
                { green = 1; red = 1; orange = 1; }
-       else if (configtype == 4)
-               { green = 1; blue = 1; }
-       else if (configtype == 5)
-               { green = 1; blue = 1; orange = 1; }
-       else if (configtype == 6)
+       else if (configtype == 3)
                { green = 1; red = 1; blue = 1; }
-       else if (configtype == 7)
-               { green = 1; red = 1; blue = 1; orange = 1; }
+       else if (configtype == 4)
+               { green = 1; red=1; orange=1; blue = 1; }
+//     else if (configtype == 5)
+//             { green = 1; blue = 1; orange = 1; }
+//     else if (configtype == 6)
+//             { green = 1; red = 1; blue = 1; }
+//     else if (configtype == 7)
+//             { green = 1; red = 1; blue = 1; orange = 1; }
 
        fprintf(flog,"found: g=%d r=%d o=%d b=%d\n",green, red, orange, blue); // #### Debug ####
 
@@ -462,7 +506,6 @@ int changedrivers(void)
                        strcpy(MenuInhalt[count], "GREEN");
                        pMenuInhalt[count] = MenuInhalt[count];
                        NicEntry[_GREEN_CARD_] = count;
-//                     fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
                        sprintf(temp, "GREEN:  %s\n", knics[_GREEN_CARD_].description);
                        strcat(message, temp);
                        if ( strlen(knics[_GREEN_CARD_].macaddr) ) {
@@ -520,15 +563,15 @@ int changedrivers(void)
                if ( rc == 0 || rc == 1) {
 //                     write_configs_netudev(pnics[choise].description, pnics[choise].macaddr, colour);
                        // insert nic to colourcard
-                       if ((green) && ( choise == NicEntry[0])) nicmenu("green");
-                       if ((red) && ( choise == NicEntry[1])) nicmenu("red");
-                       if ((orange) && ( choise == NicEntry[2])) nicmenu("orange");
-                       if ((blue) && ( choise == NicEntry[3])) nicmenu("blue");
+                       if ((green) && ( choise == NicEntry[0])) nicmenu(_GREEN_CARD_);
+                       if ((red) && ( choise == NicEntry[1])) nicmenu(_RED_CARD_);
+                       if ((orange) && ( choise == NicEntry[2])) nicmenu(_ORANGE_CARD_);
+                       if ((blue) && ( choise == NicEntry[3])) nicmenu(_BLUE_CARD_);
                } else if (rc == 2) {
-                       if ((green) && ( choise == NicEntry[0])) remove_nic_entry("green");
-                       if ((red) && ( choise == NicEntry[1])) remove_nic_entry("red");
-                       if ((orange) && ( choise == NicEntry[2])) remove_nic_entry("orange");
-                       if ((blue) && ( choise == NicEntry[3])) remove_nic_entry("blue");
+                       if ((green) && ( choise == NicEntry[0])) ask_clear_card_entry(_GREEN_CARD_);
+                       if ((red) && ( choise == NicEntry[1])) ask_clear_card_entry(_RED_CARD_);
+                       if ((orange) && ( choise == NicEntry[2])) ask_clear_card_entry(_ORANGE_CARD_);
+                       if ((blue) && ( choise == NicEntry[3])) ask_clear_card_entry(_BLUE_CARD_);
                } 
 //             else {
 //                     errorbox("Sie haben keine Netzwerkkarte ausgewaehlt.\n");