Shell bastille - a script to easily create and update jails

Yesterday I put the source code online for a simple utility, Bastille, which facilitates the creation and management of jails that share the same system components. In that sense, it's similar to ezjail, but that's actually all Bastille does. Bastille does not provide its own service, relying instead on FreeBSD's builtin jail service to start jails at boot time, nor does it attempt to manage ZFS datasets, or disk images. Bastille only works with the official binary system components as released by the FreeBSD project.

There were two reasons for writing Bastille: 1) I wanted to get myself acquainted with shell scripting and 2) I wanted to keep my jail definitions in /etc/jail.conf, rather than the now deprecated jail_* variables.

As this is my first shell script, I may not be following best practices everywhere. Despite my best efforts, I could even have made a silly mistake (or two).

Feedback is valued of course. Source code and documentation are available on github: www.github.com/dajero/bastille.

The following lines show how to prepare Bastille for use, create a jail and start it, and open a root console:
Code:
# bastille prepare
# bastille create-jail -n my-first-jail
# jail -c my-first-jail
# jexec my-first-jail /bin/sh
The first command fetches the system components for the host's FreeBSD release version (a different version may be specified via the -r option).

By default Bastille places all files needed for its operation under /usr/local/bastille and jail definitions are written to /etc/jail.conf. These defaults may be changed using the -b and -c options respectively. Any option may anywhere on the command line, allowing you to configure Bastille via aliases, e.g.:
Code:
alias bastille='bastille -b /bastille'

To have your jails start at boot time, add the following line to your rc.conf
Code:
jail_enable=YES

You can control which jails are started via the jail_list option in rc.conf.
 
Back
Top