#!/bin/ash
# $Id: load-config,v 1.1 2001/10/13 11:52:40 malekith Exp $

test ! -f /etc/profile || . /etc/profile

PATH=$PATH:. . installer-functions

info () {
  if test -x /bin/dml ; then
    dml "$1<br><button>" > /dev/null
  else
    echo "$1"
  fi
}


if mount -t vfat /dev/fd0 /mnt ; then
  case "$0" in
    *save* )
      if tar c \
      	/etc/installer.conf \
    	/etc/installer.pkgs \
    	/etc/installer.sysconf | gzip > /mnt/config.tgz ; then
        info "$(nls "Config succesfully saved to file %s." config.tgz)"
      else
        info "$(nls "Writing to diskette problems, sorry.")"
      fi
      ;;
    *load* )
      if [ -r /mnt/config.tgz ] ; then
        cd /
        if zcat /mnt/config.tgz | tar xf - ; then
          info "$(nls "Config succesfully loaded.")"
	else
	  info "$(nls "Problems unpacking archive.")"
	fi
      else
        info "$(nls "There is no config on diskette.")"
      fi
      ;;
    * )
      info "Called as $0. Don't know what to do."
      ;;
   esac
   umount /mnt
else
  info "$(nls "Cannot mount diskette. Make sure it is in drive.")"
fi
