evobackup/lib/bkctld-status
Victor LABORIE 842e57ba53 Big refactoring
* Jails are created on start and run in tmpfs
* All config files are on /etc/bkctld
* Cleaning of sshd_config and /etc/group
2020-01-08 14:46:18 +01:00

26 lines
804 B
Bash
Executable file

#!/bin/sh
#
# Print status of <jailname> (default all jail)
# Usage: status [<jailname>]
#
LIBDIR="$(dirname $0)" && . "${LIBDIR}/config"
jail="${1:-}"
if [ ! -n "${jail}" ]; then
"${LIBDIR}/bkctld-help" && exit 1
fi
[ -d "${CONFDIR}/${jail}" ] || error "${jail} : inexistant jail ! Use '$0 status' for list all"
inc="0"
if [ -f "${CONFDIR}/${jail}/inc.tpl" ]; then
day=$(grep -c "day" "${CONFDIR}/${jail}/inc.tpl")
month=$(grep -c "month" "${CONFDIR}/${jail}/inc.tpl")
inc="${day}/${month}"
fi
status="OFF"
"${LIBDIR}/bkctld-is-on" "${jail}" && status="ON "
port=$("${LIBDIR}/bkctld-port" "${jail}")
ip=$("${LIBDIR}/bkctld-ip" "${jail}"|xargs|tr -s ' ' ',')
echo "${jail} ${status} ${port} ${inc} ${ip}" | awk '{ printf("%- 30s %- 10s %- 10s %- 10s %- 40s\n", $1, $2, $3, $4, $5); }'