Did everything come back after the reboot?

jstatus shows in one glance whether every Bastille jail is up and whether the services inside it are running. It finds jails and services by itself, so there is nothing to configure.

calendar             UP   4/4 services
db                   UP   3/3 services
llama                STOPPED (boot=off)
mail                 WARN 8/9 services  KO: dovecot
minecraft-bedrock    UP   4/4 services
webmail              DOWN
Example output after a reboot. Grey means stopped on purpose; red means a jail that should be running is not.

Reading the output

How it works

  1. jstatus lists jails with bastille list jail and checks each one with jls. A jail that is not running shows as STOPPED when its settings.conf says boot="off", and as DOWN otherwise.
  2. In a running jail, a single jexec runs service -e to list the enabled rc scripts. It skips scripts marked nojail, as rc does inside a jail, and scripts that do not describe a daemon (no command=, pidfile= or procname=), such as motd or cleartmp.
  3. It then runs status on each remaining script and trusts its exit code: 0 is OK, anything else is KO. The text of the output is ignored on purpose, because custom scripts, like a game server wrapped in tmux, do not use the standard "is running as pid" message.

Install

git clone https://github.com/Creep29257/jstatus.git
install -m 755 jstatus/jstatus /usr/local/sbin/jstatus

Run it as root, since it uses jls and jexec.

Usage

jstatus              # every jail known to Bastille
jstatus mail db      # only these jails
jstatus && echo "all good"

The exit status is 0 when everything is fine, 1 when a jail is DOWN or a service is KO, and 2 when jstatus is not run as root. Colors turn off when the output is not a terminal, or when NO_COLOR is set.

Configuration

Everything is optional.

VariableDefaultPurpose
JSTATUS_IGNOREnewsyslogrc scripts to skip, separated by spaces
JSTATUS_BASTILLE_CONF/usr/local/etc/bastille/bastille.confBastille configuration file
JSTATUS_JAILSDIRread from bastille.confBastille jails directory
NO_COLORunsetTurns colors off

newsyslog is ignored by default. Its script declares command= but is not a daemon, so "not running" is its normal state.

Known limitations

BSD 2-Clause license. Written by Remi Assailly, developed and used on FreeBSD 14.5 with Bastille.

← assailly.com

Powered by FreeBSD