#!/bin/sh # # Print status of (default all jail) # Usage: status [] # # shellcheck source=./includes LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes" jail_name="${1:?}" if [ ! -n "${jail_name}" ]; then "${LIBDIR}/bkctld-help" && exit 1 fi [ -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" if [ -r "${incs_policy_file}" ]; then days=$(grep "^\+" "${incs_policy_file}" | grep --count "day") months=$(grep "^\+" "${incs_policy_file}" | grep --count "month") incs_policy="${days}/${months}" fi status="OFF" "${LIBDIR}/bkctld-is-on" "${jail_name}" && status="ON " port=$("${LIBDIR}/bkctld-port" "${jail_name}") ip=$("${LIBDIR}/bkctld-ip" "${jail_name}" | xargs | tr -s ' ' ',') echo "${jail_name} ${status} ${port} ${incs_policy} ${ip}" | awk '{ printf("%- 30s %- 10s %- 10s %- 10s %- 40s\n", $1, $2, $3, $4, $5); }'