#!/bin/sh

mkdir -p /tmp/other
if [ -n "$(ls -al /dev/root | grep hda4)" ]; then
	SOURCE=hda4
	TARGET=hda2
else
	SOURCE=hda2
	TARGET=hda4
fi
echo "syncing configuration from source $SOURCE to $TARGET"
mount /dev/$TARGET /tmp/other
echo " copy /etc/config/network"
cp -f /etc/config/network /tmp/other/etc/config/network
echo " copy /etc/config/wireless"
cp -f /etc/config/wireless /tmp/other/etc/config/wireless
echo " copy /etc/passwd"
cp -f /etc/passwd /tmp/other/etc/passwd
echo " copying openssh host keys"
cp -f /etc/ssh/ssh_host_*_key* /tmp/other/etc/ssh/ 2>/dev/null
echo " copying dropbear ssh host keys"
cp -f /etc/dropbear/dropbear_*_host_key /tmp/other/etc/dropbear/ 2>/dev/null
echo "done"
sync
umount /dev/$TARGET
rmdir /tmp/other
