Merge branch 'master' of https://github.com/tschettervictor/bastille into doc-examples-and-updates

This commit is contained in:
tschettervictor
2025-04-20 14:03:39 -06:00
2 changed files with 21 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
config config
====== ======
Get or set properties for targeted jail(s). Get,set or remove properties from targeted jail(s).
Getting a property that *is* defined in jail.conf: Getting a property that *is* defined in jail.conf:
@@ -26,10 +26,19 @@ Setting a property:
The restart message will appear every time a property is set. The restart message will appear every time a property is set.
Removing a property:
.. code-block:: shell
ishmael ~ # bastille config azkaban remove allow.mlock
A restart is required for the changes to be applied. See 'bastille restart azkaban'.
The restart message will appear every time a property is removed.
.. code-block:: shell .. code-block:: shell
ishmael ~ # bastille config help ishmael ~ # bastille config help
Usage: bastille config TARGET [get|set] PROPERTY_NAME NEW_VALUE Usage: bastille config TARGET [get|set|remove] PROPERTY [VALUE]
Options: Options:
-x | --debug Enable debug mode. -x | --debug Enable debug mode.

View File

@@ -34,7 +34,7 @@
usage() { usage() {
error_notify "Usage: bastille config TARGET [get|set] PROPERTY_NAME NEW_VALUE" error_notify "Usage: bastille config TARGET [get|set|remove] PROPERTY [VALUE]"
cat << EOF cat << EOF
Options: Options:
@@ -87,9 +87,9 @@ shift 2
set_target "${TARGET}" set_target "${TARGET}"
case "${ACTION}" in case "${ACTION}" in
get) get|remove)
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
error_notify 'Too many parameters for a "get" operation.' error_notify 'Too many parameters for [get|remove] operation.'
usage usage
fi fi
;; ;;
@@ -183,6 +183,12 @@ for _jail in ${JAILS}; do
else else
echo "${_output}" echo "${_output}"
fi fi
elif [ "${ACTION}" = "remove" ]; then
if [ "$(bastille config ${_jail} get ${PROPERTY})" != "not set" ]; then
sed -i '' "/.*${PROPERTY}.*/d" "${FILE}"
else
error_exit "Value not present in jail.conf: ${PROPERTY}"
fi
else # Setting the value. -- cwells else # Setting the value. -- cwells
if [ -n "${VALUE}" ]; then if [ -n "${VALUE}" ]; then
VALUE=$(echo "${VALUE}" | sed 's/\//\\\//g') VALUE=$(echo "${VALUE}" | sed 's/\//\\\//g')
@@ -233,7 +239,7 @@ for _jail in ${JAILS}; do
done done
# Only display this message once at the end (not for every jail). -- cwells # Only display this message once at the end (not for every jail). -- cwells
if [ "${ACTION}" = 'set' ] && [ -z "${BASTILLE_PROPERTY}" ]; then if { [ "${ACTION}" = "set" ] || [ "${ACTION}" = "remove" ]; } && [ -z "${BASTILLE_PROPERTY}" ]; then
info "A restart is required for the changes to be applied. See 'bastille restart'." info "A restart is required for the changes to be applied. See 'bastille restart'."
fi fi