]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/installer/hw.c
installer: Make restoring the backup interactive
[ipfire-2.x.git] / src / installer / hw.c
index 4e65a8b7a03b59a3568ecedca577ba17120cead4..9b9a2d00291ae7b6911bd5eb10848e7c31c444a9 100644 (file)
@@ -1041,3 +1041,27 @@ void hw_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;
+}