mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-25 06:55:46 +01:00
@@ -26,6 +26,7 @@ Available options are:
|
||||
|
||||
Options:
|
||||
|
||||
-a | --auto Auto mode. Start/stop jail(s) if required.
|
||||
--gz Export a ZFS jail using GZIP(.gz) compressed image.
|
||||
-r | --raw Export a ZFS jail to an uncompressed RAW image.
|
||||
-s | --safe Safely stop and start a ZFS jail before the exporting process.
|
||||
@@ -33,5 +34,6 @@ Available options are:
|
||||
--txz Export a jail using simple .txz compressed archive instead.
|
||||
-v | --verbose Be more verbose during the ZFS send operation.
|
||||
--xz Export a ZFS jail using XZ(.xz) compressed image.
|
||||
-x | --debug Enable debug mode.
|
||||
|
||||
Note: If no export option specified, the container should be redirected to standard output.
|
||||
|
||||
@@ -7,7 +7,8 @@ You can only add an interface once to a jail, with two exceptions.
|
||||
|
||||
1. For classic jails, you can add an interface as many times as you want, but
|
||||
each time with a different IP. All this does is add the IP as another alias
|
||||
on that interface.
|
||||
on that interface. This is the default if no option is given. See help output
|
||||
below.
|
||||
|
||||
2. For VNET jails, if the ``-v|--vlan`` switch is given along with a numerical
|
||||
VLAN ID, Bastille will add the VLAN ID to the jail as a vnetX.X interface,
|
||||
@@ -16,6 +17,8 @@ You can only add an interface once to a jail, with two exceptions.
|
||||
Bridges and VNET interfaces can be added to VNET jails, no matter if they were
|
||||
created with ``-V`` or ``-B``.
|
||||
|
||||
If no option is given, Bastille will assume a standard/classic jail.
|
||||
|
||||
It is possible to passthrough an entire interface from the host to the jail
|
||||
using the ``-P|--passthrough`` option. This will make the interface fully
|
||||
available without the need for additional configuration. It will be available
|
||||
@@ -37,12 +40,11 @@ network TARGET remove INTERFACE`` while both jails are stopped.
|
||||
|
||||
Options:
|
||||
|
||||
-a | --auto Start/stop the jail(s) if required.
|
||||
-B | --bridge Add a bridged VNET interface to an existing jail.
|
||||
-C | --classic Add an interface to a classic (non-VNET) jail.
|
||||
-M | --static-mac Generate a static MAC address for the interface.
|
||||
-a | --auto Start/stop jail(s) if required.
|
||||
-B | --bridge Add a bridge VNET interface.
|
||||
-M | --static-mac Generate a static MAC address for the interface (VNET only).
|
||||
-n | --no-ip Create interface without an IP (VNET only).
|
||||
-P | --passthrough Pass the entire interface through to the jail.
|
||||
-V | --vnet Add a VNET interface to an existing jail.
|
||||
-v | --vlan VLANID Add interface with specified VLAN ID (VNET only).
|
||||
-P | --passthrough Add a raw interface.
|
||||
-V | --vnet Add a VNET interface.
|
||||
-v | --vlan VLANID Assign VLAN ID to interface (VNET only).
|
||||
-x | --debug Enable debug mode.
|
||||
@@ -42,6 +42,7 @@ usage() {
|
||||
|
||||
Options:
|
||||
|
||||
-a | --auto Auto mode. Start/stop jail(s) if required.
|
||||
--gz Export a ZFS jail using GZIP(.gz) compressed image.
|
||||
-r | --raw Export a ZFS jail to an uncompressed RAW image.
|
||||
-s | --safe Safely stop and start a ZFS jail before the exporting process.
|
||||
@@ -49,6 +50,7 @@ usage() {
|
||||
--txz Export a jail using simple .txz compressed archive instead.
|
||||
-v | --verbose Be more verbose during the ZFS send operation.
|
||||
--xz Export a ZFS jail using XZ(.xz) compressed image.
|
||||
-x | --debug Enable debug mode.
|
||||
|
||||
Note: If no export option specified, the jail should be redirected to standard output.
|
||||
|
||||
@@ -69,6 +71,7 @@ opt_count() {
|
||||
}
|
||||
|
||||
# Reset export options
|
||||
AUTO=0
|
||||
GZIP_EXPORT=
|
||||
XZ_EXPORT=
|
||||
SAFE_EXPORT=
|
||||
@@ -133,6 +136,10 @@ else
|
||||
-h|--help|help)
|
||||
usage
|
||||
;;
|
||||
-a|--auto)
|
||||
AUTO=1
|
||||
shift
|
||||
;;
|
||||
--gz)
|
||||
GZIP_EXPORT="1"
|
||||
opt_count
|
||||
@@ -172,9 +179,15 @@ else
|
||||
enable_debug
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
error_notify "[ERROR]: Unknown Option: \"${1}\""
|
||||
usage
|
||||
-*)
|
||||
for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do
|
||||
case ${_opt} in
|
||||
a) AUTO=1 ;;
|
||||
x) enable_debug ;;
|
||||
*) error_exit "[ERROR]: Unknown Option: \"${1}\""
|
||||
esac
|
||||
done
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
@@ -377,7 +390,8 @@ jail_export() {
|
||||
# Create standard tgz backup archive
|
||||
info "\nExporting '${TARGET}' to a compressed ${FILE_EXT} archive..."
|
||||
|
||||
if ! cd "${bastille_jailsdir}" && tar -cf - "${TARGET}" | gzip ${bastille_compress_gz_options} > "${bastille_backupsdir}/${TARGET}_${DATE}${FILE_EXT}"; then
|
||||
cd "${bastille_jailsdir}" || error_exit "[ERROR]: Failed to change to directory: ${bastille_jailsdir}"
|
||||
if ! tar -cf - "${TARGET}" | gzip ${bastille_compress_gz_options} > "${bastille_backupsdir}/${TARGET}_${DATE}${FILE_EXT}"; then
|
||||
error_exit "[ERROR]: Failed to export jail: ${TARGET}"
|
||||
fi
|
||||
|
||||
@@ -388,7 +402,8 @@ jail_export() {
|
||||
# Create standard txz backup archive
|
||||
info "\nExporting '${TARGET}' to a compressed ${FILE_EXT} archive..."
|
||||
|
||||
if ! cd "${bastille_jailsdir}" && tar -cf - "${TARGET}" | xz ${bastille_compress_xz_options} > "${bastille_backupsdir}/${TARGET}_${DATE}${FILE_EXT}"; then
|
||||
cd "${bastille_jailsdir}" || error_exit "[ERROR]: Failed to change to directory: ${bastille_jailssdir}"
|
||||
if ! tar -cf - "${TARGET}" | xz ${bastille_compress_xz_options} > "${bastille_backupsdir}/${TARGET}_${DATE}${FILE_EXT}"; then
|
||||
error_exit "[ERROR]: Failed to export jail: ${TARGET}"
|
||||
fi
|
||||
|
||||
@@ -402,13 +417,12 @@ jail_export() {
|
||||
error_exit "[ERROR]: Failed to export jail: ${TARGET}"
|
||||
else
|
||||
if [ -z "${USER_EXPORT}" ]; then
|
||||
|
||||
# Generate container checksum file
|
||||
cd "${bastille_backupsdir}" || error_exit "Failed to change directory."
|
||||
sha256 -q "${TARGET}_${DATE}${FILE_EXT}" > "${TARGET}_${DATE}.sha256"
|
||||
|
||||
cd "${bastille_backupsdir}" || error_exit "[ERROR]: Failed to change to directory: ${bastille_backupsdir}"
|
||||
if ! sha256 -q "${TARGET}_${DATE}${FILE_EXT}" > "${TARGET}_${DATE}.sha256"; then
|
||||
error_exit "[ERROR]: Failed to generate sha256 file."
|
||||
fi
|
||||
info "\nExported '${bastille_backupsdir}/${TARGET}_${DATE}${FILE_EXT}' successfully."
|
||||
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -39,14 +39,13 @@ usage() {
|
||||
|
||||
Options:
|
||||
|
||||
-a | --auto Start/stop the jail(s) if required.
|
||||
-B | --bridge Add a bridged VNET interface to an existing jail.
|
||||
-C | --classic Add an interface to a classic (non-VNET) jail.
|
||||
-M | --static-mac Generate a static MAC address for the interface.
|
||||
-a | --auto Start/stop jail(s) if required.
|
||||
-B | --bridge Add a bridge VNET interface.
|
||||
-M | --static-mac Generate a static MAC address for the interface (VNET only).
|
||||
-n | --no-ip Create interface without an IP (VNET only).
|
||||
-P | --passthrough Pass the entire interface through to the jail.
|
||||
-V | --vnet Add a VNET interface to an existing jail.
|
||||
-v | --vlan VLANID Add interface with specified VLAN ID (VNET only).
|
||||
-P | --passthrough Add a raw interface.
|
||||
-V | --vnet Add a VNET interface.
|
||||
-v | --vlan VLANID Assign VLAN ID to interface (VNET only).
|
||||
-x | --debug Enable debug mode.
|
||||
|
||||
EOF
|
||||
@@ -56,8 +55,8 @@ EOF
|
||||
# Handle options.
|
||||
AUTO=0
|
||||
BRIDGE=0
|
||||
CLASSIC=0
|
||||
STATIC_MAC=0
|
||||
STANDARD=0
|
||||
PASSTHROUGH=0
|
||||
VNET=0
|
||||
VLAN_ID=""
|
||||
@@ -75,10 +74,6 @@ while [ "$#" -gt 0 ]; do
|
||||
BRIDGE=1
|
||||
shift
|
||||
;;
|
||||
-C|--classic)
|
||||
CLASSIC=1
|
||||
shift
|
||||
;;
|
||||
-M|--static-mac)
|
||||
STATIC_MAC=1
|
||||
shift
|
||||
@@ -112,7 +107,6 @@ while [ "$#" -gt 0 ]; do
|
||||
case ${_o} in
|
||||
a) AUTO=1 ;;
|
||||
B) BRIDGE=1 ;;
|
||||
C) CLASSIC=1 ;;
|
||||
M) STATIC_MAC=1 ;;
|
||||
n) NO_IP=1 ;;
|
||||
P) PASSTHROUGH=1 ;;
|
||||
@@ -140,16 +134,19 @@ else
|
||||
IP=""
|
||||
fi
|
||||
|
||||
# Default is standard interface
|
||||
if [ "${VNET}" -eq 0 ] && [ "${BRIDGE}" -eq 0 ] && [ "${PASSTHROUGH}" -eq 0 ]; then
|
||||
STANDARD=1
|
||||
fi
|
||||
|
||||
if [ "${ACTION}" = "add" ]; then
|
||||
if { [ "${VNET}" -eq 1 ] && [ "${BRIDGE}" -eq 1 ]; } || \
|
||||
{ [ "${VNET}" -eq 1 ] && [ "${CLASSIC}" -eq 1 ]; } || \
|
||||
{ [ "${VNET}" -eq 1 ] && [ "${STANDARD}" -eq 1 ]; } || \
|
||||
{ [ "${VNET}" -eq 1 ] && [ "${PASSTHROUGH}" -eq 1 ]; } || \
|
||||
{ [ "${BRIDGE}" -eq 1 ] && [ "${CLASSIC}" -eq 1 ]; } || \
|
||||
{ [ "${BRIDGE}" -eq 1 ] && [ "${STANDARD}" -eq 1 ]; } || \
|
||||
{ [ "${BRIDGE}" -eq 1 ] && [ "${PASSTHROUGH}" -eq 1 ]; } || \
|
||||
{ [ "${CLASSIC}" -eq 1 ] && [ "${PASSTHROUGH}" -eq 1 ]; } then
|
||||
error_exit "[ERROR]: Only one of [-B|--bridge], [-C|--classic], [-P|--passthrough] or [-V|--vnet] should be set."
|
||||
elif [ "${VNET}" -eq 0 ] && [ "${BRIDGE}" -eq 0 ] && [ "${CLASSIC}" -eq 0 ] && [ "${PASSTHROUGH}" -eq 0 ]; then
|
||||
error_exit "[ERROR]: [-B|--bridge], [-C|--classic], [-P|--passthrough] or [-V|--vnet] must be set."
|
||||
{ [ "${STANDARD}" -eq 1 ] && [ "${PASSTHROUGH}" -eq 1 ]; } then
|
||||
error_exit "[ERROR]: Only one of [-B|--bridge], [-P|--passthrough] or [-V|--vnet] should be set."
|
||||
elif [ "${VNET}" -eq 0 ] && [ "${BRIDGE}" -eq 0 ] && [ "${PASSTHROUGH}" -eq 0 ] && [ -n "${VLAN_ID}" ]; then
|
||||
error_exit "[ERROR]: VLANs can only be used with VNET interfaces."
|
||||
elif [ "${VNET}" -eq 0 ] && [ "${BRIDGE}" -eq 0 ] && [ "${NO_IP}" -eq 1 ]; then
|
||||
@@ -455,7 +452,7 @@ EOF
|
||||
fi
|
||||
echo "Added Passthrough interface: \"${_if}\""
|
||||
|
||||
elif [ "${CLASSIC}" -eq 1 ]; then
|
||||
elif [ "${STANDARD}" -eq 1 ]; then
|
||||
if [ -n "${IP6_ADDR}" ]; then
|
||||
sed -i '' "s/interface = .*/&\n ip6.addr += ${_if}|${_ip};/" ${_jail_config}
|
||||
else
|
||||
@@ -674,7 +671,7 @@ case "${ACTION}" in
|
||||
if [ "${AUTO}" -eq 1 ]; then
|
||||
bastille start "${TARGET}"
|
||||
fi
|
||||
elif [ "${CLASSIC}" -eq 1 ]; then
|
||||
elif [ "${STANDARD}" -eq 1 ]; then
|
||||
if [ "$(bastille config ${TARGET} get vnet)" != "not set" ]; then
|
||||
error_exit "[ERROR]: ${TARGET} is a VNET jail."
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user