1 /* SmoothWall install program.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
6 * (c) Lawrence Manning, 2001
7 * Write the config and get password stuff.
20 /* called to write out all config files using the keyvalue interface. */
21 int write_disk_configs(struct devparams
*dp
)
23 char devnode
[STRING_SIZE
];
26 snprintf(devnode
, STRING_SIZE
, "%s", dp
->devnode
);
27 if (symlink(devnode
, "/harddisk/dev/harddisk"))
29 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK
]);
33 snprintf(devnode
, STRING_SIZE
, "%sp1", dp
->devnode
);
35 snprintf(devnode
, STRING_SIZE
, "%s1", dp
->devnode
);
36 if (symlink(devnode
, "/harddisk/dev/harddisk1"))
38 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK1
]);
42 snprintf(devnode
, STRING_SIZE
, "%sp2", dp
->devnode
);
44 snprintf(devnode
, STRING_SIZE
, "%s2", dp
->devnode
);
45 if (symlink(devnode
, "/harddisk/dev/harddisk2"))
47 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK2
]);
51 snprintf(devnode
, STRING_SIZE
, "%sp3", dp
->devnode
);
53 snprintf(devnode
, STRING_SIZE
, "%s3", dp
->devnode
);
54 if (symlink(devnode
, "/harddisk/dev/harddisk3"))
56 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK3
]);
60 snprintf(devnode
, STRING_SIZE
, "%sp4", dp
->devnode
);
62 snprintf(devnode
, STRING_SIZE
, "%s4", dp
->devnode
);
63 if (symlink(devnode
, "/harddisk/dev/harddisk4"))
65 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK4
]);
69 /* Add /dev/root symlink linking to the root filesystem to
70 * keep updfstab happy */
72 snprintf(devnode
, STRING_SIZE
, "%sp4", dp
->devnode
);
74 snprintf(devnode
, STRING_SIZE
, "%s4", dp
->devnode
);
75 if (symlink(devnode
, "/harddisk/dev/root"))
77 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_ROOT
]);
84 int write_lang_configs( char *lang
)
86 struct keyvalue
*kv
= initkeyvalues();
88 /* default stuff for main/settings. */
89 replacekeyvalue(kv
, "LANGUAGE", lang
);
90 replacekeyvalue(kv
, "HOSTNAME", SNAME
);
91 writekeyvalues(kv
, "/harddisk" CONFIG_ROOT
"/main/settings");
97 int write_ethernet_configs(struct keyvalue
*ethernetkv
)
99 /* Write out the network settings we got from a few mins ago. */
100 writekeyvalues(ethernetkv
, "/harddisk" CONFIG_ROOT
"/ethernet/settings");
104 /* Taken from the cdrom one. */
105 int getpassword(char *password
, char *text
)
107 char *values
[] = { NULL
, NULL
, NULL
}; /* pointers for the values. */
108 struct newtWinEntry entries
[] =
110 { ctr
[TR_PASSWORD_PROMPT
], &values
[0], 2 },
111 { ctr
[TR_AGAIN_PROMPT
], &values
[1], 2 },
114 char title
[STRING_SIZE
];
121 sprintf (title
, "%s v%s - %s", NAME
, VERSION
, SLOGAN
);
122 rc
= newtWinEntries(title
, text
,
123 50, 5, 5, 20, entries
, ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
127 if (strlen(values
[0]) == 0 || strlen(values
[1]) == 0)
129 errorbox(ctr
[TR_PASSWORD_CANNOT_BE_BLANK
]);
131 strcpy(values
[0], "");
132 strcpy(values
[1], "");
134 else if (strcmp(values
[0], values
[1]) != 0)
136 errorbox(ctr
[TR_PASSWORDS_DO_NOT_MATCH
]);
138 strcpy(values
[0], "");
139 strcpy(values
[1], "");
145 strncpy(password
, values
[0], STRING_SIZE
);
147 if (values
[0]) free(values
[0]);
148 if (values
[1]) free(values
[1]);