mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-23 18:50:46 +01:00
Merge pull request #865 from tschettervictor/config-new-functions
Config new functions
This commit is contained in:
@@ -2,18 +2,14 @@
|
|||||||
config
|
config
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Gets or sets properties for a target container.
|
Get or set properties for targeted jail(s).
|
||||||
|
|
||||||
.. code-block:: shell
|
|
||||||
|
|
||||||
Usage: bastille config TARGET get|set propertyName [newValue]
|
|
||||||
|
|
||||||
Getting a property that *is* defined in jail.conf:
|
Getting a property that *is* defined in jail.conf:
|
||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
ishmael ~ # bastille config azkaban get ip4.addr
|
ishmael ~ # bastille config azkaban get ip4.addr
|
||||||
192.168.2.23
|
bastille0|192.168.2.23
|
||||||
|
|
||||||
Getting a property that *is not* defined in jail.conf
|
Getting a property that *is not* defined in jail.conf
|
||||||
|
|
||||||
@@ -26,7 +22,16 @@ Setting a property:
|
|||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
ishmael ~ # bastille config azkaban set ip4.addr 192.168.2.24
|
ishmael ~ # bastille config azkaban set allow.mlock 1
|
||||||
A restart is required for the changes to be applied. See 'bastille restart azkaban'.
|
A restart is required for the changes to be applied. See 'bastille restart azkaban'.
|
||||||
|
|
||||||
The restart message will appear every time a property is set.
|
The restart message will appear every time a property is set.
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
ishmael ~ # bastille config help
|
||||||
|
Usage: bastille config TARGET [get|set] PROPERTY_NAME NEW_VALUE
|
||||||
|
Options:
|
||||||
|
|
||||||
|
-x | --debug Enable debug mode.
|
||||||
|
|
||||||
|
|||||||
@@ -165,10 +165,10 @@ version|-v|--version)
|
|||||||
help|-h|--help)
|
help|-h|--help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
bootstrap|clone|console|create|cp|destroy|edit|etcupdate|export|htop|import|jcp|list|mount|pkg|rcp|rdr|rename|restart|setup|start|stop|top|umount|update|upgrade|verify)
|
bootstrap|clone|config|console|create|cp|destroy|edit|etcupdate|export|htop|import|jcp|list|mount|pkg|rcp|rdr|rename|restart|setup|start|stop|top|umount|update|upgrade|verify)
|
||||||
# Nothing "extra" to do for these commands. -- cwells
|
# Nothing "extra" to do for these commands. -- cwells
|
||||||
;;
|
;;
|
||||||
config|cmd|convert|limits|service|sysrc|tags|template|zfs)
|
cmd|convert|limits|service|sysrc|tags|template|zfs)
|
||||||
# Parse the target and ensure it exists. -- cwells
|
# Parse the target and ensure it exists. -- cwells
|
||||||
if [ $# -eq 0 ]; then # No target was given, so show the command's help. -- cwells
|
if [ $# -eq 0 ]; then # No target was given, so show the command's help. -- cwells
|
||||||
PARAMS='help'
|
PARAMS='help'
|
||||||
|
|||||||
@@ -34,7 +34,14 @@
|
|||||||
. /usr/local/etc/bastille/bastille.conf
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
error_exit "Usage: bastille config TARGET get|set propertyName [newValue]"
|
error_notify "Usage: bastille config TARGET [get|set] PROPERTY_NAME NEW_VALUE"
|
||||||
|
cat << EOF
|
||||||
|
Options:
|
||||||
|
|
||||||
|
-x | --debug Enable debug mode.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# we need jail(8) to parse the config file so it can expand variables etc
|
# we need jail(8) to parse the config file so it can expand variables etc
|
||||||
@@ -46,37 +53,65 @@ print_jail_conf() {
|
|||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle special-case commands first.
|
# Handle options.
|
||||||
case "$1" in
|
while [ "$#" -gt 0 ]; do
|
||||||
help|-h|--help)
|
case "${1}" in
|
||||||
|
-h|--help|help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
esac
|
-x|--debug)
|
||||||
|
enable_debug
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
error_notify "Unknown Option: \"${1}\""
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ $# -eq 1 ] || [ $# -gt 3 ]; then
|
if [ "$#" -lt 1 ] || [ "$#" -gt 3 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bastille_root_check
|
bastille_root_check
|
||||||
|
|
||||||
ACTION=$1
|
TARGET="${1}"
|
||||||
shift
|
ACTION="${2}"
|
||||||
|
shift 2
|
||||||
|
|
||||||
case $ACTION in
|
set_target "${TARGET}"
|
||||||
|
|
||||||
|
case "${ACTION}" in
|
||||||
get)
|
get)
|
||||||
if [ $# -ne 1 ]; then
|
if [ "$#" -ne 1 ]; then
|
||||||
error_notify 'Too many parameters for a "get" operation.'
|
error_notify 'Too many parameters for a "get" operation.'
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
set) ;;
|
set)
|
||||||
*) error_exit 'Only get and set are supported.' ;;
|
;;
|
||||||
|
*)
|
||||||
|
error_exit 'Only get and set are supported.'
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
PROPERTY=$1
|
PROPERTY="${1}"
|
||||||
shift
|
shift
|
||||||
VALUE="$@"
|
VALUE="$@"
|
||||||
|
|
||||||
|
# we need jail(8) to parse the config file so it can expand variables etc
|
||||||
|
print_jail_conf() {
|
||||||
|
|
||||||
|
# we need to pass a literal \n to jail to get each parameter on its own
|
||||||
|
# line
|
||||||
|
jail -f "${1}" -e '
|
||||||
|
'
|
||||||
|
}
|
||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
FILE="${bastille_jailsdir}/${_jail}/jail.conf"
|
FILE="${bastille_jailsdir}/${_jail}/jail.conf"
|
||||||
if [ ! -f "${FILE}" ]; then
|
if [ ! -f "${FILE}" ]; then
|
||||||
@@ -93,6 +128,7 @@ for _jail in ${JAILS}; do
|
|||||||
# check if there is a value for this property
|
# check if there is a value for this property
|
||||||
if (NF == 2) {
|
if (NF == 2) {
|
||||||
# remove any quotes surrounding the string
|
# remove any quotes surrounding the string
|
||||||
|
#sub(",[^|]*\\|", ",", $2);
|
||||||
sub(/^"/, "", $2);
|
sub(/^"/, "", $2);
|
||||||
sub(/"$/, "", $2);
|
sub(/"$/, "", $2);
|
||||||
print $2;
|
print $2;
|
||||||
|
|||||||
Reference in New Issue
Block a user