#!/bin/sh

# ============================
# Copy Uninstaller and Readme
# ============================
Model=StudioCapture

UninstName=Uninstaller.app
ReadmeDir=Readme
ReadmeName=Readme.htm

if (test -d "$1") ; then
	SrcDir="$1/.."
else
	SrcDir=`dirname "$1"`
fi

DstRoot="/Applications/Roland"
DstDir="$DstRoot"/"STUDIO-CAPTURE Driver"

if (! test -d "$DstRoot") ; then
	mkdir "$DstRoot"
	chmod ug=rw,o=r,+X "$DstRoot"
	chown 0:80 "$DstRoot"
fi

if (! test -d "$DstDir") ; then
	mkdir "$DstDir"
fi

##### Copy Uninstaller #####
if (test -d "$SrcDir"/"$UninstName") ; then
	ditto "$SrcDir"/"$UninstName" "$DstDir"/"$UninstName"
fi

##### Copy Readme #####
if (test -f "$SrcDir"/"$ReadmeName") ; then
	if (test -d "$SrcDir"/"$ReadmeDir") ; then
		cp "$SrcDir"/"$ReadmeName" "$DstDir"
		cp -R "$SrcDir"/"$ReadmeDir" "$DstDir"
	fi
fi

##### Set Permission #####
find "$DstDir" -type d -exec chmod ug=rw,o=r,+X {} \;
find "$DstDir" -type f -exec chmod ug=rw,o=r,+X {} \;

find "$DstDir" -type d -exec chown 0:80 {} \;
find "$DstDir" -type f -exec chown 0:80 {} \;
find "$DstDir" -type l -exec chown -h 0:80 {} \;

# ============================

touch /System/Library/Extensions/
touch /Library/PreferencePanes/

exit 0
