#!/bin/bash
################################################################################
#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
################################################################################

export PATH=$PATH:.
if [ $# -lt 3 ]; then
    echo usage: $0 host rootpasswd nfsserver 
    exit 1
fi

HOSTADDR=$1
ROOTPASSWD=$2
NFSSERVER=$3

echo unmounting shared drive for $HOSTADDR...
pssh root@$HOSTADDR -o StrictHostKeyChecking=no -o password=$ROOTPASSWD "umount /thor; umount /mnt/lib; umount /mnt/usrlib; umount /mnt/bin; umount /mnt/usr/bin"

echo mounting directories /thor, /mnt/lib, /mnt/usr/lib ...
pssh root@$HOSTADDR -o StrictHostKeyChecking=no -o password=$ROOTPASSWD "mkdir /thor; mount $NFSSERVER:/thor /thor -o hard,intr; mkdir /mnt/lib; mount $NFSSERVER:/lib /mnt/lib -o hard,intr; mkdir /mnt/usrlib; mount $NFSSERVER:/usr/lib /mnt/usrlib -o hard,intr; mkdir /mnt/bin; mount $NFSSERVER:/bin /mnt/bin -o hard,intr; mkdir /mnt/usrbin; mount $NFSSERVER:/usr/bin /mnt/usrbin -o hard,intr;"

