mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-22 18:21:53 +01:00
Merge pull request #865 from tschettervictor/config-new-functions
Config new functions
This commit is contained in:
@@ -2,18 +2,14 @@
|
||||
config
|
||||
=======
|
||||
|
||||
Gets or sets properties for a target container.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
Usage: bastille config TARGET get|set propertyName [newValue]
|
||||
Get or set properties for targeted jail(s).
|
||||
|
||||
Getting a property that *is* defined in jail.conf:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
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
|
||||
|
||||
@@ -26,7 +22,16 @@ Setting a property:
|
||||
|
||||
.. 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'.
|
||||
|
||||
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)
|
||||
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
|
||||
;;
|
||||
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
|
||||
if [ $# -eq 0 ]; then # No target was given, so show the command's help. -- cwells
|
||||
PARAMS='help'
|
||||
|
||||
@@ -34,7 +34,14 @@
|
||||
. /usr/local/etc/bastille/bastille.conf
|
||||
|
||||
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
|
||||
@@ -46,37 +53,65 @@ print_jail_conf() {
|
||||
'
|
||||
}
|
||||
|
||||
# Handle special-case commands first.
|
||||
case "$1" in
|
||||
help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
# 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 [ $# -eq 1 ] || [ $# -gt 3 ]; then
|
||||
if [ "$#" -lt 1 ] || [ "$#" -gt 3 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
bastille_root_check
|
||||
|
||||
ACTION=$1
|
||||
shift
|
||||
TARGET="${1}"
|
||||
ACTION="${2}"
|
||||
shift 2
|
||||
|
||||
case $ACTION in
|
||||
set_target "${TARGET}"
|
||||
|
||||
case "${ACTION}" in
|
||||
get)
|
||||
if [ $# -ne 1 ]; then
|
||||
if [ "$#" -ne 1 ]; then
|
||||
error_notify 'Too many parameters for a "get" operation.'
|
||||
usage
|
||||
fi
|
||||
;;
|
||||
set) ;;
|
||||
*) error_exit 'Only get and set are supported.' ;;
|
||||
set)
|
||||
;;
|
||||
*)
|
||||
error_exit 'Only get and set are supported.'
|
||||
;;
|
||||
esac
|
||||
|
||||
PROPERTY=$1
|
||||
PROPERTY="${1}"
|
||||
shift
|
||||
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
|
||||
FILE="${bastille_jailsdir}/${_jail}/jail.conf"
|
||||
if [ ! -f "${FILE}" ]; then
|
||||
@@ -93,6 +128,7 @@ for _jail in ${JAILS}; do
|
||||
# check if there is a value for this property
|
||||
if (NF == 2) {
|
||||
# remove any quotes surrounding the string
|
||||
#sub(",[^|]*\\|", ",", $2);
|
||||
sub(/^"/, "", $2);
|
||||
sub(/"$/, "", $2);
|
||||
print $2;
|
||||
|
||||
Reference in New Issue
Block a user