#!/bin/sh

# Copy the prman shader into the dirs in RMSTREE, RMANTREE and RATTREE
paths="$RMSTREE $RMANTREE $RATTREE"

for dir in ${paths//:/ }; do
    targetDir="${dir}/lib/shaders"

    if [ -d ${targetDir} -a -w ${targetDir} ]; then
        cp /Users/Shared/Autodesk/maya/2018/plug-ins/prman/shaders/Shave.slo ${targetDir}
    fi
done

# We used to keep libShave.dylib and libShaveAPI.dylib in Maya's shared
# directory but had to move them to Maya's install directory to allow
# everything to be relocated by the user. So get rid of those libs if they are
# still lying around in the shared directory.
#
# We need to do the same thing in our current target directory in case it
# is something other than Maya's shared directory.
#
libs="/Users/Shared/Autodesk/maya/2018/plug-ins/libShave.dylib /Users/Shared/Autodesk/maya/2018/plug-ins/libShaveAPI.dylib $2/plug-ins/libShave.dylib $2/plug-ins/libShaveAPI.dylib"

for f in ${libs}; do
	if [ -f $f ]; then
		rm -f $f
	fi
done
