mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-20 07:53:01 +02:00
installer: Add support for RAID.
This commit is contained in:
3
config/rootfiles/installer/mdadm
Normal file
3
config/rootfiles/installer/mdadm
Normal file
@@ -0,0 +1,3 @@
|
||||
lib/udev/rules.d/64-md-raid.rules
|
||||
sbin/mdadm
|
||||
sbin/mdmon
|
||||
@@ -359,6 +359,10 @@ char *de_tr[] = {
|
||||
"Hänge Dateisysteme ein...",
|
||||
/* TR_UNABLE_TO_MOUNT_FILESYSTEMS */
|
||||
"Die Dateisysteme konnten nicht eingehangen werden.",
|
||||
/* TR_BUILDING_RAID */
|
||||
"Erstelle RAID...",
|
||||
/* TR_UNABLE_TO_BUILD_RAID */
|
||||
"Das RAID konnte nicht erstellt werden.",
|
||||
/* TR_NO_IPCOP_TARBALL_FOUND */
|
||||
"Auf dem Webserver wurde kein ipcop-Tarball gefunden.",
|
||||
/* TR_NO_ORANGE_INTERFACE */
|
||||
|
||||
@@ -355,6 +355,10 @@ char *en_tr[] = {
|
||||
"Mounting filesystems...",
|
||||
/* TR_UNABLE_TO_MOUNT_FILESYSTEMS */
|
||||
"Unable to mount filesystems.",
|
||||
/* TR_BUILDING_RAID */
|
||||
"Building RAID...",
|
||||
/* TR_UNABLE_TO_BUILD_RAID */
|
||||
"Unable to build RAID.",
|
||||
/* TR_NO_IPCOP_TARBALL_FOUND */
|
||||
"No ipcop tarball found on Web Server.",
|
||||
/* TR_NO_ORANGE_INTERFACE */
|
||||
|
||||
@@ -351,6 +351,10 @@ char *es_tr[] = {
|
||||
"Mounting filesystems...",
|
||||
/* TR_UNABLE_TO_MOUNT_FILESYSTEMS */
|
||||
"Unable to mount filesystems.",
|
||||
/* TR_BUILDING_RAID */
|
||||
"Building RAID...",
|
||||
/* TR_UNABLE_TO_BUILD_RAID */
|
||||
"Unable to build RAID.",
|
||||
/* TR_NO_IPCOP_TARBALL_FOUND */
|
||||
"No se encontró ningun archivo tarball de ipcop en el servidor web",
|
||||
/* TR_NO_ORANGE_INTERFACE */
|
||||
|
||||
@@ -351,6 +351,10 @@ char *fr_tr[] = {
|
||||
"Mounting filesystems...",
|
||||
/* TR_UNABLE_TO_MOUNT_FILESYSTEMS */
|
||||
"Unable to mount filesystems.",
|
||||
/* TR_BUILDING_RAID */
|
||||
"Building RAID...",
|
||||
/* TR_UNABLE_TO_BUILD_RAID */
|
||||
"Unable to build RAID.",
|
||||
/* TR_NO_IPCOP_TARBALL_FOUND */
|
||||
"Aucun tarball ipcop trouvé sur le serveur Web.",
|
||||
/* TR_NO_ORANGE_INTERFACE */
|
||||
|
||||
@@ -355,6 +355,10 @@ char *nl_tr[] = {
|
||||
"Mounting filesystems...",
|
||||
/* TR_UNABLE_TO_MOUNT_FILESYSTEMS */
|
||||
"Unable to mount filesystems.",
|
||||
/* TR_BUILDING_RAID */
|
||||
"Building RAID...",
|
||||
/* TR_UNABLE_TO_BUILD_RAID */
|
||||
"Unable to build RAID.",
|
||||
/* TR_NO_IPCOP_TARBALL_FOUND */
|
||||
"Er is geen ipcop tarball gevonden op de webserver.",
|
||||
/* TR_NO_ORANGE_INTERFACE */
|
||||
|
||||
@@ -351,6 +351,10 @@ char *pl_tr[] = {
|
||||
"Mounting filesystems...",
|
||||
/* TR_UNABLE_TO_MOUNT_FILESYSTEMS */
|
||||
"Unable to mount filesystems.",
|
||||
/* TR_BUILDING_RAID */
|
||||
"Building RAID...",
|
||||
/* TR_UNABLE_TO_BUILD_RAID */
|
||||
"Unable to build RAID.",
|
||||
/* TR_NO_IPCOP_TARBALL_FOUND */
|
||||
"Nie znaleziono archiwum tar ipcop na serwerze Web.",
|
||||
/* TR_NO_ORANGE_INTERFACE */
|
||||
|
||||
@@ -349,6 +349,10 @@ char *ru_tr[] = {
|
||||
"Mounting filesystems...",
|
||||
/* TR_UNABLE_TO_MOUNT_FILESYSTEMS */
|
||||
"Unable to mount filesystems.",
|
||||
/* TR_BUILDING_RAID */
|
||||
"Building RAID...",
|
||||
/* TR_UNABLE_TO_BUILD_RAID */
|
||||
"Unable to build RAID.",
|
||||
/* TR_NO_IPCOP_TARBALL_FOUND */
|
||||
"На сервере не найден архив ipcop.",
|
||||
/* TR_NO_ORANGE_INTERFACE */
|
||||
|
||||
@@ -355,6 +355,10 @@ char *tr_tr[] = {
|
||||
"Mounting filesystems...",
|
||||
/* TR_UNABLE_TO_MOUNT_FILESYSTEMS */
|
||||
"Unable to mount filesystems.",
|
||||
/* TR_BUILDING_RAID */
|
||||
"Building RAID...",
|
||||
/* TR_UNABLE_TO_BUILD_RAID */
|
||||
"Unable to build RAID.",
|
||||
/* TR_NO_IPCOP_TARBALL_FOUND */
|
||||
"Web sunucuda hiçbir ipfire arşivi bulunamadı.",
|
||||
/* TR_NO_ORANGE_INTERFACE */
|
||||
|
||||
@@ -116,7 +116,7 @@ char* hw_find_source_medium(struct hw* hw) {
|
||||
|
||||
// Skip everything what we cannot work with
|
||||
if (strstartswith(dev_path, "/dev/loop") || strstartswith(dev_path, "/dev/fd") ||
|
||||
strstartswith(dev_path, "/dev/ram"))
|
||||
strstartswith(dev_path, "/dev/ram") || strstartswith(dev_path, "/dev/md"))
|
||||
continue;
|
||||
|
||||
if (hw_test_source_medium(dev_path)) {
|
||||
@@ -173,7 +173,8 @@ struct hw_disk** hw_find_disks(struct hw* hw) {
|
||||
|
||||
// Skip everything what we cannot work with
|
||||
if (strstartswith(dev_path, "/dev/loop") || strstartswith(dev_path, "/dev/fd") ||
|
||||
strstartswith(dev_path, "/dev/ram") || strstartswith(dev_path, "/dev/sr")) {
|
||||
strstartswith(dev_path, "/dev/ram") || strstartswith(dev_path, "/dev/sr") ||
|
||||
strstartswith(dev_path, "/dev/md")) {
|
||||
udev_device_unref(dev);
|
||||
continue;
|
||||
}
|
||||
@@ -410,6 +411,7 @@ struct hw_destination* hw_make_destination(int part_type, struct hw_disk** disks
|
||||
} else if (part_type == HW_PART_TYPE_RAID1) {
|
||||
dest->disk1 = *disks++;
|
||||
dest->disk2 = *disks;
|
||||
dest->raid_level = 1;
|
||||
|
||||
snprintf(dest->path, sizeof(dest->path), "/dev/md0");
|
||||
}
|
||||
@@ -675,3 +677,48 @@ int hw_umount_filesystems(struct hw_destination* dest, const char* prefix) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hw_setup_raid(struct hw_destination* dest) {
|
||||
char* cmd = NULL;
|
||||
|
||||
assert(dest->is_raid);
|
||||
|
||||
asprintf(&cmd, "echo \"y\" | /sbin/mdadm --create --verbose --metadata=0.9 %s", dest->path);
|
||||
|
||||
switch (dest->raid_level) {
|
||||
case 1:
|
||||
asprintf(&cmd, "%s --level=1 --raid-devices=2", cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (dest->disk1) {
|
||||
asprintf(&cmd, "%s %s", cmd, dest->disk1->path);
|
||||
}
|
||||
|
||||
if (dest->disk2) {
|
||||
asprintf(&cmd, "%s %s", cmd, dest->disk2->path);
|
||||
}
|
||||
|
||||
int r = mysystem(cmd);
|
||||
free(cmd);
|
||||
|
||||
// Wait a moment until the device has been properly brought up
|
||||
if (r == 0) {
|
||||
unsigned int counter = 10;
|
||||
while (counter-- > 0) {
|
||||
sleep(1);
|
||||
|
||||
if (access(dest->path, R_OK) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int hw_stop_all_raid_arrays() {
|
||||
return mysystem("/sbin/mdadm --stop --scan");
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ struct hw_destination {
|
||||
char path[DEV_SIZE];
|
||||
|
||||
int is_raid;
|
||||
int raid_level;
|
||||
const struct hw_disk* disk1;
|
||||
const struct hw_disk* disk2;
|
||||
|
||||
@@ -112,4 +113,7 @@ int hw_create_filesystems(struct hw_destination* dest);
|
||||
int hw_mount_filesystems(struct hw_destination* dest, const char* prefix);
|
||||
int hw_umount_filesystems(struct hw_destination* dest, const char* prefix);
|
||||
|
||||
int hw_setup_raid(struct hw_destination* dest);
|
||||
int hw_stop_all_raid_arrays();
|
||||
|
||||
#endif /* HEADER_HW_H */
|
||||
|
||||
@@ -239,7 +239,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Load common modules
|
||||
mysystem("/sbin/modprobe vfat"); // USB key
|
||||
|
||||
hw_stop_all_raid_arrays();
|
||||
|
||||
/* German is the default */
|
||||
for (choice = 0; langnames[choice]; choice++)
|
||||
{
|
||||
@@ -454,6 +455,19 @@ int main(int argc, char *argv[]) {
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
// Setting up RAID if needed.
|
||||
if (destination->is_raid) {
|
||||
statuswindow(60, 4, title, ctr[TR_BUILDING_RAID]);
|
||||
|
||||
rc = hw_setup_raid(destination);
|
||||
if (rc) {
|
||||
errorbox(ctr[TR_UNABLE_TO_BUILD_RAID]);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
newtPopWindow();
|
||||
}
|
||||
|
||||
// Execute the partitioning...
|
||||
statuswindow(60, 4, title, ctr[TR_PARTITIONING_DISK]);
|
||||
|
||||
@@ -619,6 +633,8 @@ EXIT:
|
||||
free(destination);
|
||||
}
|
||||
|
||||
hw_stop_all_raid_arrays();
|
||||
|
||||
if (selected_disks)
|
||||
hw_free_disks(selected_disks);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user