]> git.ipfire.org Git - ipfire-2.x.git/blame - src/setup/misc.c
IDS: Call helper script when red interface gets up
[ipfire-2.x.git] / src / setup / misc.c
CommitLineData
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
17extern FILE *flog;
18extern char *mylog;
19
bba7212c
MT
20extern int automode;
21
bba7212c
MT
22int 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}