]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/install+setup/setup/main.c
Ă„nderungen am Installer/Setup vorgenommen. ISDN wird erstmal nicht Ă¼ber den Installer...
[people/pmueller/ipfire-2.x.git] / src / install+setup / setup / main.c
CommitLineData
8af06406
HS
1/* SmoothWall setup program.
2 *
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
5 *
6 * (c) Lawrence Manning, 2001
7 * Contains main entry point, and misc functions.
8 *
9 * modified 16/11/2002 eoberlander - French language added
10 *
11 * $Id: main.c,v 1.4.2.7 2005/12/01 20:13:08 eoberlander Exp $
12 *
13 */
14
15#include "setup.h"
16
17FILE *flog = NULL;
18char *mylog;
19
20char **ctr = NULL;
21
22int automode = 0;
23
5057b611
HS
24struct nic nics[20] = { { "" , "" } };
25struct knic knics[20] = { { "" , "" , "" } };
26
8af06406 27extern char *en_tr[];
8af06406 28extern char *de_tr[];
8af06406
HS
29
30int main(int argc, char *argv[])
31{
32#ifdef LANG_EN_ONLY
33 char *shortlangnames[] = { "en", NULL };
34 char **langtrs[] = { en_tr, NULL };
8af06406
HS
35#else
36 char *shortlangnames[] = { "de", "en", NULL };
37 char **langtrs[] = { de_tr, en_tr, NULL };
38#endif
39 int choice;
40 char *sections[11]; /* need to fill this out AFTER knowning lang */
41 int rc;
42 struct keyvalue *kv;
43 char selectedshortlang[STRING_SIZE] = "en";
44 char title[STRING_SIZE];
45 int langcounter;
46 int autook = 0;
47
48 /* Log file/terminal stuff. */
49 if (argc >= 2)
50 mylog = argv[1];
51 else
069680ac 52 mylog = strdup("/var/log/setup.log");
8af06406
HS
53
54 if (!(flog = fopen(mylog, "w+")))
55 {
56 printf("Couldn't open log terminal\n");
57 return 1;
58 }
59
60 if (argc >= 3)
61 automode = 1;
62
63 fprintf(flog, "Setup program started.\n");
64
9b040aa0
HS
65 if (!setlocale(LC_CTYPE,""))
66 fprintf(flog, "Locale not spezified. Check LANG, LC_CTYPE, RC_ALL.");
67
8af06406
HS
68 kv = initkeyvalues();
69 if (!(readkeyvalues(kv, CONFIG_ROOT "/main/settings")))
70 {
71 printf("%s is not properly installed.\n", NAME);
72 return 1;
73 }
74 findkey(kv, "LANGUAGE", selectedshortlang);
75
76 for (langcounter = 0; langtrs[langcounter]; langcounter++)
77 {
78 if (strcmp(selectedshortlang, shortlangnames[langcounter]) == 0)
79 {
80 ctr = langtrs[langcounter];
81 break;
82 }
83 }
84
85 if (!ctr)
86 {
87 /* zh,lt,ro,ru,th languages not available in setup, so use English */
88 for (choice = 0; shortlangnames[choice]; choice++)
89 {
90 if (strcmp(shortlangnames[choice], "en") == 0)
91 break;
92 }
93 if (!shortlangnames[choice])
94 goto EXIT;
95 ctr = langtrs[choice];
96 }
97
98 sections[0] = ctr[TR_KEYBOARD_MAPPING];
99 sections[1] = ctr[TR_TIMEZONE];
100 sections[2] = ctr[TR_HOSTNAME];
101 sections[3] = ctr[TR_DOMAINNAME];
102 sections[4] = ctr[TR_ISDN_CONFIGURATION];
103 sections[5] = ctr[TR_NETWORKING];
104 sections[6] = ctr[TR_ROOT_PASSWORD];
105 sections[7] = ctr[TR_ADMIN_PASSWORD];
106 sections[8] = NULL;
107
108 newtInit();
109 newtCls();
110 FILE *f_title;
111 if ((f_title = fopen ("/etc/issue", "r")))
112 {
113 fgets (title, STRING_SIZE, f_title);
114 if (title[strlen(title) - 1] == '\n')
115 title[strlen(title) - 1] = '\0';
116 fclose (f_title);
117 } else {
069680ac 118 sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
8af06406
HS
119 }
120 newtDrawRootText(14, 0, title);
121 newtPushHelpLine(ctr[TR_HELPLINE]);
122
123 if (automode == 0)
124 {
125 choice = 0;
126 for (;;)
127 {
128 rc = newtWinMenu(ctr[TR_SECTION_MENU],
129 ctr[TR_SELECT_THE_ITEM], 50, 5, 5, 11,
130 sections, &choice, ctr[TR_OK], ctr[TR_QUIT], NULL);
131
132 if (rc == 2)
133 break;
134
135 switch (choice)
136 {
137 case 0:
138 handlekeymap();
139 break;
140
141 case 1:
142 handletimezone();
143 break;
144
145 case 2:
146 handlehostname();
147 break;
148
149 case 3:
150 handledomainname();
151 break;
152
153 case 4:
154 handleisdn();
155 break;
156
157 case 5:
158 handlenetworking();
159 break;
160
161 case 6:
162 handlerootpassword();
163 break;
164
165 case 7:
166 handleadminpassword();
167 break;
168
169 default:
170 break;
171 }
172 }
173 }
174 else
175 {
176 if (!(handlekeymap()))
177 goto EXIT;
178 if (!(handletimezone()))
179 goto EXIT;
180 if (!(handlehostname()))
181 goto EXIT;
182 if (!(handledomainname()))
183 goto EXIT;
9b040aa0
HS
184// if (!(handleisdn()))
185// goto EXIT;
8af06406
HS
186 if (!(handlenetworking()))
187 goto EXIT;
188 if (!(handledhcp()))
189 goto EXIT;
190 if (!(handlerootpassword()))
191 goto EXIT;
192 if (!(handleadminpassword()))
193 goto EXIT;
194
195 autook = 1;
196 }
197
198EXIT:
199 if (automode != 0)
200 {
069680ac 201 sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
8af06406
HS
202 if (autook)
203 newtWinMessage(title, ctr[TR_OK], ctr[TR_SETUP_FINISHED]);
204 else
205 newtWinMessage(ctr[TR_WARNING], ctr[TR_OK], ctr[TR_SETUP_NOT_COMPLETE]);
206 }
069680ac 207
8af06406
HS
208 fprintf(flog, "Setup program ended.\n");
209 fflush(flog);
210 fclose(flog);
069680ac 211
8af06406
HS
212 newtFinished();
213
214 return 0;
215}
216