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