#!/bin/bash

# This is a script for mounting novell disks from servers at
# Department of Control Engeneering.

# Configuration is stored in ~/.novell, where `~' is a home direcotry
# of the user running the script. If you don't use sudo it is root's
# home as this script have to be executed with root priviledges.

# Configuration file should look like this:
#   NOVELLUSER=sojkam1
#   NOVELLPASS=...
#   LOCALUSER=sojka
#   LOCALGROUP=users
#   MNTNOVELL=/mnt/novell/novell
#   MNTCONTROL=/mnt/novell/control


# If you want to run this scipt as an ordinary user, your /etc/sudoers
# file should contain a line similar to the folowing one:

# sojka   ALL=NOPASSWD: /usr/local/bin/novell

# Then, you can mount Novell disks by running `sudo novell' if you are
# logged as `sojka'.

# It should look like this:
#   NOVELLUSER=sojkam1
#   NOVELLPASS=...
#   LOCALUSER=sojka
#   LOCALGROUP=users
#   MNTNOVELL=/mnt/novell/novell
#   MNTCONTROL=/mnt/novell/control

source ~/.novell

mkdir -p $MNTNOVELL
mkdir -p $MNTCONTROL

ncpmount -S control -A control.felk.cvut.cz -U $NOVELLUSER -P $NOVELLPASS -g $LOCALGROUP -u $LOCALUSER -f 644 -d 755 $MNTCONTROL -y utf8 -p cp852 \
    || echo "Error mounting control"
ncpmount -S novell -A novell.felk.cvut.cz -U $NOVELLUSER.control.felk.cvut.cz -P $NOVELLPASS -u $LOCALUSER -g $LOCALGROUP -f 644 -d 755 $MNTNOVELL -y utf8 -p cp852 \
    || echo "Error mounting novell"
