Skip to content
Snippets Groups Projects
mount_nfs.sh 1.22 KiB
MOUNT_CMD="mount -vv -t nfs4 -o rw,hard,nolock";
UNMOUNT_CMD="umount"
TEST_MOUNT_PATH="$CLUSTER_DATA_PATH/testmount";
PROD_MOUNT_PATH="$CLUSTER_DATA_PATH/prodmount";

mount_nfs() {
    echo "mounting";
    $MKDIR $TEST_MOUNT_PATH;
    $MKDIR $PROD_MOUNT_PATH;

    echo "mounting $TESTCLUSTER_DEVICE_IP to $TEST_MOUNT_PATH"
    $MOUNT_CMD $TESTCLUSTER_DEVICE_IP:/ $TEST_MOUNT_PATH;
    err_code=$?

    if [ $err_code != 0 ] && [ "$PROD" != "true" ]
    then
        echo "could not mount test nfs; cmd exited with code $err_code";
        exit -1;
    elif [ $err_code != 0 ] && [ "$PROD" = "true" ]
    then
        echo "could not mount test nfs, exited with code $err_code but PROD=$PROD, skipping";
    fi

    echo "mounting $PRODCLUSTER_DEVICE_IP to $PROD_MOUNT_PATH"
    $MOUNT_CMD $PRODCLUSTER_DEVICE_IP:/ $PROD_MOUNT_PATH;
    err_code=$?

    if [ $err_code != 0 ] && [ "$PROD" = "true" ]
    then
        echo "could not mount prod nfs; cmd exited with code $err_code";
        exit -1;
    elif [ $err_code != 0 ] && [ "$PROD" != "true" ]
    then
        echo "could not mount prod nfs, exited with code $err_code but PROD=$PROD, skipping";
    fi
}

unmount_nfs() {
    $UNMOUNT_CMD $TEST_MOUNT_PATH
    $UNMOUNT_CMD $PROD_MOUNT_PATH
}