New jmore(8) FreeBSD Jails List/Manage Tool

[ NOTICE ]
Initially the tool name was jless(8) – but seschwar from https://lobste.rs/ page made me aware that there already is a jless project available – command line JSON viewer written in Rust – thank You for that. So … as less(8) is more(8) and more(8) is less(8) – I took the decision to rename it from jless(8) to jmore(8) to avoid confusion. The original article below have been modified to reflect that decision.

I have worked (and still work) with FreeBSD jail(8) containers for many years – mostly using Base System tools such as jls(8) or jexec(8) to manage them. They are quite OK – but then the world changed – VNET Jails were created … while tools remained the same – being practically blind when it comes to show important info about VNET Jails.

I could use very good and tested BastilleBSD framework instead – and I have used it in some places I was given to sysadmin – but there are places in which only so called plain FreeBSD Jails exist … and that fact gave enough reason for creating new jmore(8) listing/managing tool.

That jmore(8) helper tool is nothing big – without first 30 lines for the BSD license – its about 250 lines long … and its just an improved version of my previous jails.sh tool.

jmore

See the difference?

FreeBSD # jmore
JAIL       JID  TYPE  VER     DIR                    IFACE     IP(s)
----       ---  ----  ---     ---                    -----     -----
classic    5    std   13.2-R  /jail/classic          em0       10.0.0.199/32
fbsdjail   -    std   13.1-R  /jail/fbsdjail         wlan0     10.0.0.43
ctld-two   -    vnet  13.2-R  /jail/ctld-two         ${if}b    -
ctld       -    vnet  13.2-R  /jail/ctld             ${if}b    -
iscsi      -    vnet  13.2-R  /jail/iscsi            ${if}b    -
minecraft  -    std   -       [GONE]/jail/minecraft  em0       10.0.0.210
minio      -    std   14.0-R  /jail/minio            em0       10.0.0.133
nfsd       3    vnet  14.1-R  /jail/nfsd             epair99b  10.1.1.99/24
other      -    std   14.1-R  /jail/other            em0       10.0.0.199
sambajail  -    vnet  14.1-R  /jail/sambajail        ${if}b    -
unfs3      -    vnet  14.1-R  /jail/unfs3            ${if}b    -

Features

The jmore(8) adds following things to improve the situation:

  • Network interfaces.
  • IP addresses.
  • FreeBSD versions.
  • Type of Jail (standard or VNET).
  • Warning if Jail directory is [GONE].

Besides listing – the jmore(8) tool also allows simple operations like (re)start/stop or attaching to a jail(8) with jexec(8) console.

FreeBSD # jmore help
usage:
  jmore            list jail(8) containers
  jmore -a         list jail(8) containers with all IP(s)
  jmore -h         show help
  jmore --help     show help
  jmore help       show help
  jmore version    show version

manage:
  jmore <JAILNAME> start
  jmore <JAILNAME> restart
  jmore <JAILNAME> stop
  jmore <JAILNAME> status
  jmore <JAILNAME> console
  jmore <JAILNAME> shell
  jmore <JAILNAME> jexec

shorts:
  jmore <JAILNAME> u   UP ------> alias for start
  jmore <JAILNAME> d   DOWN ----> alias for stop
  jmore <JAILNAME> r   RESTART -> alias for restart
  jmore <JAILNAME> c   CONSOLE -> alias for console|shell|jexec
  jmore <JAILNAME> s   STATUS --> alias for status

I also added some ‘shorts’ that only require [UP] arrow and single letter change to do other thing … that I use the most.

Usually its like start a jail and then attach to it with jexec(8) command.

FreeBSD # jmore minecraft u
FreeBSD # jmore minecraft c
minecraft # // stuff to do inside //

… and also jmore(8) does no magic here – it just uses service(8) or jexec(8) and jls(8) commands to get most of that information.

Download

I already put it into GitHub here – https://github.com/vermaden/jmore – so You may test it for yourself.

If You just want to download it into your system and test it – jmore(8) – here is the script that can be downloaded with fetch(1) for example.

Summary

Feel free to share how jmore(8) works for your needs – or what is it still missing to make it even better.

Regards.

UPDATE 1 – Small Improvements

I found a new way to get FreeBSD Jail version without the need to use root permissions. I also added PS2 prompt variable override (as PS1 is already handled) as it was just ‘garbage’ when it was picked up from any modern ZSH or BASH config.

Updated jmore(8) version is available in the https://github.com/vermaden/jmore repo as usual.

EOF

2 thoughts on “New jmore(8) FreeBSD Jails List/Manage Tool

  1. Pingback: ๆ–ฐ Jless(8) FreeBSD ็›‘็‹ฑๅˆ—่กจ/็ฎก็†ๅทฅๅ…ท - ๅๆ‰ง็š„็ ๅ†œ

  2. Pingback: Valuable News – 2024/11/25 | ๐šŸ๐šŽ๐š›๐š–๐šŠ๐š๐šŽ๐š—

Leave a comment