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

TmpFolder="/source/bind-9.x/.bind9"
make install DESTDIR="$TmpFolder"

install -D -m755 ${TmpFolder}/bin/nslookup ${TmpInstDir}/bin/nslookup
install -D -m755 ${TmpFolder}/bin/nsupdate ${TmpInstDir}/bin/nsupdate

cp -a ${TmpFolder}/lib ${TmpInstDir}/lib
rm -f ${TmpInstDir}/lib/*.la
rm -rf ${TmpInstDir}/lib/named

if [[ -z "${NOSTRIP}" ]]; then
	while IFS= read -r -d '' file; do
		if [[ "$(file "${file}")" = *" ELF "*"not stripped"* ]]; then
			${STRIP} "${file}"
		fi
	done < <(find "${TmpInstDir}" -print0)
fi

exit 0

TarRoot="./.tarball"
PkgRoot=${TarRoot}/volume1/@named
ScriptRoot=${TarRoot}

rm -rf ${TarRoot}
rm -f ../bind-9.x.tgz

	mkdir ${TarRoot}
	install -d ${PkgRoot}/var/log
	install -d ${PkgRoot}/etc/conf
	install -d ${PkgRoot}/etc/default
	install -d ${PkgRoot}/etc/key
	install -d ${PkgRoot}/etc/zone/master
	install -d ${PkgRoot}/etc/zone/slave
	install -d ${PkgRoot}/dev
	install -d ${PkgRoot}/bin
	install -d ${PkgRoot}/var/run/named

	install -c -m755 bin/nsupdate/nsupdate ${PkgRoot}/bin/nsupdate
	install -c -m755 bin/dnssec/dnssec-keygen  ${PkgRoot}/bin/dnssec-keygen
	install -c -m755 bin/check/named-checkconf  ${PkgRoot}/bin/named-checkconf
	install -c -m755 bin/check/named-checkzone  ${PkgRoot}/bin/named-checkzone
	install -c -m755 bin/dig/dig  ${PkgRoot}/bin/dig
	install -c -m755 bin/named/named  ${PkgRoot}/bin/named
	install -c -m755 bin/rndc/rndc  ${PkgRoot}/bin/rndc
	chown -R nobody:nobody ${PkgRoot}

	cd ${TarRoot} ;	tar -zcvf ../bind-9.x.tgz *
	cd ../
rm -rf ${TarRoot}


