#!/bin/sh
##############################################################################
#
#  Copyright (c) 2005, Doremi Labs, Inc.
#    All rights reserved.
#
#  Redistribution in source or binary forms, with or without
#  modification, are NOT permitted.
#
#    Doremi Labs, Inc.
#    1020 Chestnut St.
#    Burbank, CA 91506
#    Tel : (818) 562 1101
#    Fax : (818) 562 1109
#
##############################################################################

. $(dirname $0)/../common.sh

FILE_LIST="/etc/hosts
/etc/resolv.conf
/var/resolv.conf
/etc/network/interfaces
/var/etc/network/run/ifstate
/var/etc/network/ifstate"

PERM_LIST="/etc/hosts[root:root]
/etc/resolv.conf[root:root]
/var/resolv.conf[root:root]
/etc/network/interfaces[root:root]
/var/etc/network/run/ifstate[root:root]
/var/etc/network/ifstate[root:root]"

do_backup ()
{
  if [ -e /etc/hosts ]; then
    safe_backup $FILE_LIST
  fi
  debconf-get-selections | grep '^etherconf' > ${BASE_FOLDER}/dcp2000_network_debconf.txt
}

do_restore ()
{
  safe_restore $FILE_LIST
  if test -e "${BASE_FOLDER}/dcp2000_network_debconf.txt"; then
    debconf-set-selections "${BASE_FOLDER}/dcp2000_network_debconf.txt"
  fi
}

case "$1" in
  backup)
    do_backup
    ;;
    
  restore)
    do_restore
    ;;
    
  *)
    echo "Usage: $0 [backup] [restore]"
    exit -1
    ;;
esac

exit 0
