X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=src%2Finstaller%2Fhw.c;h=9b9a2d00291ae7b6911bd5eb10848e7c31c444a9;hp=4e65a8b7a03b59a3568ecedca577ba17120cead4;hb=38c6822d3c99104978975352bcfe80fb13a94c72;hpb=35853bb47bc3a8dea8591979aa4d23a78c255f60 diff --git a/src/installer/hw.c b/src/installer/hw.c index 4e65a8b7a0..9b9a2d0029 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -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; +}