improve incs policy parsing
This commit is contained in:
parent
492433133e
commit
c920e91304
|
@ -83,7 +83,7 @@ for jail_name in $(jails_list); do
|
||||||
trap "rm ${incs_policy_keep_file}" 0
|
trap "rm ${incs_policy_keep_file}" 0
|
||||||
|
|
||||||
# loop for each line in jail configuration
|
# loop for each line in jail configuration
|
||||||
for incs_policy_line in $(cat ${incs_policy_file} | grep "^\+"); do
|
for incs_policy_line in $(grep "^\+" ${incs_policy_file}); do
|
||||||
# inc date in ISO format
|
# inc date in ISO format
|
||||||
incs_policy_date=$(relative_date ${incs_policy_line})
|
incs_policy_date=$(relative_date ${incs_policy_line})
|
||||||
echo ${incs_policy_date} >> "${incs_policy_keep_file}"
|
echo ${incs_policy_date} >> "${incs_policy_keep_file}"
|
||||||
|
|
|
@ -34,13 +34,15 @@ trap "rm ${duc_output} ${incs_output} ${stat_output}" 0
|
||||||
awk '{ print $2 }' "${duc_output}" | while read jail_name; do
|
awk '{ print $2 }' "${duc_output}" | while read jail_name; do
|
||||||
jail_path=$(jail_path "${jail_name}")
|
jail_path=$(jail_path "${jail_name}")
|
||||||
stat --format=%Y "${jail_path}/var/log/lastlog" | xargs -i -n1 date -d "@{}" "+%d-%m-%Y" >> "${stat_output}"
|
stat --format=%Y "${jail_path}/var/log/lastlog" | xargs -i -n1 date -d "@{}" "+%d-%m-%Y" >> "${stat_output}"
|
||||||
inc=0
|
|
||||||
if [ -f "${CONFDIR}/${jail_name}" ]; then
|
incs_policy_file=$(current_jail_incs_policy_file ${jail_name})
|
||||||
day=$(grep -c "day" "${CONFDIR}/${jail_name}")
|
incs_policy="0"
|
||||||
month=$(grep -c "month" "${CONFDIR}/${jail_name}")
|
if [ -r "${incs_policy_file}" ]; then
|
||||||
inc="${day}/${month}"
|
days=$(grep "^\+" "${incs_policy_file}" | grep --count "day")
|
||||||
|
months=$(grep "^\+" "${incs_policy_file}" | grep --count "month")
|
||||||
|
incs_policy="${days}/${months}"
|
||||||
fi
|
fi
|
||||||
echo "${inc}" >> "${incs_output}"
|
echo "${incs_policy}" >> "${incs_output}"
|
||||||
done
|
done
|
||||||
|
|
||||||
paste "${duc_output}" "${incs_output}" "${stat_output}" | awk '{ printf("%- 30s %- 10s %- 10s %- 15s\n", $2, $1, $3, $4); }'
|
paste "${duc_output}" "${incs_output}" "${stat_output}" | awk '{ printf("%- 30s %- 10s %- 10s %- 15s\n", $2, $1, $3, $4); }'
|
||||||
|
|
|
@ -13,10 +13,11 @@ if [ ! -n "${jail_name}" ]; then
|
||||||
fi
|
fi
|
||||||
[ -d "${JAILDIR}/${jail_name}" ] || error "${jail_name} : jail is missing.\nUse '$0 status [all]' to get the status of all jails."
|
[ -d "${JAILDIR}/${jail_name}" ] || error "${jail_name} : jail is missing.\nUse '$0 status [all]' to get the status of all jails."
|
||||||
|
|
||||||
|
incs_policy_file=$(current_jail_incs_policy_file ${jail_name})
|
||||||
incs_policy="0"
|
incs_policy="0"
|
||||||
if [ -f "${CONFDIR}/${jail_name}" ]; then
|
if [ -r "${incs_policy_file}" ]; then
|
||||||
days=$(grep -c "day" "${CONFDIR}/${jail_name}")
|
days=$(grep "^\+" "${incs_policy_file}" | grep --count "day")
|
||||||
months=$(grep -c "month" "${CONFDIR}/${jail_name}")
|
months=$(grep "^\+" "${incs_policy_file}" | grep --count "month")
|
||||||
incs_policy="${days}/${months}"
|
incs_policy="${days}/${months}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue