|
|
1d2b07 |
#!/bin/bash
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# cli_getConfigSectionNames.sh -- This function standardizes the way
|
|
|
1d2b07 |
# section names are retrieved from configuration files. Once section
|
|
|
1d2b07 |
# names are retrieved they are printed to standard output for further
|
|
|
1d2b07 |
# processing.
|
|
|
1d2b07 |
#
|
|
|
e6bbbf |
# Copyright (C) 2009-2013 The CentOS Project
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# This program is free software; you can redistribute it and/or modify
|
|
|
1d2b07 |
# it under the terms of the GNU General Public License as published by
|
|
|
1d2b07 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
1d2b07 |
# your option) any later version.
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# This program is distributed in the hope that it will be useful, but
|
|
|
1d2b07 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
1d2b07 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
1d2b07 |
# General Public License for more details.
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# You should have received a copy of the GNU General Public License
|
|
|
1d2b07 |
# along with this program; if not, write to the Free Software
|
|
|
1d2b07 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# ----------------------------------------------------------------------
|
|
|
1d2b07 |
# $Id$
|
|
|
1d2b07 |
# ----------------------------------------------------------------------
|
|
|
1d2b07 |
|
|
|
1d2b07 |
function cli_getConfigSectionNames {
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Define absolute path to configuration file we want to retrieve
|
|
|
1d2b07 |
# section names from.
|
|
|
1d2b07 |
local CONF_FILE=$1
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Verify existence of configuration file.
|
|
|
1d2b07 |
cli_checkFiles $CONF_FILE -f
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Output all section names without brackets, one per line.
|
|
|
1d2b07 |
egrep '^\[[[:alnum:]._-]+\][[:space:]]*$' $CONF_FILE \
|
|
|
1d2b07 |
| sed -r 's/\[(.+)\]/\1/'
|
|
|
1d2b07 |
|
|
|
1d2b07 |
}
|