#!/bin/sh -eu

SRCDIR=$1
DSTDIR=$2

INSTALLDIR="install -m 755 -d"
INSTALLFILE="install -m 644"

# Create destination directories
$INSTALLDIR $DSTDIR ;\
find $SRCDIR -type d -printf "%P\n" | while read DIR
do
	$INSTALLDIR "$DSTDIR/$DIR"
done

# Scan source files and install them
find $SRCDIR -type f -name "*.grm*" -printf "%P\n" | while read FILE
do
	$INSTALLFILE "$SRCDIR/$FILE" "$DSTDIR/$FILE"
done

exit 0
