]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/installer/hw.c
Merge branch 'kernel-test' into seventeen
[ipfire-2.x.git] / src / installer / hw.c
index e453e23cbe14debf38ff89e312cf67e45aa839a2..9b9a2d00291ae7b6911bd5eb10848e7c31c444a9 100644 (file)
@@ -323,6 +323,27 @@ struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection) {
        return ret;
 }
 
+struct hw_disk** hw_select_first_disk(const struct hw_disk** disks) {
+       struct hw_disk** ret = hw_create_disks();
+       struct hw_disk** selected_disks = ret;
+
+       unsigned int num_disks = hw_count_disks(disks);
+       assert(num_disks > 0);
+
+       for (unsigned int i = 0; i < num_disks; i++) {
+               struct hw_disk *disk = disks[i];
+               disk->ref++;
+
+               *selected_disks++ = disk;
+               break;
+       }
+
+       // Set sentinel
+       *selected_disks = NULL;
+
+       return ret;
+}
+
 static unsigned long long hw_swap_size(struct hw_destination* dest) {
        unsigned long long memory = hw_memory();
 
@@ -1016,3 +1037,31 @@ void hw_sync() {
        sync();
        sync();
 }
+
+int hw_start_networking(const char* output) {
+       return mysystem(output, "/usr/bin/start-networking.sh");
+}
+
+char* hw_find_backup_file(const char* output, const char* search_path) {
+       char path[STRING_SIZE];
+
+       snprintf(path, sizeof(path), "%s/backup.ipf", search_path);
+       int r = access(path, R_OK);
+
+       if (r == 0)
+               return strdup(path);
+
+       return NULL;
+}
+
+int hw_restore_backup(const char* output, const char* backup_path, const char* destination) {
+       char command[STRING_SIZE];
+
+       snprintf(command, sizeof(command), "/bin/tar xzpf %s -C %s", backup_path, destination);
+       int rc = mysystem(output, command);
+
+       if (rc)
+               return -1;
+
+       return 0;
+}