Compare commits
22 Commits
0.3.201811
...
0.3.201811
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18eec0d5b8 | ||
|
|
f38eff56fc | ||
|
|
55268d84ac | ||
|
|
1e6e0f3376 | ||
|
|
9738472245 | ||
|
|
a77dc8ef9d | ||
|
|
d15a1d166f | ||
|
|
b70d002c4b | ||
|
|
c6c3b8c52e | ||
|
|
58da217e77 | ||
|
|
ca8dad3bc3 | ||
|
|
8b7fb790e4 | ||
|
|
2533f44187 | ||
|
|
a85397484a | ||
|
|
b44e06d48a | ||
|
|
5d56b9c223 | ||
|
|
989692fc0d | ||
|
|
7700b9beff | ||
|
|
117dec28b9 | ||
|
|
396d5cd21c | ||
|
|
d6be76f317 | ||
|
|
a3273e98f7 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
docs/_build
|
||||||
124
README.md
124
README.md
@@ -4,9 +4,25 @@ Bastille is a jail automation framework that allows you to quickly and
|
|||||||
easily create and manage FreeBSD jail.
|
easily create and manage FreeBSD jail.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
Bastille is not (yet) in the official ports tree, but I have built and verified
|
||||||
|
binary packages.
|
||||||
|
|
||||||
|
To install using one of the BETA binary packages, copy the URL for the latest
|
||||||
|
release here (TXZ file): https://github.com/bastillebsd/bastille/releases
|
||||||
|
|
||||||
|
Then, install via `pkg`.
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
pkg add https://github.com/BastilleBSD/bastille/releases/download/0.3.20181114/bastille-0.3.20181114.txz
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Basic Usage
|
Basic Usage
|
||||||
-----------
|
-----------
|
||||||
```
|
```shell
|
||||||
ishmael ~ # bastille -h
|
ishmael ~ # bastille -h
|
||||||
Usage:
|
Usage:
|
||||||
bastille command [ALL|glob] [args]
|
bastille command [ALL|glob] [args]
|
||||||
@@ -26,6 +42,7 @@ Available Commands:
|
|||||||
start Start a stopped jail.
|
start Start a stopped jail.
|
||||||
stop Stop a running jail.
|
stop Stop a running jail.
|
||||||
sysrc Safely edit rc files within targeted jail(s).
|
sysrc Safely edit rc files within targeted jail(s).
|
||||||
|
template Apply Bastille template to running jail(s).
|
||||||
top Display and update information about the top(1) cpu processes.
|
top Display and update information about the top(1) cpu processes.
|
||||||
update Update jail base -pX release.
|
update Update jail base -pX release.
|
||||||
upgrade Upgrade jail release to X.Y-RELEASE.
|
upgrade Upgrade jail release to X.Y-RELEASE.
|
||||||
@@ -51,7 +68,7 @@ the firewall, permitting and denying traffic as needed.
|
|||||||
First, create the loopback interface:
|
First, create the loopback interface:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
ishmael ~ # sysrc cloned_interfaces="lo1"
|
ishmael ~ # sysrc cloned_interfaces+=lo1
|
||||||
ishmael ~ # service netif cloneup
|
ishmael ~ # service netif cloneup
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -130,7 +147,7 @@ release version as the argument.
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
ishmael ~ # bastille bootstrap 11.2-RELEASE
|
ishmael ~ # bastille bootstrap 11.2-RELEASE
|
||||||
ishmael ~ # bastille bootstrap 10.4-RELEASE
|
ishmael ~ # bastille bootstrap 12.0-RELEASE
|
||||||
```
|
```
|
||||||
|
|
||||||
This command will ensure the required directory structures are in place and
|
This command will ensure the required directory structures are in place and
|
||||||
@@ -440,6 +457,88 @@ Note: jail console logs not destroyed.
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
bastille template
|
||||||
|
-----------------
|
||||||
|
Bastille supports a templating system allowing you to apply files, pkgs and
|
||||||
|
execute commands inside the jail automatically.
|
||||||
|
|
||||||
|
Currently supported template hooks are: `PRE`, `CONFIG`, `PKG`, `SYSRC`, `CMD`.
|
||||||
|
Planned template hooks include: `FSTAB`, `PF`
|
||||||
|
|
||||||
|
Templates are created in `${bastille_prefix}/templates` and can leverage any of
|
||||||
|
the template hooks. Simply create a new directory named after the template. eg;
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mkdir -p /usr/local/bastille/templates/base
|
||||||
|
```
|
||||||
|
|
||||||
|
To leverage a template hook, create an UPPERCASE file in the root of the
|
||||||
|
template directory named after the hook you want to execute. eg;
|
||||||
|
|
||||||
|
```shell
|
||||||
|
echo "zsh vim-console git-lite htop" > /usr/local/bastille/templates/base/PKG
|
||||||
|
echo "/usr/bin/chsh -s /usr/local/bin/zsh" > /usr/local/bastille/templates/base/CMD
|
||||||
|
echo "etc root usr" > /usr/local/bastille/templates/base/CONFIG
|
||||||
|
```
|
||||||
|
|
||||||
|
Template hooks are executed in specific order and require specific syntax to
|
||||||
|
work as expected. This table outlines those requirements:
|
||||||
|
|
||||||
|
| HOOK | format | example |
|
||||||
|
|---------|------------------|--------------------------------------|
|
||||||
|
| PRE/CMD | /bin/sh command | /usr/bin/chsh -s /usr/local/bin/zsh |
|
||||||
|
| CONFIG | path | etc root usr |
|
||||||
|
| PKG | port/pkg name(s) | vim-console zsh git-lite tree htop |
|
||||||
|
| SYSRC | sysrc command(s) | nginx_enable=YES |
|
||||||
|
|
||||||
|
Note: SYSRC requires NO quotes or that quotes (`"`) be escaped. ie; `\"`)
|
||||||
|
|
||||||
|
In addition to supporting template hooks, Bastille supports overlaying files
|
||||||
|
into the jail. This is done by placing the files in their full path, using the
|
||||||
|
template directory as "/".
|
||||||
|
|
||||||
|
An example here may help. Think of `/usr/local/bastille/templates/base`, our
|
||||||
|
example template, as the root of our filesystem overlay. If you create an
|
||||||
|
`etc/hosts` or `etc/resolv.conf` *inside* the base template directory, these
|
||||||
|
can be overlayed into your jail.
|
||||||
|
|
||||||
|
Note: due to the way FreeBSD segregates user-space, the majority of your
|
||||||
|
overlayed template files will be in `usr/local`. The few general
|
||||||
|
exceptions are the `etc/hosts`, `etc/resolv.conf`, and `etc/rc.conf.local`.
|
||||||
|
|
||||||
|
After populating `usr/local/` with custom config files that your jail will
|
||||||
|
use, be sure to include `usr` in the template CONFIG definition. eg;
|
||||||
|
|
||||||
|
```shell
|
||||||
|
echo "etc usr" > /usr/local/bastille/templates/base/CONFIG
|
||||||
|
```
|
||||||
|
|
||||||
|
The above example "etc usr" will include anything under "etc" and "usr" inside
|
||||||
|
the template. You do not need to list individual files. Just include the
|
||||||
|
top-level directory name.
|
||||||
|
|
||||||
|
Applying Templates
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Jails must be running to apply templates.
|
||||||
|
|
||||||
|
Bastille includes a `template` sub-command. This sub-command requires a target
|
||||||
|
and a template name. As covered in the previous section, template names
|
||||||
|
correspond to directory names in the `bastille/templates` directory.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
ishmael ~ # bastille template folsom base
|
||||||
|
[folsom]:
|
||||||
|
Copying files...
|
||||||
|
Copy complete.
|
||||||
|
Installing packages.
|
||||||
|
...[snip]...
|
||||||
|
Executing final command(s).
|
||||||
|
chsh: user information updated
|
||||||
|
Template Complete.
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
bastille top
|
bastille top
|
||||||
------------
|
------------
|
||||||
@@ -757,8 +856,25 @@ rdr pass inet proto tcp from any to any port 8081 -> 10.7.6.5 port 8080
|
|||||||
rdr pass inet proto tcp from any to any port 8181 -> 10.7.6.5 port 443
|
rdr pass inet proto tcp from any to any port 8181 -> 10.7.6.5 port 443
|
||||||
```
|
```
|
||||||
|
|
||||||
Tip: Initially I spent time worrying about what IP addresses to assign. In the
|
Tip #3:
|
||||||
|
-------
|
||||||
|
Don't worry too much about IP assignments.
|
||||||
|
Initially I spent time worrying about what IP addresses to assign. In the
|
||||||
end I've come to the conclusion that it _really_ doesn't matter. Pick *any*
|
end I've come to the conclusion that it _really_ doesn't matter. Pick *any*
|
||||||
private address and be done with it. These are all isolated networks. In the
|
private address and be done with it. These are all isolated networks. In the
|
||||||
end, what matters is you can map host:port to jail:port reliably, and we
|
end, what matters is you can map host:port to jail:port reliably, and we
|
||||||
can.
|
can.
|
||||||
|
|
||||||
|
|
||||||
|
Community Support
|
||||||
|
=================
|
||||||
|
We would love to hear your feedback on Bastille! Please join us on the
|
||||||
|
[BastilleBSD Chat Server](https://chat.bastillebsd.org) and let us know what
|
||||||
|
you think. Registration is currently open pending email verification.
|
||||||
|
|
||||||
|
Be mindful of the [Bastille Code of
|
||||||
|
Conduct](https://github.com/BastilleBSD/bastille/blob/master/CODE-OF-CONDUCT.md)
|
||||||
|
when participating in the chat rooms.
|
||||||
|
|
||||||
|
If you've found a bug in Bastille, please submit it to the [Bastille Issue
|
||||||
|
Tracker](https://github.com/bastillebsd/bastille/issues/new).
|
||||||
|
|||||||
45
ROADMAP.md
Normal file
45
ROADMAP.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
Bastille Roadmap
|
||||||
|
================
|
||||||
|
This is the general roadmap for the next nine months. I would like the
|
||||||
|
near-term done by the end of 2018. The mid-term should be done by March 2019.
|
||||||
|
The long-term by summer 2019.
|
||||||
|
|
||||||
|
At that point, if the templating is mature, and the top 50 is complete, the
|
||||||
|
platform is ready for general purpose use.
|
||||||
|
|
||||||
|
|
||||||
|
near-term
|
||||||
|
---------
|
||||||
|
1. zfs support (configurable)
|
||||||
|
2. bastille-dev template (see below):
|
||||||
|
```shell
|
||||||
|
## jail -c name=foo host.hostname=foo allow.raw_sockets children.max=99
|
||||||
|
## ip4.addr=10.20.12.68 persist
|
||||||
|
## jexec foo /bin/csh
|
||||||
|
## foo# jail -c name=bar host.hostname=bar allow.raw_sockets
|
||||||
|
## ip4.addr=10.20.12.68 persist
|
||||||
|
## foo# jexec bar /bin/csh
|
||||||
|
## bar# ping gritton.org
|
||||||
|
```
|
||||||
|
3. branding
|
||||||
|
|
||||||
|
|
||||||
|
mid-term
|
||||||
|
--------
|
||||||
|
1. templating
|
||||||
|
2. ssh-to-jail demo (ie; ldap + .authorized_keys + command)
|
||||||
|
```shell
|
||||||
|
## TODO: .ssh/authorized_keys auto-launch into user jail
|
||||||
|
## jail_create_login_hook() {
|
||||||
|
## echo "permit nopass ${user} cmd /usr/sbin/jexec args ${name} /usr/bin/login -f ${user}" >> /usr/local/etc/doas.conf
|
||||||
|
## echo "command='/usr/local/bin/doas /usr/sbin/jexec ${name} /usr/bin/login -f ${user}' ${pubkey}" >> $HOME/.ssh/authorized_keys
|
||||||
|
## }
|
||||||
|
```
|
||||||
|
3. additional modules: ps, sockstat, pf, fstab.
|
||||||
|
|
||||||
|
|
||||||
|
long-term
|
||||||
|
---------
|
||||||
|
1. top 50
|
||||||
|
2. monitoring
|
||||||
|
3. rctl
|
||||||
29
TODO
29
TODO
@@ -1,29 +0,0 @@
|
|||||||
# TODO
|
|
||||||
|
|
||||||
##This is just a place to throw down the ideas of things I need to fix and or
|
|
||||||
##improve. In no particular order.
|
|
||||||
##
|
|
||||||
##+ ZFS or UFS support
|
|
||||||
##+ Support for multi-jail templating (create, snapshot, deploy)
|
|
||||||
##+ jail.conf validation support in `create`
|
|
||||||
##+ Dynamic config support for templating
|
|
||||||
##+
|
|
||||||
|
|
||||||
##Bastille in Bastille
|
|
||||||
##--------------------
|
|
||||||
## found on mailing list archive. need to research
|
|
||||||
|
|
||||||
## jail -c name=foo host.hostname=foo allow.raw_sockets children.max=99
|
|
||||||
## ip4.addr=10.20.12.68 persist
|
|
||||||
## jexec foo /bin/csh
|
|
||||||
## foo# jail -c name=bar host.hostname=bar allow.raw_sockets
|
|
||||||
## ip4.addr=10.20.12.68 persist
|
|
||||||
## foo# jexec bar /bin/csh
|
|
||||||
## bar# ping gritton.org
|
|
||||||
|
|
||||||
## TODO: .ssh/authorized_keys auto-launch into user jail
|
|
||||||
## jail_create_login_hook() {
|
|
||||||
## echo "permit nopass ${user} cmd /usr/sbin/jexec args ${name} /usr/bin/login -f ${user}" >> /usr/local/etc/doas.conf
|
|
||||||
## echo "command='/usr/local/bin/doas /usr/sbin/jexec ${name} /usr/bin/login -f ${user}' ${pubkey}" >> $HOME/.ssh/authorized_keys
|
|
||||||
## }
|
|
||||||
|
|
||||||
19
docs/Makefile
Normal file
19
docs/Makefile
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Minimal makefile for Sphinx documentation
|
||||||
|
#
|
||||||
|
|
||||||
|
# You can set these variables from the command line.
|
||||||
|
SPHINXOPTS =
|
||||||
|
SPHINXBUILD = sphinx-build
|
||||||
|
SOURCEDIR = .
|
||||||
|
BUILDDIR = _build
|
||||||
|
|
||||||
|
# Put it first so that "make" without argument is like "make help".
|
||||||
|
help:
|
||||||
|
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
|
|
||||||
|
.PHONY: help Makefile
|
||||||
|
|
||||||
|
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||||
|
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||||
|
%: Makefile
|
||||||
|
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
1
docs/README.md
Symbolic link
1
docs/README.md
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../README.md
|
||||||
185
docs/conf.py
Normal file
185
docs/conf.py
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Configuration file for the Sphinx documentation builder.
|
||||||
|
#
|
||||||
|
# This file does only contain a selection of the most common options. For a
|
||||||
|
# full list see the documentation:
|
||||||
|
# http://www.sphinx-doc.org/en/master/config
|
||||||
|
|
||||||
|
# -- Path setup --------------------------------------------------------------
|
||||||
|
|
||||||
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
|
#
|
||||||
|
# import os
|
||||||
|
# import sys
|
||||||
|
# sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
|
||||||
|
import os
|
||||||
|
on_rtd = os.environ.get('READTHEDOCS') == 'True'
|
||||||
|
if on_rtd:
|
||||||
|
html_theme = 'default'
|
||||||
|
else:
|
||||||
|
html_theme = 'sphinx_rtd_theme'
|
||||||
|
|
||||||
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
|
project = 'Bastille'
|
||||||
|
copyright = '2018, Christer Edwards'
|
||||||
|
author = 'Christer Edwards'
|
||||||
|
|
||||||
|
# The short X.Y version
|
||||||
|
version = '0.3'
|
||||||
|
# The full version, including alpha/beta/rc tags
|
||||||
|
release = 'beta'
|
||||||
|
|
||||||
|
|
||||||
|
# -- General configuration ---------------------------------------------------
|
||||||
|
|
||||||
|
# If your documentation needs a minimal Sphinx version, state it here.
|
||||||
|
#
|
||||||
|
# needs_sphinx = '1.0'
|
||||||
|
|
||||||
|
# Add any Sphinx extension module names here, as strings. They can be
|
||||||
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
|
# ones.
|
||||||
|
extensions = [
|
||||||
|
]
|
||||||
|
|
||||||
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
|
templates_path = ['_templates']
|
||||||
|
|
||||||
|
# The suffix(es) of source filenames.
|
||||||
|
# You can specify multiple suffix as a list of string:
|
||||||
|
#
|
||||||
|
# source_suffix = ['.rst', '.md']
|
||||||
|
source_suffix = '.md'
|
||||||
|
|
||||||
|
from recommonmark.parser import CommonMarkParser
|
||||||
|
source_parsers = {
|
||||||
|
'.md': CommonMarkParser,
|
||||||
|
}
|
||||||
|
|
||||||
|
# The master toctree document.
|
||||||
|
master_doc = 'README'
|
||||||
|
|
||||||
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
|
# for a list of supported languages.
|
||||||
|
#
|
||||||
|
# This is also used if you do content translation via gettext catalogs.
|
||||||
|
# Usually you set "language" from the command line for these cases.
|
||||||
|
language = None
|
||||||
|
|
||||||
|
# List of patterns, relative to source directory, that match files and
|
||||||
|
# directories to ignore when looking for source files.
|
||||||
|
# This pattern also affects html_static_path and html_extra_path.
|
||||||
|
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||||
|
|
||||||
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
|
pygments_style = None
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for HTML output -------------------------------------------------
|
||||||
|
|
||||||
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
|
# a list of builtin themes.
|
||||||
|
#
|
||||||
|
##html_theme = 'alabaster'
|
||||||
|
|
||||||
|
# Theme options are theme-specific and customize the look and feel of a theme
|
||||||
|
# further. For a list of options available for each theme, see the
|
||||||
|
# documentation.
|
||||||
|
#
|
||||||
|
# html_theme_options = {}
|
||||||
|
|
||||||
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
|
html_static_path = ['_static']
|
||||||
|
|
||||||
|
# Custom sidebar templates, must be a dictionary that maps document names
|
||||||
|
# to template names.
|
||||||
|
#
|
||||||
|
# The default sidebars (for documents that don't match any pattern) are
|
||||||
|
# defined by theme itself. Builtin themes are using these templates by
|
||||||
|
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
|
||||||
|
# 'searchbox.html']``.
|
||||||
|
#
|
||||||
|
# html_sidebars = {}
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for HTMLHelp output ---------------------------------------------
|
||||||
|
|
||||||
|
# Output file base name for HTML help builder.
|
||||||
|
htmlhelp_basename = 'Bastilledoc'
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for LaTeX output ------------------------------------------------
|
||||||
|
|
||||||
|
latex_elements = {
|
||||||
|
# The paper size ('letterpaper' or 'a4paper').
|
||||||
|
#
|
||||||
|
# 'papersize': 'letterpaper',
|
||||||
|
|
||||||
|
# The font size ('10pt', '11pt' or '12pt').
|
||||||
|
#
|
||||||
|
# 'pointsize': '10pt',
|
||||||
|
|
||||||
|
# Additional stuff for the LaTeX preamble.
|
||||||
|
#
|
||||||
|
# 'preamble': '',
|
||||||
|
|
||||||
|
# Latex figure (float) alignment
|
||||||
|
#
|
||||||
|
# 'figure_align': 'htbp',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
|
# (source start file, target name, title,
|
||||||
|
# author, documentclass [howto, manual, or own class]).
|
||||||
|
latex_documents = [
|
||||||
|
(master_doc, 'Bastille.tex', 'Bastille Documentation',
|
||||||
|
'Christer Edwards', 'manual'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for manual page output ------------------------------------------
|
||||||
|
|
||||||
|
# One entry per manual page. List of tuples
|
||||||
|
# (source start file, name, description, authors, manual section).
|
||||||
|
man_pages = [
|
||||||
|
(master_doc, 'bastille', 'Bastille Documentation',
|
||||||
|
[author], 1)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for Texinfo output ----------------------------------------------
|
||||||
|
|
||||||
|
# Grouping the document tree into Texinfo files. List of tuples
|
||||||
|
# (source start file, target name, title, author,
|
||||||
|
# dir menu entry, description, category)
|
||||||
|
texinfo_documents = [
|
||||||
|
(master_doc, 'Bastille', 'Bastille Documentation',
|
||||||
|
author, 'Bastille', 'One line description of project.',
|
||||||
|
'Miscellaneous'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for Epub output -------------------------------------------------
|
||||||
|
|
||||||
|
# Bibliographic Dublin Core info.
|
||||||
|
epub_title = project
|
||||||
|
|
||||||
|
# The unique identifier of the text. This can be a ISBN number
|
||||||
|
# or the project homepage.
|
||||||
|
#
|
||||||
|
# epub_identifier = ''
|
||||||
|
|
||||||
|
# A unique identification for the text.
|
||||||
|
#
|
||||||
|
# epub_uid = ''
|
||||||
|
|
||||||
|
# A list of files that should not be packed into the epub file.
|
||||||
|
epub_exclude_files = ['search.html']
|
||||||
|
|
||||||
20
docs/index.rst.sample
Normal file
20
docs/index.rst.sample
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
.. Bastille documentation master file, created by
|
||||||
|
sphinx-quickstart on Tue Nov 20 20:48:22 2018.
|
||||||
|
You can adapt this file completely to your liking, but it should at least
|
||||||
|
contain the root `toctree` directive.
|
||||||
|
|
||||||
|
Welcome to Bastille's documentation!
|
||||||
|
====================================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: Contents:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Indices and tables
|
||||||
|
==================
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`modindex`
|
||||||
|
* :ref:`search`
|
||||||
@@ -32,8 +32,7 @@
|
|||||||
. /usr/local/etc/bastille/bastille.conf
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
## version
|
## version
|
||||||
BASTILLE_VERSION="0.3.20181107"
|
BASTILLE_VERSION="0.3.20181120"
|
||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
@@ -58,6 +57,7 @@ Available Commands:
|
|||||||
start Start a stopped container.
|
start Start a stopped container.
|
||||||
stop Stop a running container.
|
stop Stop a running container.
|
||||||
sysrc Safely edit rc files within targeted container(s).
|
sysrc Safely edit rc files within targeted container(s).
|
||||||
|
template Apply file templates to targeted jail(s).
|
||||||
top Display and update information about the top(1) cpu processes.
|
top Display and update information about the top(1) cpu processes.
|
||||||
update Update container base -pX release.
|
update Update container base -pX release.
|
||||||
upgrade Upgrade container release to X.Y-RELEASE.
|
upgrade Upgrade container release to X.Y-RELEASE.
|
||||||
@@ -73,7 +73,6 @@ EOF
|
|||||||
|
|
||||||
CMD=$1
|
CMD=$1
|
||||||
shift
|
shift
|
||||||
CMD_ENV=
|
|
||||||
|
|
||||||
# Handle special-case commands first.
|
# Handle special-case commands first.
|
||||||
case "${CMD}" in
|
case "${CMD}" in
|
||||||
@@ -88,32 +87,13 @@ esac
|
|||||||
|
|
||||||
# Filter out all non-commands
|
# Filter out all non-commands
|
||||||
case "${CMD}" in
|
case "${CMD}" in
|
||||||
cmd|console|cp|create|destroy|list|pkg|restart|start|stop|sysrc|verify)
|
cmd|cp|create|destroy|list|pkg|restart|start|stop|sysrc|template|verify)
|
||||||
;;
|
;;
|
||||||
update|upgrade)
|
update|upgrade)
|
||||||
CMD_ENV="${CMD_ENV} PAGER=cat"
|
|
||||||
;;
|
;;
|
||||||
console|bootstrap|htop|top)
|
console|bootstrap|htop|top)
|
||||||
while read envvar envvalue; do
|
;;
|
||||||
case "${envvar}" in
|
|
||||||
TERM)
|
|
||||||
CMD_ENV="${CMD_ENV} ${envvar}=${envvalue}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done <<-EOF
|
|
||||||
$(env | sed -Ee 's,^([^=]*)=(.*),\1 \2,')
|
|
||||||
EOF
|
|
||||||
;;
|
|
||||||
bootstrap|update|upgrade)
|
bootstrap|update|upgrade)
|
||||||
while read envvar envvalue; do
|
|
||||||
case "${envvar}" in
|
|
||||||
FETCH_BIND_ADDRESS|FTP_*|ftp_*|HTTP_*|http_*|SSL_|NO_PROXY|no_proxy|MAKEOBJDIRPREFIX)
|
|
||||||
CMD_ENV="${CMD_ENV} ${envvar}=${envvalue}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done <<-EOF
|
|
||||||
$(env | sed -Ee 's,^([^=]*)=(.*),\1 \2,')
|
|
||||||
EOF
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
@@ -127,4 +107,4 @@ umask ${UMASK}
|
|||||||
|
|
||||||
: ${SH:=sh}
|
: ${SH:=sh}
|
||||||
|
|
||||||
exec env -i ${CMD_ENV} ${SH} "${SCRIPTPATH}" "$@"
|
exec ${SH} "${SCRIPTPATH}" "$@"
|
||||||
@@ -7,4 +7,5 @@ bastille_cachedir=${bastille_prefix}/cache
|
|||||||
bastille_jailsdir=${bastille_prefix}/jails
|
bastille_jailsdir=${bastille_prefix}/jails
|
||||||
bastille_logsdir=${bastille_prefix}/logs
|
bastille_logsdir=${bastille_prefix}/logs
|
||||||
bastille_releasesdir=${bastille_prefix}/releases
|
bastille_releasesdir=${bastille_prefix}/releases
|
||||||
|
bastille_templatesdir=${bastille_prefix}/templates
|
||||||
bastille_sharedir=/usr/local/share/bastille
|
bastille_sharedir=/usr/local/share/bastille
|
||||||
@@ -29,8 +29,8 @@ load_rc_config ${name}
|
|||||||
start_cmd=bastille_start
|
start_cmd=bastille_start
|
||||||
stop_cmd=bastille_stop
|
stop_cmd=bastille_stop
|
||||||
|
|
||||||
start_command="%%$PREFIX%%/bin/bastille start"
|
start_command="%%PREFIX%%/bin/bastille start"
|
||||||
stop_command="%%$PREFIX%%/bin/bastille stop"
|
stop_command="%%PREFIX%%/bin/bastille stop"
|
||||||
|
|
||||||
bastille_start()
|
bastille_start()
|
||||||
{
|
{
|
||||||
@@ -110,18 +110,22 @@ case "${RELEASE}" in
|
|||||||
;;
|
;;
|
||||||
12.0-BETA1)
|
12.0-BETA1)
|
||||||
bootstrap
|
bootstrap
|
||||||
echo -e "${COLOR_RED}BETA releases are complete untested.${COLOR_RESET}"
|
echo -e "${COLOR_RED}BETA releases are completely untested.${COLOR_RESET}"
|
||||||
;;
|
;;
|
||||||
12.0-BETA2)
|
12.0-BETA2)
|
||||||
bootstrap
|
bootstrap
|
||||||
echo -e "${COLOR_RED}BETA releases are complete untested.${COLOR_RESET}"
|
echo -e "${COLOR_RED}BETA releases are completely untested.${COLOR_RESET}"
|
||||||
;;
|
;;
|
||||||
12.0-BETA3)
|
12.0-BETA3)
|
||||||
bootstrap
|
bootstrap
|
||||||
echo -e "${COLOR_RED}BETA releases are complete untested.${COLOR_RESET}"
|
echo -e "${COLOR_RED}BETA releases are completely untested.${COLOR_RESET}"
|
||||||
|
;;
|
||||||
|
12.0-BETA4)
|
||||||
|
bootstrap
|
||||||
|
echo -e "${COLOR_RED}BETA releases are completely untested.${COLOR_RESET}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "${COLOR_RED}BETA releases are complete untested.${COLOR_RESET}"
|
echo -e "${COLOR_RED}BETA releases are completely untested.${COLOR_RESET}"
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -56,5 +56,5 @@ fi
|
|||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jexec -l ${_jail} $2
|
jexec -l ${_jail} $2
|
||||||
echo -e "${NC}"
|
echo
|
||||||
done
|
done
|
||||||
@@ -56,5 +56,5 @@ fi
|
|||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jexec -l ${_jail} /usr/bin/login -f root
|
jexec -l ${_jail} /usr/bin/login -f root
|
||||||
echo -e "${NC}"
|
echo
|
||||||
done
|
done
|
||||||
@@ -58,5 +58,5 @@ for _jail in ${JAILS}; do
|
|||||||
bastille_jail_path="${bastille_jailsdir}/${_jail}/root"
|
bastille_jail_path="${bastille_jailsdir}/${_jail}/root"
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
cp -a "$2" "${bastille_jail_path}/$3"
|
cp -a "$2" "${bastille_jail_path}/$3"
|
||||||
echo -e "${COLOR_RESET}"
|
echo
|
||||||
done
|
done
|
||||||
@@ -70,8 +70,8 @@ create_jail() {
|
|||||||
|
|
||||||
if [ ! -d "${bastille_jail_base}" ]; then
|
if [ ! -d "${bastille_jail_base}" ]; then
|
||||||
mkdir -p "${bastille_jail_base}"
|
mkdir -p "${bastille_jail_base}"
|
||||||
mkdir -p "${bastille_jail_path}/usr"
|
|
||||||
mkdir -p "${bastille_jail_path}/usr/home"
|
mkdir -p "${bastille_jail_path}/usr/home"
|
||||||
|
mkdir -p "${bastille_jail_path}/usr/local"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "${bastille_jail_template}" ]; then
|
if [ ! -d "${bastille_jail_template}" ]; then
|
||||||
@@ -97,9 +97,9 @@ create_jail() {
|
|||||||
## ro
|
## ro
|
||||||
cd "${bastille_jail_path}"
|
cd "${bastille_jail_path}"
|
||||||
echo
|
echo
|
||||||
echo -e "${COLOR_GREEN}RELEASE: ${RELEASE}.${COLOR_RESET}"
|
|
||||||
echo -e "${COLOR_GREEN}NAME: ${NAME}.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}NAME: ${NAME}.${COLOR_RESET}"
|
||||||
echo -e "${COLOR_GREEN}IP: ${IP}.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}IP: ${IP}.${COLOR_RESET}"
|
||||||
|
echo -e "${COLOR_GREEN}RELEASE: ${RELEASE}.${COLOR_RESET}"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
for _link in bin boot lib libexec rescue sbin usr/bin usr/include usr/lib usr/lib32 usr/libdata usr/libexec usr/sbin usr/share usr/src; do
|
for _link in bin boot lib libexec rescue sbin usr/bin usr/include usr/lib usr/lib32 usr/libdata usr/libexec usr/sbin usr/share usr/src; do
|
||||||
@@ -107,7 +107,7 @@ create_jail() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
## link home properly
|
## link home properly
|
||||||
ln -sf usr/home home
|
ln -s usr/home home
|
||||||
|
|
||||||
## rw
|
## rw
|
||||||
cp -a "${bastille_releasesdir}/${RELEASE}/.cshrc" "${bastille_jail_path}"
|
cp -a "${bastille_releasesdir}/${RELEASE}/.cshrc" "${bastille_jail_path}"
|
||||||
@@ -126,8 +126,10 @@ create_jail() {
|
|||||||
if [ "${RELEASE}" == "11.2-RELEASE" ]; then cp -a "${bastille_releasesdir}/${RELEASE}/usr/tests" "${bastille_jail_path}"; fi
|
if [ "${RELEASE}" == "11.2-RELEASE" ]; then cp -a "${bastille_releasesdir}/${RELEASE}/usr/tests" "${bastille_jail_path}"; fi
|
||||||
|
|
||||||
## rc.conf.local & resolv.conf
|
## rc.conf.local & resolv.conf
|
||||||
|
## cron_flags="-J 60" ## cedwards 20181118
|
||||||
if [ ! -f "${bastille_jail_rc_conf}" ]; then
|
if [ ! -f "${bastille_jail_rc_conf}" ]; then
|
||||||
echo -e "syslogd_flags=\"-ss\"\nsendmail_enable=\"NONE\"" > ${bastille_jail_rc_conf}
|
echo -e "syslogd_flags=\"-ss\"\nsendmail_enable=\"NONE\"" > ${bastille_jail_rc_conf}
|
||||||
|
echo -e "cron_flags=\"-J 60\"" >> ${bastille_jail_rc_conf}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "${bastille_jail_resolv_conf}" ]; then
|
if [ ! -f "${bastille_jail_resolv_conf}" ]; then
|
||||||
@@ -135,8 +137,7 @@ create_jail() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
## TZ: UTC
|
## TZ: UTC
|
||||||
ln -s "/usr/share/zoneinfo/Etc/UTC ${bastille_jail_root}/etc/localtime"
|
ln -s /usr/share/zoneinfo/Etc/UTC etc/localtime
|
||||||
ln -s "/.template/usr/local ${bastille_jail_root}/usr/local"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle special-case commands first.
|
# Handle special-case commands first.
|
||||||
@@ -174,12 +175,6 @@ if [ -d "/usr/local/bastille/jails/${NAME}/root/.bastille" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## check for name/root/.template
|
|
||||||
if [ -d "/usr/local/bastille/jails/${NAME}/root/.template" ]; then
|
|
||||||
echo -e "${COLOR_RED}Jail: ${NAME} already created. ${NAME}/root/.template exists.${COLOR_RESET}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
## check if a running jail matches name
|
## check if a running jail matches name
|
||||||
if running_jail ${NAME}; then
|
if running_jail ${NAME}; then
|
||||||
echo -e "${COLOR_RED}Running jail matches name.${COLOR_RESET}"
|
echo -e "${COLOR_RED}Running jail matches name.${COLOR_RESET}"
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# https://pastebin.com/T6eThbKu
|
||||||
|
|
||||||
DEVICE_SELF_SCAN_ALL=NO
|
DEVICE_SELF_SCAN_ALL=NO
|
||||||
[ "$_SCRIPT_SUBR" ] || . /usr/share/bsdconfig/script.subr
|
[ "$_SCRIPT_SUBR" ] || . /usr/share/bsdconfig/script.subr
|
||||||
@@ -64,3 +64,5 @@ for _jail in ${JAILS}; do
|
|||||||
fi
|
fi
|
||||||
echo -e "${COLOR_RESET}"
|
echo -e "${COLOR_RESET}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
TERM=${SAVED_TERM}
|
||||||
@@ -29,9 +29,10 @@
|
|||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
. /usr/local/share/bastille/colors.pre.sh
|
. /usr/local/share/bastille/colors.pre.sh
|
||||||
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo -e "${COLOR_RED}Usage: bastille list.${COLOR_RESET}"
|
echo -e "${COLOR_RED}Usage: bastille list [release|template|jail|log].${COLOR_RESET}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +46,18 @@ if [ $# -gt 0 ]; then
|
|||||||
help|-h|--help)
|
help|-h|--help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
release|releases)
|
||||||
|
ls "${bastille_releasesdir}"
|
||||||
|
;;
|
||||||
|
template|templates)
|
||||||
|
ls "${bastille_templatesdir}"
|
||||||
|
;;
|
||||||
|
jail|jails)
|
||||||
|
ls "${bastille_jailsdir}"
|
||||||
|
;;
|
||||||
|
log|logs)
|
||||||
|
ls "${bastille_logsdir}"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
@@ -56,5 +56,5 @@ fi
|
|||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jexec -l ${_jail} /usr/sbin/pkg $2
|
jexec -l ${_jail} /usr/sbin/pkg $2
|
||||||
echo -e "${COLOR_RESET}"
|
echo
|
||||||
done
|
done
|
||||||
@@ -57,5 +57,5 @@ fi
|
|||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jexec -l ${_jail} /usr/sbin/service $2
|
jexec -l ${_jail} /usr/sbin/service $2
|
||||||
echo -e "${COLOR_RESET}"
|
echo
|
||||||
done
|
done
|
||||||
@@ -62,7 +62,7 @@ fi
|
|||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -c ${_jail}
|
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -c ${_jail}
|
||||||
echo -e "${COLOR_RESET}"
|
echo
|
||||||
done
|
done
|
||||||
|
|
||||||
## HUP the firewall
|
## HUP the firewall
|
||||||
@@ -57,7 +57,7 @@ fi
|
|||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -r ${_jail}
|
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -r ${_jail}
|
||||||
echo -e "${COLOR_RESET}"
|
echo
|
||||||
done
|
done
|
||||||
|
|
||||||
## HUP the firewall
|
## HUP the firewall
|
||||||
117
usr/local/share/bastille/template.sh
Normal file
117
usr/local/share/bastille/template.sh
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018, 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/colors.pre.sh
|
||||||
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo -e "${COLOR_RED}Usage: bastille template [ALL|glob] template.${COLOR_RESET}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Handle special-case commands first.
|
||||||
|
case "$1" in
|
||||||
|
help|-h|--help)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ $# -gt 2 ] || [ $# -lt 2 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = 'ALL' ]; then
|
||||||
|
JAILS=$(jls -N name)
|
||||||
|
fi
|
||||||
|
if [ "$1" != 'ALL' ]; then
|
||||||
|
JAILS=$(jls -N name | grep "$1")
|
||||||
|
fi
|
||||||
|
|
||||||
|
TEMPLATE=$2
|
||||||
|
bastille_template=${bastille_templatesdir}/${TEMPLATE}
|
||||||
|
|
||||||
|
for _jail in ${JAILS}; do
|
||||||
|
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||||
|
|
||||||
|
## pre
|
||||||
|
if [ -s "${bastille_template}/PRE" ]; then
|
||||||
|
echo -e "${COLOR_GREEN}Executing PRE-command(s).${COLOR_RESET}"
|
||||||
|
jexec -l ${_jail} /bin/sh < "${bastille_template}/PRE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## config
|
||||||
|
if [ -s "${bastille_template}/CONFIG" ]; then
|
||||||
|
echo -e "${COLOR_GREEN}Copying files...${COLOR_RESET}"
|
||||||
|
for _dir in $(cat "${bastille_template}/CONFIG"); do
|
||||||
|
cp -a "${bastille_template}/${_dir}" "${bastille_jailsdir}/${_jail}/root"
|
||||||
|
done
|
||||||
|
echo -e "${COLOR_GREEN}Copy complete.${COLOR_RESET}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## fstab
|
||||||
|
if [ -s "${bastille_template}/FSTAB" ]; then
|
||||||
|
bastille_templatefstab=$(cat "${bastille_template}/FSTAB")
|
||||||
|
echo -e "${COLOR_GREEN}Updating fstab.${COLOR_RESET}"
|
||||||
|
echo -e "${COLOR_GREEN}NOT YET IMPLEMENTED.${COLOR_RESET}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## pf
|
||||||
|
if [ -s "${bastille_template}/PF" ]; then
|
||||||
|
bastille_templatepf=$(cat "${bastille_template}/PF")
|
||||||
|
echo -e "${COLOR_GREEN}Generating PF profile.${COLOR_RESET}"
|
||||||
|
echo -e "${COLOR_GREEN}NOT YET IMPLEMENTED.${COLOR_RESET}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## pkg (bootstrap + pkg)
|
||||||
|
if [ -s "${bastille_template}/PKG" ]; then
|
||||||
|
bastille_templatepkg=$(cat "${bastille_template}/PKG")
|
||||||
|
echo -e "${COLOR_GREEN}Installing packages.${COLOR_RESET}"
|
||||||
|
jexec -l ${_jail} env ASSUME_ALWAYS_YES="YES" /usr/sbin/pkg bootstrap
|
||||||
|
jexec -l ${_jail} env ASSUME_ALWAYS_YES="YES" /usr/sbin/pkg audit -F
|
||||||
|
jexec -l ${_jail} env ASSUME_ALWAYS_YES="YES" /usr/sbin/pkg install ${bastille_templatepkg}
|
||||||
|
fi
|
||||||
|
|
||||||
|
## sysrc
|
||||||
|
if [ -s "${bastille_template}/SYSRC" ]; then
|
||||||
|
echo -e "${COLOR_GREEN}Updating services.${COLOR_RESET}"
|
||||||
|
IFS=''
|
||||||
|
while read _sysrc; do
|
||||||
|
jexec -l ${_jail} /usr/sbin/sysrc "${_sysrc}"
|
||||||
|
done < "${bastille_template}/SYSRC"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## cmd
|
||||||
|
if [ -s "${bastille_template}/CMD" ]; then
|
||||||
|
echo -e "${COLOR_GREEN}Executing final command(s).${COLOR_RESET}"
|
||||||
|
jexec -l ${_jail} /bin/sh < "${bastille_template}/CMD"
|
||||||
|
fi
|
||||||
|
echo -e "${COLOR_GREEN}Template Complete.${COLOR_RESET}"
|
||||||
|
echo
|
||||||
|
done
|
||||||
@@ -59,3 +59,5 @@ for _jail in ${JAILS}; do
|
|||||||
jexec -l ${_jail} /usr/bin/top
|
jexec -l ${_jail} /usr/bin/top
|
||||||
echo -e "${COLOR_RESET}"
|
echo -e "${COLOR_RESET}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
TERM=${SAVED_TERM}
|
||||||
@@ -49,7 +49,7 @@ fi
|
|||||||
|
|
||||||
RELEASE=$1
|
RELEASE=$1
|
||||||
|
|
||||||
echo -e "${COLOR_RED}Targeting specified release.${COLOR_RESET}"
|
echo -e "${COLOR_GREEN}Targeting specified release.${COLOR_RESET}"
|
||||||
echo -e "${RELEASE}"
|
echo -e "${RELEASE}"
|
||||||
echo
|
echo
|
||||||
if [ -d "${bastille_releasesdir}/${RELEASE}" ]; then
|
if [ -d "${bastille_releasesdir}/${RELEASE}" ]; then
|
||||||
Reference in New Issue
Block a user