]>
Commit | Line | Data |
---|---|---|
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 | * Misc. stuff for the lib. | |
8 | * | |
9 | */ | |
10 | ||
11 | // Translation | |
12 | #include <libintl.h> | |
13 | #define _(x) dgettext("setup", x) | |
14 | ||
15 | #include "setup.h" | |
16 | ||
17 | extern FILE *flog; | |
18 | extern char *mylog; | |
19 | ||
20 | extern int automode; | |
21 | ||
22 | int writehostsfiles(void) | |
23 | { | |
24 | char message[1000]; | |
25 | struct keyvalue *kv; | |
26 | char hostname[STRING_SIZE]; | |
27 | char domainname[STRING_SIZE] = "localdomain"; | |
28 | char commandstring[STRING_SIZE]; | |
29 | ||
30 | kv = initkeyvalues(); | |
31 | if (!(readkeyvalues(kv, CONFIG_ROOT "/main/settings"))) | |
32 | { | |
33 | freekeyvalues(kv); | |
34 | errorbox(_("Unable to open settings file")); | |
35 | return 0; | |
36 | } | |
37 | strcpy(hostname, SNAME ); | |
38 | findkey(kv, "HOSTNAME", hostname); | |
39 | findkey(kv, "DOMAINNAME", domainname); | |
40 | freekeyvalues(kv); | |
41 | ||
42 | sprintf(commandstring, "/bin/hostname %s.%s", hostname, domainname); | |
43 | if (mysystem(NULL, commandstring)) | |
44 | { | |
45 | errorbox(_("Unable to set hostname.")); | |
46 | return 0; | |
47 | } | |
48 | ||
49 | return 1; | |
50 | } |