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