installer: Make restoring the backup interactive

This commit is contained in:
Michael Tremer
2014-10-15 23:38:05 +02:00
parent 35853bb47b
commit 38c6822d3c
6 changed files with 47 additions and 23 deletions

View File

@@ -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

View File

@@ -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

View 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;
}

View 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 */

View 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

View 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}" \