initramfs: restore configuration if available

The error case of the backup not properly restoring has not
been tested.

Fixes: SYS#525
This commit is contained in:
Henning Heinold 2014-08-26 19:57:53 +02:00 committed by Holger Hans Peter Freyther
parent a3a743ecb2
commit 7a09426da5
1 changed files with 21 additions and 0 deletions

View File

@ -200,7 +200,28 @@ umount /tgt_root
echo "Resizing partition"
e2fsck -f $rootfs || true
resize2fs $rootfs
sync
echo "Re-mounting the root and trying to apply backup."
mount $rootfs /tgt_root
echo "Finding backupfiles"
backupfile=`find /media/$dev_name/ -name "sysmocom-backup*.tar" | head -n1`
if [ -n "$backupfile" ]; then
if [ ! -r "$backupfile" ]; then
echo "configurations-file $backupfile it is not readable"
else
echo "restoring $backupfile"
backupfile_basename=`basename $backupfile`
cp $backupfile /tgt_root
chroot /tgt_root /usr/sbin/sysmocom-restore $backupfile_basename
rm /tgt_root/$backupfile_basename
fi
else
echo "No configurations-file found"
fi
umount /tgt_root
sync
echo "Remove your installation media, and press ENTER"