#!/bin/bash
# Copyright (c) 2000-2015 Synology Inc. All rights reserved.

if ! UsingPkgScripts && ! checkPlatformFunction SYNO_FEA_HYPER_CONVERGED; then
	SkipThisProject
	return
fi

make install DESTDIR="$TmpInstDir"

move_files()
{
	HAPKGPath="/var/packages/HighAvailability/target"

	mkdir -p "$TmpInstDir/usr"
	mv "$TmpInstDir/$HAPKGPath/bin" "$TmpInstDir/usr/bin"
	if UsingPkgScripts; then
		mv "$TmpInstDir/$HAPKGPath/etc" "$TmpInstDir/etc"
	fi
	rm -r "$TmpInstDir/var"

}
install_other_files()
{
	LSYNCD_ETC="$TmpInstDir/etc/lsyncd"
	[ -d $LSYNCD_ETC ] || install -d $LSYNCD_ETC
	install -c -m644 ./default.lua $TmpInstDir/etc/lsyncd/default.lua
}
strip_binary()
{
	[ "x$NOSTRIP" = "xNOSTRIP" ] && return

	BinDir="usr/bin"
	if [ -d "$TmpInstDir/$BinDir" ]; then
		find $TmpInstDir/$BinDir -type f | xargs $STRIP
	fi
}

move_files
install_other_files
strip_binary

