#!/bin/bash
#Script to login to Netware server
#mounts home directory under ~/H
#Written 26/08/2004 onwards copyright Andrew Stringer

#set up variables
LOGINSERVER=server
CONTEXT=.context
TREE=tree
VOLUME=.volume.tree

#define functions

#generate desktop icon, $1 is the name of the desktop icon, it must end with
#.novell.desktop as on logout icons are destroyed which match this name ending,
#$2 is the mount point under $HOME/ where the icon points to, also this is the 
#icon name which appears on the desktop.
generate_icon()
{
cat <<EOF >$HOME/Desktop/$1.novell.desktop
[Desktop Entry]
Encoding=UTF-8
GenericName=$2
Icon=/opt/kde/share/icons/novell-folder-32.png
Name=$1:
Name[en_US]=$1:
Type=Link
URL=$HOME/$1/
EOF
}


#1st login to Netware
/usr/local/bin/ncplogin -A $LOGINSERVER -S $LOGINSERVER -U $USER$CONTEXT

#map H drive to ~/H if logged in OK.
if [ $? -eq 0 ]; then
/usr/local/bin/ncpmap -A $LOGINSERVER -T $TREE -V $VOLUME -R users/andrew H &&
#squirt out desktop icon
generate_icon H "Personal files on Server"



else
#if login is unsucessful, exit with status 1
exit 1
fi

echo ""
#show ncpfs mounts
echo "********* Current Connections *********"
mount |grep ncpfs
echo "***************************************"
echo""

exit 0


