File ncpfs-ipxmount of Package ncpfs

#! /bin/sh
# Copyright (c) 2001 Dr. Ing. Dieter Jurzitza, Germany.
#
# Author:  Dr. Ing. Dieter Jurzitza
#
# Revision History:
# 5.07.2002 insert the apropriate Codepage-Setting to display Umlauts in Filenames
# 19.11.2002 insert an option for both TCP and IPX-mounts
# 12.12.2002 remove a bug when parsing the password-file
#
#
# /etc/init.d/ipxmount
#
### BEGIN INIT INFO
# Provides: ipxmout
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Should-Start: radiusd  $syslog $named
# Should-Stop: $syslog
# Default-Start: 3 5
# Default-Stop:
# Description:  access to novell network via ipx
### END INIT INFO

. /etc/rc.status

test -f /etc/novellpasswd || {
echo "ipxmount not yet configured, missing /etc/novellpasswd"
echo "please read documentation in /usr/share/doc/packages/ncpfs"
rc_failed
exit 6

}

. /etc/sysconfig/ncpfs

#
# The next line ought to be handled with care ...
#
NVPASSWD=`grep -v "#" /etc/novellpasswd`

#
# Test wether the user exists at all
#
NVEXIST=`grep "$NVLXUSER" /etc/passwd`

#
# and default to root if not ...
#
if [ -z "$NVLXUSER" -o -z "$NVEXIST" ]; then
	NVLXUSER=root
fi

#
# ... then we need a string to specify how to mount the tree ...
#
NVOPTS=`grep ^$NVLXUSER: /etc/passwd |\
sed "s/:/:::/2; s/^.*:::/-c $NVLXUSER -u /; s/:/ -g /; s/:/:::/; s/:::.*$//"`

#
# ... then we have to add the codepage+iocharset to see all files containing 
#
if [ ! -z "$NVCODEPAGE" ] ; then
NVOPTS="$NVOPTS -p $NVCODEPAGE"
fi
if [ ! -z "$NVIOCHARSET" ] ; then
NVOPTS="$NVOPTS -y $NVIOCHARSET"
fi
NVOPTS="$NVOPTS $NVUSEROPTS"

rc_reset
case "$1" in
	start)
		echo -n "Starting Netware interconnection - $NVPROTOCOL"
		if [ "$NVPROTOCOL" != "TCP" ]; then
			/sbin/modprobe ipx 2>/dev/null
		fi
		/sbin/modprobe ncpfs 2>/dev/null
		if [ "$NVPROTOCOL" != "TCP" ]; then
			/usr/bin/ipx_configure --auto_primary=ON --auto_interface=off 2>/dev/null
			/usr/bin/ipx_interface add -p $NVNETDEVICE $NVFRAMETYPE 2>/dev/null
		fi
		/bin/sleep 1 # some delay is required 

		if [ "$NVPROTOCOL" != "TCP" ]; then
			/usr/bin/ncpmount -S $NVSERVER -U $NVUSER -P $NVPASSWD $NVOPTS $NVLOCATION 2> /dev/null
		else
			/usr/bin/ncpmount -S $NVSERVER -A $NVSERVER -U $NVUSER -P $NVPASSWD $NVOPTS $NVLOCATION 2> /dev/null
		fi
		rc_status -v
	;;
	stop)
		echo -n "Stopping Netware interconnection"
		/usr/bin/ncpumount $NVLOCATION 2> /dev/null
		if [ "$NVPROTOCOL" != "TCP" ]; then
			/usr/bin/ipx_interface delall
		fi
		rc_status -v
	;;
	restart)
	        $0 stop
		$0 start

		# Remember status and be quiet
		rc_status
	;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
	;;
esac
rc_exit
openSUSE Build Service is sponsored by