#!/bin/sh
#
# $Revision: 1.17 $, $Date: 2003/09/08 10:03:41 $
#

[ -f /etc/pldconf/ustawienia ] && . /etc/pldconf/ustawienia
export PLDCONF_VERSION
export PLDCONF_EDITOR
#this is for vfjuggle instead of /cdrom, can it ever bother?
export VF_MNTPOINT=/mnt/cdrom 
export VF_EJECT=eject

if [ ! -x /usr/bin/less ]
then 
	echo 'Musisz zainstalowa less jeeli chcesz przeglda pomoc pldconf'
	echo 'W Dodaj/Usu programy zaznacz sekcj "Informacje o systemie"'
	echo 'Jeeli drani Ci ten komunikat usu go z /usr/bin/pldconf'
	echo '<enter>'
	read
fi

gui_func()
{
	if [ `id -nu` = root ]
	then
		eval `dml -t "    _p_l_d_c_o_n_f $PLDCONF_VERSION"<< EOF
		<meta title="pldconf" width=28> 
		<br>
		<menu id=res_menu res=1 height=13> 
		<item id=ustawienia> Ustawienia pldconf
		<item id=poldek> Dodaj/Usu programy
		<item id=X> rodowisko graficzne
		<item id=net> Sie 
		<item id=win> Partycje Windows
		<item id=boot> Uruchamianie systemu
		<item id=device> Urzdzenia
		<item id=inne> Inne 
		<item id=sysinfo> Informacje o systemie
		<item id=pld_install> Instalacja PLD
		<item id=pomoc> Pomoc
		<item id=autorzy> Autorzy
		<item id=exit> Wyjcie
		</menu>
EOF`

		case $res_menu in 
			ustawienia)
			exec /usr/share/pldconf/ustawienia.sh
			;;
			poldek)
			exec /usr/share/pldconf/poldek.sh
			;;
			X)
			exec /usr/share/pldconf/X/X_menu.sh
			;;
			net)
			exec /usr/share/pldconf/NET/net_menu.sh 
			;;
			win)
			exec /usr/share/pldconf/win.pl
			;;
			boot)
			exec /usr/share/pldconf/BOOT/boot_menu.sh
			;;
			device)
			exec /usr/share/pldconf/DEVICE/device_menu.sh
			;;
			inne)
			exec /usr/share/pldconf/inne.sh
			;;
			sysinfo)
			exec /usr/share/pldconf/SYSINFO/sysinfo_menu.sh
			;;
			pld_install)
			exec /usr/share/pldconf/install_pld.sh
			;;
			pomoc)
			less /usr/share/pldconf/POMOC/README_pomoc.txt
			exec /usr/bin/pldconf
			;;
			autorzy)
			exec /usr/share/pldconf/autorzy.sh
			;;
			exit)
			exit
			;;
		esac
	else 
		exec /usr/share/pldconf/menu_user.sh
	fi
}

print_help()
{
	clear
	cat << EOF
Dozwolone opcje:
-X   -Konfiguracja X;
-d   -Konfiguracja desktopu;
-H   -Konfiguracja urzdze;
-i   -Dodaj/Usu programy;
-n   -Konfiguracja sieci;
-b   -Konfiguracja menedera startu;
-D   -Instalacja PLD;
-I   -Inne;
-v   -Wersja;
-h   -Opis opcji;

EOF
}

getopts "XdHinbDIvh" opt && shift
case $opt in
	X) exec /usr/share/pldconf/X/X.pl $@;;
	d) exec /usr/share/pldconf/X/desktop.sh $@;;
	H) exec /usr/share/pldconf/DEVICE/device_menu.sh $@;;
	i) exec /usr/share/pldconf/poldek.sh $@;;
	n) exec /usr/share/pldconf/NET/net_menu.sh $@;;
	b) exec /usr/share/pldconf/BOOT/boot_manager.pl $@;;
	D) exec /usr/share/pldconf/install_pld.sh $@;;
	I) exec /usr/share/pldconf/inne.sh $@;;
	h) print_help;;
	v) echo pldconf $PLDCONF_VERSION;;
	?) gui_func;;
esac
