#!/usr/local/bin/cbsd
#v13.0.8
MYARG="jname"
MYOPTARG=""
MYDESC="praudit(1) warpper: print the contents of audit trail files"
CBSDMODULE="jail"
ADDHELP="
${H3_COLOR}Description${N0_COLOR}:


${H3_COLOR}Options${N0_COLOR}:

 ${N2_COLOR}cbsdfile${N0_COLOR}              - alternative path to CBSDfile, could be relative to the

${H3_COLOR}Examples${N0_COLOR}:

 # cbsd auditd

${H3_COLOR}See also${N0_COLOR}:

 cbsd up --help
 cbsd forms --help

"

. ${subrdir}/nc.subr
. ${system}
. ${cbsdinit}

export OPATH="${PATH}"
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
PRAUDIT_CMD=$( which praudit )
export PATH="${OPATH}"

[ ! -x "${PRAUDIT_CMD}" ] && err 1 "${N1_COLOR}${CIX_APP} error: no such executable: ${N2_COLOR}praudit${N2_COLOR}"

. ${subrdir}/rcconf.subr

case ${baserw} in
	0)
		${PRAUDIT_CMD} /dev/auditpipe | ${GREP_CMD} ^path | ${GREP_CMD} "${cbsd_workdir}/jails/${jname}/" | ${GREP_CMD} -v "/dev/" | ${SED_CMD} "s:path,${cbsd_workdir}/jails/${jname}::g"
		;;
	1)
		${PRAUDIT_CMD} /dev/auditpipe | ${GREP_CMD} ^path | ${GREP_CMD} "${cbsd_workdir}/jails-data/${jname}-data/" | ${GREP_CMD} -v "/dev/" | ${SED_CMD} "s:path,${cbsd_workdir}/jails-data/${jname}-data::g"
		;;
esac

#| grep -v /dev | grep {jname}
# | grep -v jails-system | grep -v ftmp

exit 0
