Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b30a7484bb | ||
|
|
b05493bc8e | ||
|
|
97a0e692d9 | ||
|
|
3df39078bf | ||
|
|
620ad465d6 | ||
|
|
d44c85637e | ||
|
|
c2b17f346d | ||
|
|
94656350a1 | ||
|
|
d0ff97057e | ||
|
|
dc6e755c2b | ||
|
|
c8b3fb3bc1 | ||
|
|
8906e491d0 | ||
|
|
51f9003016 | ||
|
|
2de0766b54 | ||
|
|
ace7bdce2f | ||
|
|
9e71332876 | ||
|
|
2b6eb3c9f4 | ||
|
|
a38403b028 | ||
|
|
8c04f1d110 | ||
|
|
157125c4af | ||
|
|
b7d741b5cd | ||
|
|
df00a7939e | ||
|
|
49f6402a00 | ||
|
|
cf928f1237 | ||
|
|
11367238ec | ||
|
|
78c77b7e26 | ||
|
|
bf98acd330 | ||
|
|
01ee385384 | ||
|
|
22b3c3cd69 | ||
|
|
3ac2921559 | ||
|
|
0354baa6d5 | ||
|
|
445b42ed39 | ||
|
|
00d5c97f64 | ||
|
|
4ea6f00077 | ||
|
|
10fe9df412 | ||
|
|
440b24371b | ||
|
|
8b38497cb1 | ||
|
|
b0ba336d7e | ||
|
|
fe31dbdca8 | ||
|
|
4bebca9a69 | ||
|
|
864d8d03f5 | ||
|
|
ca2b75e8c0 | ||
|
|
b76df46cd1 | ||
|
|
b60bc10537 |
@@ -3,5 +3,7 @@ version: 2
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
|
||||
python:
|
||||
version: 3.11
|
||||
build:
|
||||
os: "ubuntu-22.04"
|
||||
tools:
|
||||
python: "3.11"
|
||||
|
||||
20
README.md
20
README.md
@@ -30,9 +30,22 @@ make install
|
||||
**enable at boot**
|
||||
```shell
|
||||
sysrc bastille_enable=YES
|
||||
sysrc bastille_list="azkaban alcatraz" # (optional whitelist of jails to start at boot; default: ALL)
|
||||
sysrc bastille_rcorder=YES
|
||||
```
|
||||
|
||||
Upgrading from a previous version
|
||||
---------------------------------
|
||||
When upgrading from a previous version of bastille (e.g. 0.10.20230714 to
|
||||
0.10.20231013) you will need to update your bastille.conf
|
||||
|
||||
```shell
|
||||
cd /usr/local/etc/bastille
|
||||
diff -u bastille.conf bastille.conf.sample
|
||||
```
|
||||
|
||||
Merge the lines that are present in the new bastille.conf.sample into
|
||||
your bastille.conf
|
||||
|
||||
Basic Usage
|
||||
-----------
|
||||
```shell
|
||||
@@ -62,6 +75,7 @@ Available Commands:
|
||||
mount Mount a volume inside the targeted container(s).
|
||||
pkg Manipulate binary packages within targeted container(s). See pkg(8).
|
||||
rdr Redirect host port to container port.
|
||||
rcp reverse cp(1) files from a single container to the host.
|
||||
rename Rename a container.
|
||||
restart Restart a running container.
|
||||
service Manage services within targeted container(s).
|
||||
@@ -118,7 +132,7 @@ Example (create, start, console)
|
||||
This example creates, starts and consoles into the container.
|
||||
|
||||
```shell
|
||||
ishmael ~ # bastille create alcatraz 13.2-RELEASE 10.17.89.10
|
||||
ishmael ~ # bastille create alcatraz 14.0-RELEASE 10.17.89.10/24
|
||||
```
|
||||
|
||||
```shell
|
||||
@@ -130,7 +144,7 @@ alcatraz: created
|
||||
```shell
|
||||
ishmael ~ # bastille console alcatraz
|
||||
[alcatraz]:
|
||||
FreeBSD 13.2-RELEASE-p4 GENERIC
|
||||
FreeBSD 14.0-RELEASE GENERIC
|
||||
|
||||
Welcome to FreeBSD!
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Bastille is available in the official FreeBSD ports tree at
|
||||
`sysutils/bastille`. Binary packages available in `quarterly` and `latest`
|
||||
repositories.
|
||||
|
||||
Current version is `0.10.20231013`.
|
||||
Current version is `0.10.20231125`.
|
||||
|
||||
To install from the FreeBSD package repository:
|
||||
|
||||
@@ -19,6 +19,7 @@ PKG
|
||||
|
||||
pkg install bastille
|
||||
sysrc bastille_enable=YES
|
||||
sysrc bastille_rcorder=YES
|
||||
|
||||
|
||||
To install from source (don't worry, no compiling):
|
||||
@@ -30,6 +31,7 @@ ports
|
||||
|
||||
make -C /usr/ports/sysutils/bastille install clean
|
||||
sysrc bastille_enable=YES
|
||||
sysrc bastille_rcorder=YES
|
||||
|
||||
|
||||
GIT
|
||||
@@ -41,6 +43,7 @@ GIT
|
||||
cd bastille
|
||||
make install
|
||||
sysrc bastille_enable=YES
|
||||
sysrc bastille_rcorder=YES
|
||||
|
||||
This method will install the latest files from GitHub directly onto your
|
||||
system. It is verbose about the files it installs (for later removal), and also
|
||||
|
||||
36
docs/chapters/migration.rst
Normal file
36
docs/chapters/migration.rst
Normal file
@@ -0,0 +1,36 @@
|
||||
Stop the running jail and export it:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
iocage stop jailname
|
||||
iocage export jailname
|
||||
|
||||
Move the backup files (.zip and .sha256) into Bastille backup dir (default: /usr/local/bastille/backups/):
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
mv /iocage/images/jailname_$(date +%F).* /usr/local/bastille/backups/
|
||||
|
||||
for remote systems you could use rsync:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
rsync -avh /iocage/images/jailname_$(date +%F).* root@10.0.1.10:/usr/local/bastille/backups/
|
||||
|
||||
|
||||
Import the iocage backup file (use zip file name)
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
bastille import jailname_$(date +%F).zip
|
||||
|
||||
Set your new ip address and interface:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
vim /usr/local/bastille/jails/jailname/jail.conf
|
||||
interface = bastille0;
|
||||
ip4.addr = "192.168.0.1";
|
||||
|
||||
|
||||
You can use you primary network interface instead of the virtual bastille0 interface as well if you know what you’re doing.
|
||||
@@ -128,6 +128,11 @@ host system:
|
||||
## /etc/devfs.rules (NOT .conf)
|
||||
|
||||
[bastille_vnet=13]
|
||||
add include $devfsrules_hide_all
|
||||
add include $devfsrules_unhide_basic
|
||||
add include $devfsrules_unhide_login
|
||||
add include $devfsrules_jail
|
||||
add include $devfsrules_jail_vnet
|
||||
add path 'bpf*' unhide
|
||||
|
||||
Lastly, you may want to consider these three `sysctl` values:
|
||||
@@ -138,6 +143,23 @@ Lastly, you may want to consider these three `sysctl` values:
|
||||
net.link.bridge.pfil_onlyip=0
|
||||
net.link.bridge.pfil_member=0
|
||||
|
||||
Below is the definition of what these three parameters are used for and mean:
|
||||
|
||||
|
||||
net.link.bridge.pfil_onlyip Controls the handling of non-IP packets
|
||||
which are not passed to pfil(9). Set to 1
|
||||
to only allow IP packets to pass (subject
|
||||
to firewall rules), set to 0 to uncondi-
|
||||
tionally pass all non-IP Ethernet frames.
|
||||
|
||||
net.link.bridge.pfil_member Set to 1 to enable filtering on the incom-
|
||||
ing and outgoing member interfaces, set to
|
||||
0 to disable it.
|
||||
|
||||
net.link.bridge.pfil_bridge Set to 1 to enable filtering on the bridge
|
||||
interface, set to 0 to disable it.
|
||||
|
||||
|
||||
**Regarding Routes**
|
||||
|
||||
Bastille will attempt to auto-detect the default route from the host system and
|
||||
|
||||
@@ -27,7 +27,7 @@ release version as the argument.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
ishmael ~ # bastille bootstrap 12.4-RELEASE [update]
|
||||
ishmael ~ # bastille bootstrap 14.0-RELEASE [update]
|
||||
ishmael ~ # bastille bootstrap 13.2-RELEASE [update]
|
||||
|
||||
To `bootstrap` a HardenedBSD release, run the bootstrap sub-command with the
|
||||
@@ -43,6 +43,21 @@ download the requested release. For each requested release, `bootstrap` will
|
||||
download the base.txz. These files are verified (sha256 via MANIFEST file)
|
||||
before they are extracted for use.
|
||||
|
||||
EOL Releases
|
||||
------------
|
||||
|
||||
It is sometimes necessary to run end-of-life releases for testing or legacy
|
||||
application support. Dy default Bastille will only install supported releases
|
||||
but you can bootstrap EOL / unsupported releases with a simple trick.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
ishmael ~ # export BASTILLE_URL_FREEBSD=http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/
|
||||
ishmael ~ # bastille bootstrap 11.2-RELEASE
|
||||
|
||||
By overriding the BASTILLE_URL_FREEBSD variable you can now bootstrap archived
|
||||
releases from the FTP archive.
|
||||
|
||||
Tips
|
||||
----
|
||||
|
||||
|
||||
@@ -40,3 +40,13 @@ ranges include:
|
||||
|
||||
Bastille does its best to validate the submitted ip is valid. This has not been
|
||||
thouroughly tested--I generally use the 10/8 range.
|
||||
|
||||
A couple of notes about the created jails. First, MOTD has been disabled inside
|
||||
of the jails because it does not give information about the jail, but about the host
|
||||
system. This caused confusion for some users, so we implemented the .hushlogin which
|
||||
silences the MOTD at login.
|
||||
|
||||
Also, uname does not work from within a jail. Much like MOTD, it gives you the version
|
||||
information about the host system instead of the jail. If you need to check the version
|
||||
of freebsd running on the jail use the freebsd-version command to get accurate information.
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ use, be sure to include `usr` in the template OVERLAY definition. eg;
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
echo "CP usr" >> /usr/local/bastille/templates/username/template/Bastillefile
|
||||
echo "CP usr /" >> /usr/local/bastille/templates/username/template/Bastillefile
|
||||
|
||||
The above example "usr" will include anything under "usr" inside the template.
|
||||
You do not need to list individual files. Just include the top-level directory
|
||||
@@ -140,3 +140,36 @@ directory names in the `bastille/templates` directory.
|
||||
Template Complete.
|
||||
|
||||
.. _Bastille Templates: https://gitlab.com/BastilleBSD-Templates
|
||||
|
||||
Using Ports in Templates
|
||||
------------------------
|
||||
|
||||
Sometimes when you make a template you need special options for a package, or you need a newer version than what is in the pkgs. The solution for these cases, or a case like minecraft server that has NO compiled option, is to use the ports. A working example of this is the minecraft server template in the template repo. The main lines needed to use this is first to mount the ports directory, then compile the port. Below is an example of the minecraft template where this was used.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
ARG MINECRAFT_MEMX="1024M"
|
||||
ARG MINECRAFT_MEMS="1024M"
|
||||
ARG MINECRAFT_ARGS=""
|
||||
CONFIG set enforce_statfs=1;
|
||||
CONFIG set allow.mount.fdescfs;
|
||||
CONFIG set allow.mount.procfs;
|
||||
RESTART
|
||||
PKG dialog4ports tmux openjdk17
|
||||
MOUNT /usr/ports usr/ports nullfs ro 0 0
|
||||
CP etc /
|
||||
CP var /
|
||||
CMD make -C /usr/ports/games/minecraft-server install clean
|
||||
CP usr /
|
||||
SYSRC minecraft_enable=YES
|
||||
SYSRC minecraft_memx=${MINECRAFT_MEMX}
|
||||
SYSRC minecraft_mems=${MINECRAFT_MEMS}
|
||||
SYSRC minecraft_args=${MINECRAFT_ARGS}
|
||||
SERVICE minecraft restart
|
||||
RDR tcp 25565 25565
|
||||
|
||||
The MOUNT line mounts the ports directory, then the CMD make line makes the port. This can be modified to use any port in the port tree.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -35,5 +35,7 @@ Old Releases
|
||||
----------------------------------
|
||||
After upgrading all jails from one release to the next you may find that you now have bootstrapped a release that is no longer used. Once you've decided that you no longer need the option to revert the change you can destroy the old release.
|
||||
|
||||
|
||||
`bastille list releases` to list all bootstrapped releases.
|
||||
`bastille destroy X.Y-RELEASE` to fully delete the release.
|
||||
|
||||
`bastille destroy X.Y-RELEASE` to fully delete the release.
|
||||
|
||||
12
docs/conf.py
12
docs/conf.py
@@ -12,9 +12,9 @@ copyright = '2018-2023, Christer Edwards'
|
||||
author = 'Christer Edwards'
|
||||
|
||||
# The short X.Y version
|
||||
version = '0.10.20231013'
|
||||
version = '0.10.20231125'
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '0.10.20231013-beta'
|
||||
release = '0.10.20231125-beta'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
@@ -26,10 +26,10 @@ templates_path = ['_templates']
|
||||
|
||||
source_suffix = ['.rst', '.md']
|
||||
|
||||
from recommonmark.parser import CommonMarkParser
|
||||
source_parsers = {
|
||||
'.md': CommonMarkParser,
|
||||
}
|
||||
#from recommonmark.parser import CommonMarkParser
|
||||
#source_parsers = {
|
||||
# '.md': CommonMarkParser,
|
||||
#}
|
||||
|
||||
master_doc = 'index'
|
||||
language = None
|
||||
|
||||
@@ -16,11 +16,13 @@ https://docs.bastillebsd.org.
|
||||
chapters/networking
|
||||
chapters/usage
|
||||
chapters/targeting
|
||||
chapters/upgrading
|
||||
chapters/subcommands/index
|
||||
chapters/template
|
||||
chapters/jail-config
|
||||
chapters/zfs-support
|
||||
chapters/gcp
|
||||
chapters/migration
|
||||
|
||||
copyright
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ bastille_perms_check() {
|
||||
bastille_perms_check
|
||||
|
||||
## version
|
||||
BASTILLE_VERSION="0.10.20231013"
|
||||
BASTILLE_VERSION="0.10.20231125"
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
@@ -91,6 +91,7 @@ Available Commands:
|
||||
list List containers (running and stopped).
|
||||
mount Mount a volume inside the targeted container(s).
|
||||
pkg Manipulate binary packages within targeted container(s). See pkg(8).
|
||||
rcp reverse cp(1) files from a single container to the host.
|
||||
rdr Redirect host port to container port.
|
||||
rename Rename a container.
|
||||
restart Restart a running container.
|
||||
@@ -149,7 +150,7 @@ help|-h|--help)
|
||||
bootstrap|create|destroy|export|import|list|rdr|restart|setup|start|update|upgrade|verify)
|
||||
# Nothing "extra" to do for these commands. -- cwells
|
||||
;;
|
||||
clone|config|cmd|console|convert|cp|edit|htop|limits|mount|pkg|rename|service|stop|sysrc|tags|template|top|umount|zfs)
|
||||
clone|config|cmd|console|convert|cp|edit|htop|limits|mount|pkg|rcp|rename|service|stop|sysrc|tags|template|top|umount|zfs)
|
||||
# Parse the target and ensure it exists. -- cwells
|
||||
if [ $# -eq 0 ]; then # No target was given, so show the command's help. -- cwells
|
||||
PARAMS='help'
|
||||
|
||||
@@ -8,10 +8,19 @@
|
||||
|
||||
# Add the following to /etc/rc.conf[.local] to enable this service
|
||||
#
|
||||
# bastille_enable (bool): Set to NO by default.
|
||||
# Set it to YES to enable bastille.
|
||||
# bastille_list (string): Set to "ALL" by default.
|
||||
# Space separated list of jails to start.
|
||||
# bastille_enable (bool): Set to "NO" by default.
|
||||
# Set it to "YES" to enable bastille.
|
||||
# bastille_conf (bool): Set to "/usr/local/etc/bastille/bastille.conf" by default.
|
||||
# Path to bastile.conf file. Used if bastille_rcorder="YES".
|
||||
# bastille_list (string): Set to "ALL" by default.
|
||||
# Space separated list of jails to start or "ALL" to start all
|
||||
# jails.
|
||||
# bastille_rcorder (bool): Set to "NO" by default.
|
||||
# Set it to "YES" to start all jails in order, defined by
|
||||
# rcorder(8). It starts all jails, except jails with "KEYWORD:
|
||||
# nostart" in jail.conf. Value of bastille_list is ignored in this
|
||||
# case, requires correct path to bastile.conf in bastille_conf
|
||||
# var.
|
||||
#
|
||||
|
||||
. /etc/rc.subr
|
||||
@@ -19,24 +28,36 @@
|
||||
name=bastille
|
||||
rcvar=${name}_enable
|
||||
|
||||
: ${bastille_enable:=NO}
|
||||
: ${bastille_enable:="NO"}
|
||||
: ${bastille_conf:="/usr/local/etc/bastille/bastille.conf"}
|
||||
: ${bastille_list:="ALL"}
|
||||
: ${bastille_rcorder:="NO"}
|
||||
|
||||
command=/usr/local/bin/${name}
|
||||
start_cmd="bastille_start"
|
||||
stop_cmd="bastille_stop"
|
||||
restart_cmd="bastille_stop && bastille_start"
|
||||
|
||||
rcordered_list() {
|
||||
local _jailsdir
|
||||
_jailsdir=$(. $bastille_conf; echo $bastille_jailsdir)
|
||||
bastille_ordered_list=$(rcorder -s nostart ${_jailsdir}/*/jail.conf | xargs dirname | xargs basename | tr "\n" " ")
|
||||
}
|
||||
|
||||
bastille_start()
|
||||
{
|
||||
if [ -z "${bastille_list}" ]; then
|
||||
echo "bastille_list is undefined"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local _jail
|
||||
|
||||
for _jail in ${bastille_list}; do
|
||||
if checkyesno bastille_rcorder; then
|
||||
rcordered_list
|
||||
elif [ -z "${bastille_list}" ]; then
|
||||
echo "bastille_list is undefined"
|
||||
return 1
|
||||
else
|
||||
bastille_ordered_list=${bastille_list}
|
||||
fi
|
||||
|
||||
for _jail in ${bastille_ordered_list}; do
|
||||
echo "Starting Bastille Container: ${_jail}"
|
||||
${command} start ${_jail}
|
||||
done
|
||||
@@ -44,16 +65,20 @@ bastille_start()
|
||||
|
||||
bastille_stop()
|
||||
{
|
||||
if [ -z "${bastille_list}" ]; then
|
||||
local _jail _revlist
|
||||
|
||||
if checkyesno bastille_rcorder; then
|
||||
rcordered_list
|
||||
elif [ -z "${bastille_list}" ]; then
|
||||
echo "bastille_list is undefined"
|
||||
return 1
|
||||
else
|
||||
bastille_ordered_list=${bastille_list}
|
||||
fi
|
||||
|
||||
local _jail
|
||||
|
||||
## reverse order of list for shutdown ## fixes #389
|
||||
bastille_revlist=$(echo "${bastille_list}" | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }')
|
||||
for _jail in ${bastille_revlist}; do
|
||||
_revlist=$(echo "${bastille_ordered_list}" | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }')
|
||||
for _jail in ${_revlist}; do
|
||||
echo "Stopping Bastille Container: ${_jail}"
|
||||
${command} stop ${_jail}
|
||||
done
|
||||
|
||||
@@ -473,6 +473,11 @@ if [ -n "${OPTION}" ] && [ "${OPTION}" != "${HW_MACHINE}" ] && [ "${OPTION}" !=
|
||||
fi
|
||||
fi
|
||||
|
||||
## allow override bootstrap URLs via environment variables
|
||||
[ -n "${BASTILLE_URL_FREEBSD}" ] && bastille_url_freebsd="${BASTILLE_URL_FREEBSD}"
|
||||
[ -n "${BASTILLE_URL_HARDENEDBSD}" ] && bastille_url_hardenedbsd="${BASTILLE_URL_HARDENEDBSD}"
|
||||
[ -n "${BASTILLE_URL_MIDNIGHTBSD}" ] && bastille_url_midnightbsd="${BASTILLE_URL_MIDNIGHTBSD}"
|
||||
|
||||
## Filter sane release names
|
||||
case "${1}" in
|
||||
2.[0-9]*)
|
||||
@@ -489,9 +494,9 @@ case "${1}" in
|
||||
PLATFORM_OS="FreeBSD"
|
||||
validate_release_url
|
||||
;;
|
||||
*-RELEASE|*-release|*-RC1|*-rc1|*-RC2|*-rc2|*-RC3|*-rc3|*-RC4|*-rc4|*-RC5|*-rc5|*-BETA1|*-BETA2|*-BETA3|*-BETA4|*-BETA5)
|
||||
*-RELEASE|*-release|*-RC[1-9]|*-rc[1-9]|*-BETA[1-9])
|
||||
## check for FreeBSD releases name
|
||||
NAME_VERIFY=$(echo "${RELEASE}" | grep -iwE '^([1-9]{2,2})\.[0-9](-RELEASE|-RC[1-5]|-BETA[1-5])$' | tr '[:lower:]' '[:upper:]')
|
||||
NAME_VERIFY=$(echo "${RELEASE}" | grep -iwE '^([0-9]{1,2})\.[0-9](-RELEASE|-RC[1-9]|-BETA[1-9])$' | tr '[:lower:]' '[:upper:]')
|
||||
UPSTREAM_URL="${bastille_url_freebsd}${HW_MACHINE}/${HW_MACHINE_ARCH}/${NAME_VERIFY}"
|
||||
PLATFORM_OS="FreeBSD"
|
||||
validate_release_url
|
||||
|
||||
@@ -136,7 +136,7 @@ update_fstab() {
|
||||
# Update fstab to use the new name
|
||||
FSTAB_CONFIG="${bastille_jailsdir}/${NEWNAME}/fstab"
|
||||
if [ -f "${FSTAB_CONFIG}" ]; then
|
||||
FSTAB_RELEASE=$(grep -owE '([1-9]{2,2})\.[0-9](-RELEASE|-RELEASE-i386|-RC[1-5]|-BETA[1-5]|-CURRENT)|([0-9]{1,2}(-stable-build-[0-9]{1,3}|-stable-LAST))|(current-build)-([0-9]{1,3})|(current-BUILD-LATEST)|([0-9]{1,2}-stable-BUILD-LATEST)' "${FSTAB_CONFIG}" | uniq)
|
||||
FSTAB_RELEASE=$(grep -owE '([1-9]{2,2})\.[0-9](-RELEASE|-RELEASE-i386|-RC[1-9]|-BETA[1-9]|-CURRENT)|([0-9]{1,2}(-stable-build-[0-9]{1,3}|-stable-LAST))|(current-build)-([0-9]{1,3})|(current-BUILD-LATEST)|([0-9]{1,2}-stable-BUILD-LATEST)' "${FSTAB_CONFIG}" | uniq)
|
||||
FSTAB_CURRENT=$(grep -w ".*/releases/.*/jails/${TARGET}/root/.bastille" "${FSTAB_CONFIG}")
|
||||
FSTAB_NEWCONF="${bastille_releasesdir}/${FSTAB_RELEASE} ${bastille_jailsdir}/${NEWNAME}/root/.bastille nullfs ro 0 0"
|
||||
if [ -n "${FSTAB_CURRENT}" ] && [ -n "${FSTAB_NEWCONF}" ]; then
|
||||
|
||||
@@ -178,6 +178,7 @@ ${NAME} {
|
||||
mount.fstab = ${bastille_jail_fstab};
|
||||
path = ${bastille_jail_path};
|
||||
securelevel = 2;
|
||||
osrelease = ${RELEASE};
|
||||
|
||||
interface = ${bastille_jail_conf_interface};
|
||||
${IP4_DEFINITION}
|
||||
@@ -225,6 +226,7 @@ ${NAME} {
|
||||
mount.fstab = ${bastille_jail_fstab};
|
||||
path = ${bastille_jail_path};
|
||||
securelevel = 2;
|
||||
osrelease = ${RELEASE};
|
||||
|
||||
${NETBLOCK}
|
||||
}
|
||||
@@ -499,7 +501,7 @@ create_jail() {
|
||||
if [ -n "${VNET_JAIL}" ]; then
|
||||
if [ -n "${bastille_template_vnet}" ]; then
|
||||
## rename interface to generic vnet0
|
||||
uniq_epair=$(grep vnet.interface "${bastille_jailsdir}/${NAME}/jail.conf" | awk '{print $3}' | sed 's/;//')
|
||||
uniq_epair=$(grep vnet.interface "${bastille_jailsdir}/${NAME}/jail.conf" | awk '{print $3}' | sed 's/;//; s/-/_/g')
|
||||
|
||||
_gateway=''
|
||||
_gateway6=''
|
||||
@@ -605,36 +607,80 @@ LINUX_JAIL=""
|
||||
# Handle and parse options
|
||||
while [ $# -gt 0 ]; do
|
||||
case "${1}" in
|
||||
-E|--empty|empty)
|
||||
-E|--empty)
|
||||
EMPTY_JAIL="1"
|
||||
shift
|
||||
;;
|
||||
-L|--linux|linux)
|
||||
-L|--linux)
|
||||
LINUX_JAIL="1"
|
||||
shift
|
||||
;;
|
||||
-T|--thick|thick)
|
||||
-T|--thick)
|
||||
THICK_JAIL="1"
|
||||
shift
|
||||
;;
|
||||
-V|--vnet|vnet)
|
||||
-V|--vnet)
|
||||
VNET_JAIL="1"
|
||||
shift
|
||||
;;
|
||||
-B|--bridge|bridge)
|
||||
-B|--bridge)
|
||||
VNET_JAIL="1"
|
||||
VNET_JAIL_BRIDGE="1"
|
||||
shift
|
||||
;;
|
||||
-C|--clone|clone)
|
||||
-C|--clone)
|
||||
CLONE_JAIL="1"
|
||||
shift
|
||||
;;
|
||||
-CV|-VC|--clone-vnet)
|
||||
CLONE_JAIL="1"
|
||||
VNET_JAIL="1"
|
||||
shift
|
||||
;;
|
||||
-CB|-BC|--clone-bridge)
|
||||
CLONE_JAIL="1"
|
||||
VNET_JAIL="1"
|
||||
VNET_JAIL_BRIDGE="1"
|
||||
shift
|
||||
;;
|
||||
-TV|-VT|--thick-vnet)
|
||||
THICK_JAIL="1"
|
||||
VNET_JAIL="1"
|
||||
shift
|
||||
;;
|
||||
-TB|-BT|--thick-bridge)
|
||||
THICK_JAIL="1"
|
||||
VNET_JAIL="1"
|
||||
VNET_JAIL_BRIDGE="1"
|
||||
shift
|
||||
;;
|
||||
-EB|-BE|--empty-bridge)
|
||||
EMPTY_JAIL="1"
|
||||
VNET_JAIL="1"
|
||||
VNET_JAIL_BRIDGE="1"
|
||||
shift
|
||||
;;
|
||||
-EV|-VE|--empty-vnet)
|
||||
EMPTY_JAIL="1"
|
||||
VNET_JAIL="1"
|
||||
shift
|
||||
;;
|
||||
-LV|-VL|--linux-vnet)
|
||||
LINUX_JAIL="1"
|
||||
VNET_JAIL="1"
|
||||
shift
|
||||
;;
|
||||
-LB|-BL|--linux-bridge)
|
||||
LINUX_JAIL="1"
|
||||
VNET_JAIL="1"
|
||||
VNET_JAIL_BRIDGE="1"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
error_notify "Unknown Option."
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
@@ -719,9 +765,9 @@ if [ -z "${EMPTY_JAIL}" ]; then
|
||||
NAME_VERIFY=$(echo "${RELEASE}" | grep -iwE '^([1-9]{2,2})\.[0-9](-CURRENT|-CURRENT-i386)$' | tr '[:lower:]' '[:upper:]' | sed 's/I/i/g')
|
||||
validate_release
|
||||
;;
|
||||
*-RELEASE|*-RELEASE-I386|*-RELEASE-i386|*-release|*-RC1|*-rc1|*-RC2|*-rc2|*-BETA1|*-BETA2|*-BETA3|*-BETA4|*-BETA5)
|
||||
*-RELEASE|*-RELEASE-I386|*-RELEASE-i386|*-release|*-RC[1-9]|*-rc[1-9]|*-BETA[1-9])
|
||||
## check for FreeBSD releases name
|
||||
NAME_VERIFY=$(echo "${RELEASE}" | grep -iwE '^([1-9]{2,2})\.[0-9](-RELEASE|-RELEASE-i386|-RC[1-2]|-BETA[1-5])$' | tr '[:lower:]' '[:upper:]' | sed 's/I/i/g')
|
||||
NAME_VERIFY=$(echo "${RELEASE}" | grep -iwE '^([1-9]{2,2})\.[0-9](-RELEASE|-RELEASE-i386|-RC[1-9]|-BETA[1-9])$' | tr '[:lower:]' '[:upper:]' | sed 's/I/i/g')
|
||||
validate_release
|
||||
;;
|
||||
*-stable-LAST|*-STABLE-last|*-stable-last|*-STABLE-LAST)
|
||||
|
||||
@@ -219,9 +219,9 @@ case "${TARGET}" in
|
||||
NAME_VERIFY=$(echo "${TARGET}" | grep -iwE '^([1-9]{2,2})\.[0-9](-CURRENT|-CURRENT-i386)$' | tr '[:lower:]' '[:upper:]' | sed 's/I/i/g')
|
||||
destroy_rel
|
||||
;;
|
||||
*-RELEASE|*-RELEASE-I386|*-RELEASE-i386|*-release|*-RC1|*-rc1|*-RC2|*-rc2|*-RC3|*-rc3|*-RC4|*-rc4|*-RC5|*-rc5|*-BETA1|*-BETA2|*-BETA3|*-BETA4|*-BETA5)
|
||||
*-RELEASE|*-RELEASE-I386|*-RELEASE-i386|*-release|*-RC[1-9]|*-rc[1-9]|*-BETA[1-9])
|
||||
## check for FreeBSD releases name
|
||||
NAME_VERIFY=$(echo "${TARGET}" | grep -iwE '^([1-9]{2,2})\.[0-9](-RELEASE|-RELEASE-i386|-RC[1-5]|-BETA[1-5])$' | tr '[:lower:]' '[:upper:]' | sed 's/I/i/g')
|
||||
NAME_VERIFY=$(echo "${TARGET}" | grep -iwE '^([1-9]{2,2})\.[0-9](-RELEASE|-RELEASE-i386|-RC[1-9]|-BETA[1-9])$' | tr '[:lower:]' '[:upper:]' | sed 's/I/i/g')
|
||||
destroy_rel
|
||||
;;
|
||||
*-stable-LAST|*-STABLE-last|*-stable-last|*-STABLE-LAST)
|
||||
|
||||
@@ -164,7 +164,7 @@ update_fstab() {
|
||||
# Update fstab .bastille mountpoint on thin containers only
|
||||
# Set some variables
|
||||
FSTAB_CONFIG="${bastille_jailsdir}/${TARGET_TRIM}/fstab"
|
||||
FSTAB_RELEASE=$(grep -owE '([1-9]{2,2})\.[0-9](-RELEASE|-RELEASE-i386|-RC[1-2])|([0-9]{1,2}-stable-build-[0-9]{1,3})|(current-build)-([0-9]{1,3})|(current-BUILD-LATEST)|([0-9]{1,2}-stable-BUILD-LATEST)|(current-BUILD-LATEST)' "${FSTAB_CONFIG}")
|
||||
FSTAB_RELEASE=$(grep -owE '([1-9]{2,2})\.[0-9](-RELEASE|-RELEASE-i386|-RC[1-9])|([0-9]{1,2}-stable-build-[0-9]{1,3})|(current-build)-([0-9]{1,3})|(current-BUILD-LATEST)|([0-9]{1,2}-stable-BUILD-LATEST)|(current-BUILD-LATEST)' "${FSTAB_CONFIG}")
|
||||
FSTAB_CURRENT=$(grep -w ".*/releases/.*/jails/${TARGET_TRIM}/root/.bastille" "${FSTAB_CONFIG}")
|
||||
FSTAB_NEWCONF="${bastille_releasesdir}/${FSTAB_RELEASE} ${bastille_jailsdir}/${TARGET_TRIM}/root/.bastille nullfs ro 0 0"
|
||||
if [ -n "${FSTAB_CURRENT}" ] && [ -n "${FSTAB_NEWCONF}" ]; then
|
||||
|
||||
77
usr/local/share/bastille/rcp.sh
Normal file
77
usr/local/share/bastille/rcp.sh
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2018-2022, Christer Edwards <christer.edwards@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# * Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
. /usr/local/share/bastille/common.sh
|
||||
. /usr/local/etc/bastille/bastille.conf
|
||||
|
||||
usage() {
|
||||
error_exit "Usage: bastille rcp [OPTION] TARGET CONTAINER_PATH HOST_PATH"
|
||||
}
|
||||
|
||||
CPSOURCE="${1}"
|
||||
CPDEST="${2}"
|
||||
|
||||
# Handle special-case commands first.
|
||||
case "$1" in
|
||||
help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
-q|--quiet)
|
||||
OPTION="${1}"
|
||||
CPSOURCE="${2}"
|
||||
CPDEST="${3}"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ "${TARGET}" = "ALL" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
case "${OPTION}" in
|
||||
-q|--quiet)
|
||||
OPTION="-a"
|
||||
;;
|
||||
*)
|
||||
OPTION="-av"
|
||||
;;
|
||||
esac
|
||||
|
||||
for _jail in ${JAILS}; do
|
||||
info "[${_jail}]:"
|
||||
bastille_jail_path="${bastille_jailsdir}/${_jail}/root"
|
||||
cp "${OPTION}" "${bastille_jail_path}/${CPSOURCE}" "${CPDEST}"
|
||||
RETURN="$?"
|
||||
echo
|
||||
return "${RETURN}"
|
||||
done
|
||||
@@ -83,7 +83,7 @@ update_fstab() {
|
||||
if [ -f "${FSTAB_CONFIG}" ]; then
|
||||
# Skip if fstab is empty, e.g newly created thick or clone jails
|
||||
if [ -s "${FSTAB_CONFIG}" ]; then
|
||||
FSTAB_RELEASE=$(grep -owE '([1-9]{2,2})\.[0-9](-RELEASE|-RC[1-2])|([0-9]{1,2}-stable-build-[0-9]{1,3})|(current-build)-([0-9]{1,3})|(current-BUILD-LATEST)|([0-9]{1,2}-stable-BUILD-LATEST)|(current-BUILD-LATEST)' "${FSTAB_CONFIG}")
|
||||
FSTAB_RELEASE=$(grep -owE '([1-9]{2,2})\.[0-9](-RELEASE|-RC[1-9])|([0-9]{1,2}-stable-build-[0-9]{1,3})|(current-build)-([0-9]{1,3})|(current-BUILD-LATEST)|([0-9]{1,2}-stable-BUILD-LATEST)|(current-BUILD-LATEST)' "${FSTAB_CONFIG}")
|
||||
FSTAB_CURRENT=$(grep -w ".*/releases/.*/jails/${TARGET}/root/.bastille" "${FSTAB_CONFIG}")
|
||||
FSTAB_NEWCONF="${bastille_releasesdir}/${FSTAB_RELEASE} ${bastille_jailsdir}/${NEWNAME}/root/.bastille nullfs ro 0 0"
|
||||
if [ -n "${FSTAB_CURRENT}" ] && [ -n "${FSTAB_NEWCONF}" ]; then
|
||||
|
||||
@@ -93,7 +93,7 @@ fi
|
||||
|
||||
# Configure ZFS
|
||||
configure_zfs() {
|
||||
if [ ! "$(kldstat -q -m zfs)" ]; then
|
||||
if [ ! "$(kldstat -m zfs)" ]; then
|
||||
info "ZFS module not loaded; skipping..."
|
||||
else
|
||||
## attempt to determine bastille_zroot from `zpool list`
|
||||
|
||||
@@ -157,7 +157,7 @@ fi
|
||||
bastille_root_check
|
||||
|
||||
case "$1" in
|
||||
*-RELEASE|*-release|*-RC1|*-rc1|*-RC2|*-rc2)
|
||||
*-RELEASE|*-release|*-RC[1-9]|*-rc[1-9])
|
||||
RELEASE=$1
|
||||
verify_release
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user