evobackup/server/lib/bkctld-status

31 lines
1,015 B
Plaintext
Raw Normal View History

2019-01-04 13:51:05 +01:00
#!/bin/sh
#
# Description: Display status of SSH server
# Usage: [--no-header] status [<jailname>|all]
#
2019-01-04 13:51:05 +01:00
2020-04-02 13:44:13 +02:00
# shellcheck source=./includes
2020-04-02 00:31:57 +02:00
LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes"
2019-01-04 13:51:05 +01:00
2020-04-02 23:33:54 +02:00
jail_name="${1:?}"
if [ ! -n "${jail_name}" ]; then
show_help && exit 1
fi
2020-04-02 23:33:54 +02:00
[ -d "${JAILDIR}/${jail_name}" ] || error "${jail_name} : jail is missing.\nUse '$0 status [all]' to get the status of all jails."
2019-01-04 13:51:05 +01:00
2020-04-02 23:52:27 +02:00
incs_policy_file=$(current_jail_incs_policy_file ${jail_name})
2020-04-02 23:33:54 +02:00
incs_policy="0"
2020-04-02 23:52:27 +02:00
if [ -r "${incs_policy_file}" ]; then
days=$(grep "^\+" "${incs_policy_file}" | grep --count "day")
months=$(grep "^\+" "${incs_policy_file}" | grep --count "month")
2021-12-03 15:16:59 +01:00
incs_policy="${days}/${months}"
2019-01-07 16:12:51 +01:00
fi
2020-04-02 23:33:54 +02:00
status="OFF"
2020-04-02 23:33:54 +02:00
"${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 %- 25s %- 20s\n", $1, $2, $3, $4, $5); }'