Commit af971e84 authored by Fabian Mauchle's avatar Fabian Mauchle

[FEATURE #190] Save old ssh host keys and authorized_keys during firmware upgrade

and restore to new firwmare.
parent 62b4fe8d
Pipeline #4900 failed with stage
in 7 seconds
......@@ -182,7 +182,25 @@ fi
# First: update usr: we may have the whole thing, or just wrs-usr.tar.gz
if [ -f /update/$WRS_FW -o -f /update/$WRS_USR ]; then
echo -n "Saving existing data..." | $TEE /dev/ttyGS0
# Mount /usr temporarily to transfer some existing files
mkdir -p /usr
mount -t ubifs ubi0:usr /usr
# save some old data to be reused with updated software
if ls /usr/etc/ssh/ssh_host_*_key* 1> /dev/null 2>&1; then
cp /usr/etc/ssh/ssh_host_*_key* /tmp/
fi
if [ -f /usr/authorized_keys ]; then
cp /usr/authorized_keys /tmp/
fi
# FIXME: save configuration somewhere, and recover it later
# Unmount /usr again so we can recreate the partition form the new firmware
sync; cd /; umount /usr
echo " done" | $TEE /dev/ttyGS0
echo -n "Extracting filesystem..." | $TEE /dev/ttyGS0
# since we are upgrading, we'd better remove and recreate the volume
ubirmvol /dev/ubi0 --name=usr
......@@ -195,6 +213,17 @@ if [ -f /update/$WRS_FW -o -f /update/$WRS_USR ]; then
else
tar xzf /update/$WRS_USR
fi
echo " done" | $TEE /dev/ttyGS0
# restore saved data
echo -n "Restoring saved data..." | $TEE /dev/ttyGS0
if ls /tmp/ssh_host_*_key* 1> /dev/null 2>&1; then
mv /tmp/ssh_host_*_key* /usr/etc/ssh/
fi
if [ -f /tmp/authorized_keys ]; then
mv /tmp/authorized_keys /usr/
fi
sync; cd /; umount /usr
echo " done" | $TEE /dev/ttyGS0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment