# migrate file to specify files and/or directories to copy
# from some other "var" to the new "var".
#
# Example entries:
#
#  Copy to a new dir:
#  "${PREVVARDIR}/etc/sysconfig/test       ${VARDIR}/etc/sysconfig/test"  \
#  New dir can have a different location:
#  "${PREVVARDIR}/etc/sysconfig/test       ${VARDIR}/etc/sysconfig/test2"  \
#  Copy the contents of an existing dir:
#  "${PREVVARDIR}/root/test                     ${VARDIR}/root"  \
#  Note that you have to remove the last dir entry to copy this way.
#
#  Not necessary to include the /etc/sysconfig/network directory.  That is
# handled separately.
#
#  Individual file may be specified as shown below.  Every entry except for the last 
# needs a trailing backslash (\).   See 'config.sh' script for similar example.


for LINE in \
  "${PREVVARDIR}/etc/sysconfig/network/routes    ${VARDIR}/etc/sysconfig/network/routes" \
  "${PREVVARDIR}/etc/sysconfig/features   ${VARDIR}/etc/sysconfig" \
  "${PREVVARDIR}/etc/ntp.conf             ${VARDIR}/etc/ntp.conf" \
  "${PREVVARDIR}/etc/syslog.conf          ${VARDIR}/etc/syslog.conf" \
  "${PREVVARDIR}/etc/HOSTNAME             ${VARDIR}/etc/HOSTNAME" \
  "${PREVVARDIR}/etc/TZ                   ${VARDIR}/etc/TZ" \
  "${PREVVARDIR}/etc/xinetd.d/ftp         ${VARDIR}/etc/xinetd.d/ftp" \
  "${PREVVARDIR}/etc/localtime            ${VARDIR}/etc/localtime" \
  "${PREVVARDIR}/etc/hosts                ${VARDIR}/etc/hosts" \
  "${PREVVARDIR}/etc/services             ${VARDIR}/etc/services" \
  "${PREVVARDIR}/var/local/lib/sysd       ${VARDIR}/var/local/lib" \
  "${PREVVARDIR}/var/local/lib/asimux     ${VARDIR}/var/local/lib" \
  "${PREVVARDIR}/root                     ${VARDIR}/" 
do
  do_copy "${LINE}"
done


### Section for fixing some of the migration  ###
# Some files have settings that need to migrate, but
# have other sections that are updated.
### consider putting this in a common file.
#  pure-ftp path
${RFSDIR}/bin/sed -i 's/usr\/sbin/usr\/local\/sbin/' ${VARDIR}/etc/xinetd.d/ftp
# add support for pure.db
PUREDB=$(${RFSDIR}/bin/grep -c pureftpd.pdb ${VARDIR}/etc/xinetd.d/ftp)
if [ $PUREDB -eq 0 ]; then  # not there, fix.
	${RFSDIR}/bin/sed -i 's/= -lunix/= -lpuredb:\/etc\/pureftpd.pdb -lunix/' ${VARDIR}/etc/xinetd.d/ftp
fi

sync