#================================================================================ # hevsMount.bash - Mounts the HES-SO//Vs SAMBA (CIFS) shares # # Requirements # - SAMBA package: # sudo apt-get install cifs-utils smbclient samba # - must be run as root # sudo hevsMount.bash MOUNT_POINTS=( '/mnt/i_si' '/mnt/p_pcb' '/mnt/r_public' '/mnt/u_home') HEVS_SHARES=( '//datahei.hevs.ch/HEI' '//datasion.hevs.ch/Pcb' '//datasion.hevs.ch/share/public' '//datasion.hevs.ch/home/Users/') #mountShare //nwedata/share ~/share_s/ SEPARATOR='--------------------------------------------------------------------------------' INDENT=' ' #------------------------------------------------------------------------------- # Functions # function createMountPoint () { local mountPoint=$1 if [ ! -d "$mountPoint" ]; then mkdir $mountPoint fi } function mountShare () { local share=$1 ; local mountPoint=$2 mount -t cifs $share $mountPoint \ -o uid=$Linux_user -o gid=$Linux_group \ -o username=$Novell_user -o password=$password \ -o noserverinfo -o rw -o file_mode=0777 -o dir-mode=0777 } #-------------------------------------------------------------------------------- # Parse command line options # usage='Usage: HEVsMount.bash [-v] [-h]' usage="$usage\n\t[-n NovellUserName] [-u userName] [-g groupName] [-p password]" Linux_user="$USER" Linux_group="$Linux_user" while getopts "n:u:g:p:vh" options; do case $options in n ) Novell_user=$OPTARG;; u ) Linux_user=$OPTARG;; g ) Linux_group=$OPTARG;; p ) password=$OPTARG;; v ) verbose=1;; h ) echo -e $usage exit 1;; * ) echo -e $usage exit 1;; esac done HEVS_SHARES[${#HEVS_SHARES[@]}-1]="${HEVS_SHARES[${#HEVS_SHARES[@]}-1]}$Novell_user" #================================================================================ # Main script # if [ -n "$verbose" ] ; then echo "$SEPARATOR" echo 'Mounting HES-SO//Vs Novell network disks...' fi #-------------------------------------------------------------------------------- # Get password # if [ -z "$password" ] ; then echo -n "Novell Password: " stty -echo read password stty echo echo # force a carriage return after the read fi #-------------------------------------------------------------------------------- # Create mount points # if [ -n "$verbose" ] ; then echo echo "Creating mount points:" fi for mount_point in ${MOUNT_POINTS[@]} ; do if [ -n "$verbose" ] ; then echo "${INDENT}Mount point $mount_point" fi createMountPoint $mount_point done #-------------------------------------------------------------------------------- # Mount shares # if [ -n "$verbose" ] ; then echo echo "Mounting shares:" fi for ((index=0; index<${#MOUNT_POINTS[@]}; index+=1)) ; do if [ -n "$verbose" ] ; then echo "${INDENT}Mounting ${HEVS_SHARES[$index]} on ${MOUNT_POINTS[$index]}" fi mountShare ${HEVS_SHARES[$index]} ${MOUNT_POINTS[$index]} done if [ -n "$verbose" ] ; then echo echo 'Finished mounting.' echo "$SEPARATOR" echo fi