Merge branch 'master' into master

This commit is contained in:
tschettervictor
2025-02-23 12:18:38 -07:00
committed by GitHub
5 changed files with 135 additions and 44 deletions

View File

@@ -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

View File

@@ -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