#!/bin/sh
# This script handles '2 Vendor Log File' of Download RPC
# Vendors can replace this file if they need to collect more logs

VENDOR_LOG_FILE="/tmp/icwmp/2_vendor_log"
ret=""

if [ -n "$(which logread)" ]; then
	mkdir -p /tmp/icwmp

	logread > "${VENDOR_LOG_FILE}"

	arch_file="${VENDOR_LOG_FILE}.tar"

	if [ -f "${arch_file}" ]; then
		rm -f ${arch_file}
	fi

	if [ -f "${VENDOR_LOG_FILE}" ]; then
		tar -cf "${arch_file}" "${VENDOR_LOG_FILE}"  2> /dev/null
		if [ -f "${arch_file}" ]; then
			ret="${arch_file}"
		fi

		rm -rf "${VENDOR_LOG_FILE}"
	fi
fi

echo "${ret}"
