installer: Make restoring the backup interactive
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 15 Oct 2014 21:38:05 +0000 (23:38 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 15 Oct 2014 21:38:05 +0000 (23:38 +0200)
config/syslinux/unattended.conf [deleted file]
lfs/cdrom
src/installer/hw.c
src/installer/hw.h
src/installer/main.c
src/scripts/backupiso

diff --git a/config/syslinux/unattended.conf b/config/syslinux/unattended.conf
deleted file mode 100644 (file)
index 169463b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-DOMAINNAME=localdomain
-HOSTNAME=ipfire
-KEYMAP=/lib/kbd/keymaps/i386/qwerty/us.map.gz
-LANGUAGE=en
-TIMEZONE=/usr/share/zoneinfo/posix/Europe/Berlin
-THEME=ipfire
-GREEN_ADDRESS=192.168.0.1
-GREEN_NETMASK=255.255.255.0
-GREEN_NETADDRESS=192.168.0.0
-GREEN_BROADCAST=192.168.0.255
-ROOT_PASSWORD=ipfire
-ADMIN_PASSWORD=ipfire
index 7a569a0..79920b8 100644 (file)
--- a/lfs/cdrom
+++ b/lfs/cdrom
@@ -86,10 +86,6 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        cp $(DIR_SRC)/doc/COPYING                               /install/cdrom/
        cp $(DIR_SRC)/doc/{ChangeLog,packages-list.txt} /install/cdrom/doc
 
-       # Configuration
-       mkdir -p /install/cdrom/boot
-       cp $(DIR_SRC)/config/syslinux/unattended.conf    /install/cdrom/boot/unattended.conf
-
        # Make the ISO
        mkdir -p /install/cdrom/boot/isolinux
        dd if=/dev/zero  bs=1k count=2            > /install/cdrom/boot/isolinux/boot.catalog
index 4e65a8b..9b9a2d0 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;
+}
index c5285d5..41ff093 100644 (file)
@@ -128,6 +128,9 @@ int hw_stop_all_raid_arrays(const char* output);
 int hw_install_bootloader(struct hw_destination* dest, const char* output);
 int hw_write_fstab(struct hw_destination* dest);
 
+char* hw_find_backup_file(const char* output, const char* search_path);
+int hw_restore_backup(const char* output, const char* backup_path, const char* destination);
+
 void hw_sync();
 
 #endif /* HEADER_HW_H */
index ba50cd9..36f8dfe 100644 (file)
@@ -722,11 +722,24 @@ int main(int argc, char *argv[]) {
        mysystem(logfile, "/usr/bin/touch /harddisk/var/ipfire/main/gpl_accepted");
 
        /* Copy restore file from cdrom */
-       if (unattended && (strlen(restore_file) > 0)) {
-               fprintf(flog, "unattended: Copy restore file\n");
-               snprintf(commandstring, STRING_SIZE, 
-                       "cp /cdrom/%s /harddisk/var/ipfire/backup", restore_file);
-               mysystem(logfile, commandstring);
+       char* backup_file = hw_find_backup_file(logfile, SOURCE_MOUNT_PATH);
+       if (backup_file) {
+               rc = 0;
+               if (!unattended) {
+                       rc = newtWinOkCancel(title, _("A backup file has been found on the installation image.\n\n"
+                               "Do you want to restore the backup?"), 50, 10, _("Yes"), _("No"));
+               }
+
+               if (rc == 0) {
+                       rc = hw_restore_backup(logfile, backup_file, DESTINATION_MOUNT_PATH);
+
+                       if (rc) {
+                               errorbox(_("An error occured when the backup file was restored."));
+                               goto EXIT;
+                       }
+               }
+
+               free(backup_file);
        }
 
        // Umount the destination drive
index a340d6f..fb203bd 100644 (file)
@@ -53,8 +53,8 @@ cp -pr backupiso.tmp.${TS} backupiso.${TS}
 umount backupiso.tmp.${TS}
 rm -r backupiso.tmp.${TS}
 
-echo "RESTORE_FILE=${TS}.ipf" >> backupiso.${TS}/boot/unattended.conf
-cp /var/ipfire/backup/${TS}.ipf backupiso.${TS}
+# Copy backup file to disk
+cp "/var/ipfire/backup/${TS}.ipf" "backupiso.${TS}/backup.ipf"
 
 echo "Running mkisofs"
 mkisofs -J -r -V "ipfire backup ${TS}" \