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
Get the code on GitHub →
Reading the output
- UP The jail is running and every daemon it enables is running.
- WARN The jail is running but some enabled daemons are not. They are listed after
KO:. - DOWN The jail has
boot="on"but is not running. - STOPPED The jail is not running and has
boot="off". Nothing to fix.
How it works
- jstatus lists jails with
bastille list jailand checks each one withjls. A jail that is not running shows as STOPPED when itssettings.confsaysboot="off", and as DOWN otherwise. - In a running jail, a single
jexecrunsservice -eto list the enabled rc scripts. It skips scripts markednojail, as rc does inside a jail, and scripts that do not describe a daemon (nocommand=,pidfile=orprocname=), such asmotdorcleartmp. - It then runs
statuson 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.
| Variable | Default | Purpose |
|---|---|---|
JSTATUS_IGNORE | newsyslog | rc scripts to skip, separated by spaces |
JSTATUS_BASTILLE_CONF | /usr/local/etc/bastille/bastille.conf | Bastille configuration file |
JSTATUS_JAILSDIR | read from bastille.conf | Bastille jails directory |
NO_COLOR | unset | Turns 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
- A real daemon whose rc script sets none of
command=,pidfile=orprocname=is treated as a one-shot and never reported. - Results are only as reliable as each script's
statusexit code. - jstatus checks processes, not listening ports: a running service can still fail to serve.
- Other one-shot scripts that set
command=, likenewsyslog, must be added toJSTATUS_IGNORE.
BSD 2-Clause license. Written by Remi Assailly, developed and used on FreeBSD 14.5 with Bastille.
