#!/bin/sh
echo "Novell-Netzwerkankopplung wird vorbereitet!"

if [ -d "/etc/init.d" ]; then
	echo ""
	echo "SuSE >= 7.2 -> installation wird fortgesetzt!"
	echo ""
else
	echo "Falsche Version des Betriebssystems"
	exit 1
fi

if [ ! -e /etc/novellpasswd ]; then
	cp ./novellpasswd /etc/novellpasswd
	chown root.root /etc/novellpasswd
	chmod 0400 /etc/novellpasswd
else
	echo ""
	echo "/etc/novellpasswd existiert schon!"
fi
if [ ! -e "/etc/init.d/ipxmount" ]; then
	cp ./ipxmount /etc/init.d/ipxmount
	chown root.root /etc/init.d/ipxmount
	chmod 0744 /etc/init.d/ipxmount
else
	echo ""
	echo "/etc/init.d/ipxmount existiert schon!"
fi

cd /etc/init.d/rc5.d
if [ ! -L "/etc/init.d/rc5.d/K18ipxmount" ]; then
	ln -s ../ipxmount K18ipxmount
	ln -s ../ipxmount S09ipxmount
else
	echo ""
	echo "Symlinks in /etc/init.d/rc5.d existieren schon!"
fi

cd /etc/init.d/rc3.d
if [ ! -L "/etc/init.d/rc5.d/K18ipxmount" ]; then
	ln -s ../ipxmount K18ipxmount
	ln -s ../ipxmount S09ipxmount
else
	echo ""
	echo "Symlinks in /etc/init.d/rc3.d existiert schon!"
fi

TESTPERMS=`grep novellpasswd /etc/permissions.local`

if [ -z "$TESTPERMS" ]; then
	echo "/etc/novellpasswd            root.root       0400" >> /etc/permissions.local
else
	echo ""
	echo "Eintrag in $TEST in /etc/permissions.local existiert schon!"
fi

if [ ! -e /etc/rc.config.d/ipxmount.rc.config ]; then
	cp . ipxmount.rc.config /etc/rc.config.d
else
	echo ""
	echo "Datei /etc/rc.config.d/ipxmount.rc.config existiert schon!"
fi

echo ""
echo "Alles fertig! Jetzt muß noch das Novellpasswort in /etc/novellpasswd"
echo "eingetragen werden! In 7 s geht es weiter!"
sleep 7

if [ ! -z "$EDITOR" ]; then
	$EDITOR /etc/novellpasswd
else
	vi /etc/novellpasswd
fi

if [ -e "/etc/novellpasswd~" ]; then
	rm -f /etc/novellpasswd~
fi

echo ""
/sbin/SuSEconfig
echo ""
echo "Achtung, daß keine Backup-Datei /etc/novellpasswd* liegen bleibt!"
echo ""
echo "Dann: yast starten -> Administation des Systems ->"
echo "Konfigurationsdatei verändern -> NVFRAMETYPE, NVLOCATION"
echo "NVNETDEVICE, NVSERVER, NVUSER anpassen"
echo "Nach Aufruf von /etc/init.d/ipxmount start muß dann der Novell-"
echo "Server im NVLOCATION-Verzeichnis eingebunden sein!"
