
# Script program Realised by MARTINEZ SYLVAIN
# 25/01/1996
# martinez@iutserveur.univ-lyon1.fr
 

if [ ! -d /archives/config ]; then
mkdirhier /archives/config
fi

while [ 0 ]; do

 dialog --title "NETWORK CONFIGURATION with LINUX" --menu "\n\
		Iut informatique de LYON    (FRANCE)
             V1.0 create by MARTINEZ Sylvain (25/01/1996) \n\n\
             Actual Config: '`cat /root/config/config_actu`'\n" 21 74 9 \
"DISPLAY" "Display all the config available" \
"LOAD" "Load a new config" \
"SAVE" "Save the actual config" \
"ERASE" "Erase a configuration (WARNING !)" \
"CREATE" "Create/Modify an information file for a config" \
"INFOS" "Informations on a config" \
"BACKUP" "Saved on drive A" \
"RESTORE" "BACKUP'S LOAD (WARNING !)" \
"EXIT" "QUIT this menu" 2> /tmp/choix_config

 if [ $? = 1 -o $? = 255 ]; then
  rm -f /tmp/choix_config
  reset
  exit
 fi

 MAINSELECT="`cat /tmp/choix_config`"

 rm /tmp/choix_config


 if [ "$MAINSELECT" = "DISPLAY" ]; then
    affiche
 fi
 
 if [ "$MAINSELECT" = "LOAD" ]; then
    charger
 fi


 if [ "$MAINSELECT" = "SAVE" ]; then
       dialog --title "	SAVE THE ACTUAL CONFIGURATION " \
--inputbox "
         Write the name of the config to save" 10 60 2>/tmp/choix_config
       dialog --yesno "	  DO YOU REALLY WANT TO SAVE THE CONFIG \n\
         NAMED '`cat /tmp/choix_config`' ?" 6 60

     if [ $? != 1 ]; then
	NOM=`cat /tmp/choix_config`
	mkdir /archives/config/$NOM
     if [ $? != 1 ]; then 
	cd /archives/config/$NOM
	/root/config/files
        echo $NOM > /root/config/config_actu
     fi
       
      fi
 fi

 if [ "$MAINSELECT" = "ERASE" ]; then
	effacer
 fi

 if [ "$MAINSELECT" = "CREATE" ]; then
	creer
 fi

 if [ "$MAINSELECT" = "INFOS" ]; then
	information
 fi

 if [ "$MAINSELECT" = "BACKUP" ]; then
	backup
 fi

 if [ "$MAINSELECT" = "RESTORE" ]; then
	load
 fi

  if [ "$MAINSELECT" = "EXIT" ]; then
   rm -f /tmp/choix_config 2>/dev/null
   reset
   break
  fi
done 
clear
