mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-21 09:41:47 +01:00
Merge branch 'master' into master
This commit is contained in:
@@ -2,15 +2,22 @@
|
||||
convert
|
||||
=======
|
||||
|
||||
To convert a thin container to a thick container use `bastille convert`.
|
||||
Convert a thin jail to a thick jail.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
ishmael ~ # bastille convert azkaban
|
||||
[azkaban]:
|
||||
...
|
||||
|
||||
Syntax requires only the target container to convert.
|
||||
Syntax requires only the target jail to convert.
|
||||
|
||||
.. 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)
|
||||
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
|
||||
;;
|
||||
template)
|
||||
|
||||
@@ -34,21 +34,63 @@
|
||||
. /usr/local/etc/bastille/bastille.conf
|
||||
|
||||
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.
|
||||
case "$1" in
|
||||
help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
# Handle options.
|
||||
AUTO=0
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "${1}" in
|
||||
-h|--help|help)
|
||||
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
|
||||
fi
|
||||
|
||||
TARGET="${1}"
|
||||
|
||||
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() {
|
||||
# Work with the symlinks, revert on first cp error
|
||||
|
||||
@@ -34,7 +34,14 @@
|
||||
. /usr/local/etc/bastille/bastille.conf
|
||||
|
||||
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() {
|
||||
@@ -79,47 +86,68 @@ for _jail in ${JAILS}; do
|
||||
done
|
||||
}
|
||||
|
||||
# Handle special-case commands first.
|
||||
case "$1" in
|
||||
help|-h|--help)
|
||||
|
||||
# Handle options.
|
||||
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
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
TARGET="${1}"
|
||||
ACTION="${2}"
|
||||
|
||||
bastille_root_check
|
||||
set_target "${TARGET}"
|
||||
|
||||
## check ZFS enabled
|
||||
# Check if ZFS is enabled
|
||||
if ! checkyesno bastille_zfs_enable; then
|
||||
error_exit "ZFS not enabled."
|
||||
fi
|
||||
|
||||
## check zpool defined
|
||||
# Check if zpool is defined
|
||||
if [ -z "${bastille_zfs_zpool}" ]; then
|
||||
error_exit "ZFS zpool not defined."
|
||||
fi
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
set)
|
||||
ATTRIBUTE=$2
|
||||
zfs_set_value
|
||||
;;
|
||||
get)
|
||||
ATTRIBUTE=$2
|
||||
zfs_get_value
|
||||
;;
|
||||
snap|snapshot)
|
||||
TAG=$2
|
||||
zfs_snapshot
|
||||
;;
|
||||
destroy_snap|destroy_snapshot)
|
||||
TAG=$2
|
||||
zfs_destroy_snapshot
|
||||
;;
|
||||
df|usage)
|
||||
zfs_disk_usage
|
||||
;;
|
||||
case "${ACTION}" in
|
||||
set)
|
||||
ATTRIBUTE="${3}"
|
||||
zfs_set_value
|
||||
;;
|
||||
get)
|
||||
ATTRIBUTE="${3}"
|
||||
zfs_get_value
|
||||
;;
|
||||
snap|snapshot)
|
||||
TAG="${3}"
|
||||
zfs_snapshot
|
||||
;;
|
||||
destroy_snap|destroy_snapshot)
|
||||
TAG="${3}"
|
||||
zfs_destroy_snapshot
|
||||
;;
|
||||
df|usage)
|
||||
zfs_disk_usage
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user