mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-21 17:52:01 +01:00
Merge branch 'master' into master
This commit is contained in:
@@ -2,15 +2,22 @@
|
|||||||
convert
|
convert
|
||||||
=======
|
=======
|
||||||
|
|
||||||
To convert a thin container to a thick container use `bastille convert`.
|
Convert a thin jail to a thick jail.
|
||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
ishmael ~ # bastille convert azkaban
|
ishmael ~ # bastille convert azkaban
|
||||||
[azkaban]:
|
[azkaban]:
|
||||||
|
...
|
||||||
|
|
||||||
Syntax requires only the target container to convert.
|
Syntax requires only the target jail to convert.
|
||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
Usage: bastille convert TARGET
|
ishmael ~ # bastille convert help
|
||||||
|
Usage: bastille convert [option(s)] TARGET
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
-a | --auto Auto mode. Start/stop jail(s) if required.
|
||||||
|
-x | --debug Enable debug mode.
|
||||||
|
|||||||
14
docs/chapters/subcommands/zfs.rst
Normal file
14
docs/chapters/subcommands/zfs.rst
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
===
|
||||||
|
zfs
|
||||||
|
===
|
||||||
|
|
||||||
|
Manage ZFS properties, ceate and destroy snapshots, and check ZFS usage for targeted jail(s).
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
ishmael ~ # bastille zfs help
|
||||||
|
Usage: bastille zfs TARGET [set|get|snap|destroy_snap|df|usage] [key=value|date]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
-x | --debug Enable debug mode.
|
||||||
@@ -165,7 +165,7 @@ version|-v|--version)
|
|||||||
help|-h|--help)
|
help|-h|--help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
bootstrap|clone|cmd|config|console|create|cp|destroy|edit|etcupdate|export|htop|import|jcp|list|mount|pkg|rcp|rdr|rename|restart|service|setup|start|stop|sysrc|top|umount|update|upgrade|verify)
|
bootstrap|clone|cmd|config|console|convert|create|cp|destroy|edit|etcupdate|export|htop|import|jcp|list|mount|pkg|rcp|rdr|rename|restart|service|setup|start|stop|sysrc|top|umount|update|upgrade|verify|zfs)
|
||||||
# Nothing "extra" to do for these commands. -- cwells
|
# Nothing "extra" to do for these commands. -- cwells
|
||||||
;;
|
;;
|
||||||
template)
|
template)
|
||||||
|
|||||||
@@ -34,21 +34,63 @@
|
|||||||
. /usr/local/etc/bastille/bastille.conf
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
error_exit "Usage: bastille convert TARGET"
|
error_notify "Usage: bastille convert [option(s)] TARGET"
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
Options:
|
||||||
|
|
||||||
|
-a | --auto Auto mode. Start/stop jail(s) if required.
|
||||||
|
-x | --debug Enable debug mode.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle special-case commands first.
|
# Handle options.
|
||||||
case "$1" in
|
AUTO=0
|
||||||
help|-h|--help)
|
while [ "$#" -gt 0 ]; do
|
||||||
usage
|
case "${1}" in
|
||||||
;;
|
-h|--help|help)
|
||||||
esac
|
usage
|
||||||
|
;;
|
||||||
|
-a|--auto)
|
||||||
|
AUTO=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-x|--debug)
|
||||||
|
enable_debug
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do
|
||||||
|
case ${_opt} in
|
||||||
|
a) AUTO=1 ;;
|
||||||
|
x) enable_debug ;;
|
||||||
|
*) error_exit "Unknown Option: \"${1}\"" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ $# -ne 0 ]; then
|
if [ "$#" -ne 1 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
TARGET="${1}"
|
||||||
|
|
||||||
bastille_root_check
|
bastille_root_check
|
||||||
|
set_target_single "${TARGET}"
|
||||||
|
check_target_is_stopped "${TARGET}" || if [ "${AUTO}" -eq 1 ]; then
|
||||||
|
bastille stop "${TARGET}"
|
||||||
|
else
|
||||||
|
error_notify "Jail is running."
|
||||||
|
error_exit "Use [-a|--auto] to auto-stop the jail."
|
||||||
|
fi
|
||||||
|
|
||||||
convert_symlinks() {
|
convert_symlinks() {
|
||||||
# Work with the symlinks, revert on first cp error
|
# Work with the symlinks, revert on first cp error
|
||||||
|
|||||||
@@ -34,7 +34,14 @@
|
|||||||
. /usr/local/etc/bastille/bastille.conf
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
error_exit "Usage: bastille zfs TARGET [set|get|snap] [key=value|date]'"
|
error_notify "Usage: bastille zfs TARGET [set|get|snap|destroy_snap|df|usage] [key=value|date]"
|
||||||
|
cat << EOF
|
||||||
|
Options:
|
||||||
|
|
||||||
|
-x | --debug Enable debug mode.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
zfs_snapshot() {
|
zfs_snapshot() {
|
||||||
@@ -79,47 +86,68 @@ for _jail in ${JAILS}; do
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle special-case commands first.
|
|
||||||
case "$1" in
|
# Handle options.
|
||||||
help|-h|--help)
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case "${1}" in
|
||||||
|
-h|--help|help)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
-x|--debug)
|
||||||
|
enable_debug
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
error_notify "Unknown Option: \"${1}\""
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$#" -lt 2 ]; then
|
||||||
usage
|
usage
|
||||||
;;
|
fi
|
||||||
esac
|
|
||||||
|
TARGET="${1}"
|
||||||
|
ACTION="${2}"
|
||||||
|
|
||||||
bastille_root_check
|
bastille_root_check
|
||||||
|
set_target "${TARGET}"
|
||||||
|
|
||||||
## check ZFS enabled
|
# Check if ZFS is enabled
|
||||||
if ! checkyesno bastille_zfs_enable; then
|
if ! checkyesno bastille_zfs_enable; then
|
||||||
error_exit "ZFS not enabled."
|
error_exit "ZFS not enabled."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## check zpool defined
|
# Check if zpool is defined
|
||||||
if [ -z "${bastille_zfs_zpool}" ]; then
|
if [ -z "${bastille_zfs_zpool}" ]; then
|
||||||
error_exit "ZFS zpool not defined."
|
error_exit "ZFS zpool not defined."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
case "${ACTION}" in
|
||||||
usage
|
set)
|
||||||
fi
|
ATTRIBUTE="${3}"
|
||||||
|
zfs_set_value
|
||||||
case "$1" in
|
;;
|
||||||
set)
|
get)
|
||||||
ATTRIBUTE=$2
|
ATTRIBUTE="${3}"
|
||||||
zfs_set_value
|
zfs_get_value
|
||||||
;;
|
;;
|
||||||
get)
|
snap|snapshot)
|
||||||
ATTRIBUTE=$2
|
TAG="${3}"
|
||||||
zfs_get_value
|
zfs_snapshot
|
||||||
;;
|
;;
|
||||||
snap|snapshot)
|
destroy_snap|destroy_snapshot)
|
||||||
TAG=$2
|
TAG="${3}"
|
||||||
zfs_snapshot
|
zfs_destroy_snapshot
|
||||||
;;
|
;;
|
||||||
destroy_snap|destroy_snapshot)
|
df|usage)
|
||||||
TAG=$2
|
zfs_disk_usage
|
||||||
zfs_destroy_snapshot
|
;;
|
||||||
;;
|
*)
|
||||||
df|usage)
|
usage
|
||||||
zfs_disk_usage
|
;;
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user