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

if ! checkPlatformFunction SYNO_FEA_MCELOG; then
	SkipThisProject
	return
fi

SYSTEMD_DIR=/usr/lib/systemd/system
TARGET_WANTS=basic.target.wants

make install DESTDIR=${TmpInstDir}
rm -rf $TmpInstDir/usr/share

# install syslog config
mkdir -p ${TmpInstDir}/etc/syslog-ng/patterndb.d
install -c -v -m 644 syno/mcelog.conf.syslog ${TmpInstDir}/etc/syslog-ng/patterndb.d/mcelog.conf
mkdir -p ${TmpInstDir}/etc/logrotate.d
install -c -v -m 644 syno/mcelog.conf.logrotate ${TmpInstDir}/etc/logrotate.d/mcelog

# install systemd service
mkdir -p ${TmpInstDir}/${SYSTEMD_DIR}
mkdir -p ${TmpInstDir}/${SYSTEMD_DIR}/${TARGET_WANTS}
install -c -v -m 644 syno/mcelog.service ${TmpInstDir}/${SYSTEMD_DIR}/mcelog.service

# link systemd wants
ln -s ../mcelog.service ${TmpInstDir}/${SYSTEMD_DIR}/${TARGET_WANTS}/mcelog.service

if [ "x$NOSTRIP" != "xNOSTRIP" ]; then
	${STRIP} ${TmpInstDir}/usr/sbin/mcelog
fi

