]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/setup/main.c
1 /* SmoothWall setup program.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
6 * (c) Lawrence Manning, 2001
7 * Contains main entry point, and misc functions.
13 #define _(x) dgettext("setup", x)
22 struct nic nics
[20] = { { "" , "" , "" , "" } };
23 struct knic knics
[20] = { { "" , "" , "" , "" } };
25 int main(int argc
, char *argv
[])
28 char *sections
[11]; /* need to fill this out AFTER knowning lang */
31 char selectedshortlang
[STRING_SIZE
] = "en";
32 char title
[STRING_SIZE
];
36 /* Log file/terminal stuff. */
40 mylog
= strdup("/var/log/setup.log");
42 if (!(flog
= fopen(mylog
, "w+")))
44 printf("Couldn't open log terminal\n");
51 fprintf(flog
, "Setup program started.\n");
53 if (!setlocale(LC_CTYPE
,""))
54 fprintf(flog
, "Locale not spezified. Check LANG, LC_CTYPE, RC_ALL.");
58 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/main/settings")))
60 printf("%s is not properly installed.\n", NAME
);
63 findkey(kv
, "LANGUAGE", selectedshortlang
);
65 for (langcounter
= 0; langtrs
[langcounter
]; langcounter
++)
67 if (strcmp(selectedshortlang
, shortlangnames
[langcounter
]) == 0)
69 ctr
= langtrs
[langcounter
];
76 for (choice
= 0; shortlangnames
[choice
]; choice
++)
78 if (strcmp(shortlangnames
[choice
], "en") == 0)
81 if (!shortlangnames
[choice
])
83 ctr
= langtrs
[choice
];
87 sections
[0] = _("Keyboard mapping");
88 sections
[1] = _("Timezone");
89 sections
[2] = _("Hostname");
90 sections
[3] = _("Domain name");
91 sections
[4] = _("Networking");
92 sections
[5] = _("ISDN");
93 sections
[6] = _("'root' password");
94 sections
[7] = _("'admin' password");
100 if ((f_title
= fopen ("/etc/issue", "r")))
102 fgets (title
, STRING_SIZE
, f_title
);
103 if (title
[strlen(title
) - 1] == '\n')
104 title
[strlen(title
) - 1] = '\0';
107 sprintf (title
, "%s %s - %s", NAME
, VERSION
, SLOGAN
);
109 newtDrawRootText(14, 0, title
);
110 newtPushHelpLine(_(" <Tab>/<Alt-Tab> between elements | <Space> selects"));
117 rc
= newtWinMenu(_("Section menu"),
118 _("Select the item you wish to configure."), 50, 5, 5, 11,
119 sections
, &choice
, _("OK"), _("Quit"), NULL
);
151 handlerootpassword();
155 handleadminpassword();
165 if (!(handlekeymap()))
167 if (!(handletimezone()))
169 if (!(handlehostname()))
171 if (!(handledomainname()))
173 if (!(handlerootpassword()))
175 if (!(handleadminpassword()))
179 if (!(handlenetworking()))
190 sprintf (title
, "%s %s - %s", NAME
, VERSION
, SLOGAN
);
192 newtWinMessage(title
, _("OK"), _("Setup is complete."));
194 newtWinMessage(_("Warning"), _("OK"),
195 _("Initial setup was not entirely complete. "
196 "You must ensure that Setup is properly finished by running "
197 "setup again at the shell."));
199 fprintf(flog
, "Setup program has not finished.\n");
209 fprintf(flog
, "Setup program ended.\n");