mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
installer: Make restoring the backup interactive
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}" \
|
||||
|
||||
Reference in New Issue
Block a user