git-svn-id: http://svn.ipfire.org/svn/ipfire/1.4/source@36 ea5c0bd1-69bd-2848-81d8...
[people/pmueller/ipfire-2.x.git] / src / install+setup / install / config.c
CommitLineData
cd1a2927
MT
1/* SmoothWall install program.\r
2 *\r
3 * This program is distributed under the terms of the GNU General Public\r
4 * Licence. See the file COPYING for details.\r
5 *\r
6 * (c) Lawrence Manning, 2001\r
7 * Write the config and get password stuff.\r
8 * \r
9 * $Id: config.c,v 1.6.2.3 2005/12/07 20:42:48 franck78 Exp $\r
10 * \r
11 */\r
12\r
13#include "install.h"\r
14extern char **ctr; // text translation table\r
15\r
16/* called to write out all config files using the keyvalue interface. */\r
17int write_disk_configs(struct devparams *dp)\r
18{\r
19 char devnode[STRING_SIZE];\r
20 char partition[STRING_SIZE];\r
21 char *messages[5] = { NULL,\r
22 ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK1],\r
23 ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK2],\r
24 ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK3],\r
25 ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK4] \r
26 };\r
27 /* dev node links. */\r
28 sprintf(devnode, "%s", dp->devnode_disk_run);\r
29 if (symlink(devnode, "/harddisk/dev/harddisk"))\r
30 {\r
31 errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK]);\r
32 return 0;\r
33 }\r
34 \r
35 int j;\r
36 for (j=1; j<5; j++) {\r
37 sprintf(devnode, "%s%d", dp->devnode_part_run,j);\r
38 sprintf(partition,"/harddisk/dev/harddisk%d",j);\r
39 if (symlink(devnode, partition))\r
40 {\r
41 errorbox( messages[j] );\r
42 return 0;\r
43 }\r
44 }\r
45\r
46 /* Add /dev/root symlink linking to the root filesystem to \r
47 * keep updfstab happy */\r
48 sprintf(devnode, "%s4", dp->devnode_part_run);\r
49 if (symlink(devnode, "/harddisk/dev/root"))\r
50 {\r
51 errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_ROOT]);\r
52 return 0;\r
53 }\r
54\r
55 return 1;\r
56}\r
57\r
58int write_lang_configs( char *lang)\r
59{\r
60 struct keyvalue *kv = initkeyvalues();\r
61 \r
62 /* default stuff for main/settings. */\r
63 replacekeyvalue(kv, "LANGUAGE", lang);\r
64 replacekeyvalue(kv, "HOSTNAME", SNAME);\r
65 writekeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings");\r
66 freekeyvalues(kv);\r
67 \r
68 return 1;\r
69}\r
70\r
71int write_ethernet_configs(struct keyvalue *ethernetkv)\r
72{\r
73 /* Write out the network settings we got from a few mins ago. */\r
74 writekeyvalues(ethernetkv, "/harddisk" CONFIG_ROOT "/ethernet/settings");\r
75 return 1;\r
76}\r
77\r
78/* Taken from the cdrom one. */\r
79int getpassword(char *password, char *text)\r
80{\r
81 char *values[] = { NULL, NULL, NULL }; /* pointers for the values. */\r
82 struct newtWinEntry entries[] =\r
83 { \r
84 { ctr[TR_PASSWORD_PROMPT], &values[0], 2 },\r
85 { ctr[TR_AGAIN_PROMPT], &values[1], 2 },\r
86 { NULL, NULL, 0 }\r
87 };\r
88 char title[STRING_SIZE];\r
89 int rc;\r
90 int done;\r
91 \r
92 do\r
93 {\r
94 done = 1;\r
95 sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);\r
96 rc = newtWinEntries(title, text,\r
97 50, 5, 5, 20, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL);\r
98 \r
99 if (rc != 2)\r
100 {\r
101 if (strlen(values[0]) == 0 || strlen(values[1]) == 0)\r
102 {\r
103 errorbox(ctr[TR_PASSWORD_CANNOT_BE_BLANK]);\r
104 done = 0;\r
105 strcpy(values[0], "");\r
106 strcpy(values[1], ""); \r
107 }\r
108 else if (strcmp(values[0], values[1]) != 0)\r
109 {\r
110 errorbox(ctr[TR_PASSWORDS_DO_NOT_MATCH]);\r
111 done = 0;\r
112 strcpy(values[0], "");\r
113 strcpy(values[1], ""); \r
114 }\r
115 }\r
116 }\r
117 while (!done);\r
118\r
119 strncpy(password, values[0], STRING_SIZE);\r
120\r
121 if (values[0]) free(values[0]);\r
122 if (values[1]) free(values[1]);\r
123\r
124 return rc;\r
125}\r