diff options
Diffstat (limited to 'autocluster')
-rwxr-xr-x | autocluster | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/autocluster b/autocluster index 04070d2..046d383 100755 --- a/autocluster +++ b/autocluster @@ -17,12 +17,16 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. +##BEGIN-INSTALLDIR-MAGIC## +# There are better ways of doing this but not if you still want to be +# able to run straight out of a git tree. :-) if [ -f "$0" ]; then installdir="`dirname \"$0\"`" else autocluster=`which $0` installdir="`dirname \"$autocluster\"`" fi +##END-INSTALLDIR-MAGIC## #################### # show program usage @@ -31,9 +35,19 @@ usage () cat <<EOF Usage: autocluster [OPTION] ... <COMMAND> options: - -c <file> specify config file (default is "config") - -x enable script debugging - --dump dump config settings and exit + -c <file> specify config file (default is "config") +EOF + + local releases=$(echo $(cd $installdir/releases && ls)) + releases="\"${releases// /\", \"}\"" + + usage_smart_display \ + defconf "WITH_RELEASE" "" \ + "<string>" "specify kickstart and yum templates using a release version string. Possible values are: ${releases}." + +cat <<EOF + -x enable script debugging + --dump dump config settings and exit configuration options: EOF @@ -668,7 +682,7 @@ usage_display_text() { } # Display usage information for long config options. -usage_config_options(){( # sub-shell for local declaration of defconf() +usage_smart_display () {( # sub-shell for local declaration of defconf() local def_fillcol=78 local fillcol=$def_fillcol local rows=$(stty size | sed -e 's@.* @@') @@ -686,10 +700,16 @@ usage_config_options(){( # sub-shell for local declaration of defconf() usage_display_text $startcol $fillcol "$4" "$2" } - . "$installdir/config.default" + + "$@" )} +# Display usage information for long config options. +usage_config_options(){ + usage_smart_display . "$installdir/config.default" +} + ###################################################################### . "$installdir/config.default" @@ -697,7 +717,7 @@ usage_config_options(){( # sub-shell for local declaration of defconf() ############################ # parse command line options long_opts=$(getopt_config_options) -getopt_output=$(getopt -n autocluster -o "c:xh" -l help,dump -l "$long_opts" -- "$@") +getopt_output=$(getopt -n autocluster -o "c:xh" -l help,dump,with-release -l "$long_opts" -- "$@") [ $? != 0 ] && usage use_default_config=true @@ -709,6 +729,7 @@ while true ; do case "$1" in -c) shift 2 ; use_default_config=false ;; --) shift ; break ;; + --with-release) shift 2 ;; # Don't set use_default_config=false!!! --dump|-x) shift ;; -h|--help) usage ;; # Usage should be shown here for real defaults. --*) shift 2 ;; # Assume other long opts are valid and take an arg. @@ -723,7 +744,18 @@ eval set -- "$getopt_output" while true ; do case "$1" in - -c) . "`dirname $2`/$2" ; shift 2 ; conf_done=true ;; + -c) . "`dirname $2`/$2" ; shift 2 ;; + --with-release) + # This simply loads an extra config file from $installdir/releases + f="${installdir}/releases/$2" + if [ -r "$f" ] ; then + . "$f" + else + echo "Unknown release \"$2\" specified to --with-release" + exit 1 + fi + shift 2 + ;; -x) set -x; shift ;; --dump) dump_config ;; --) shift ; break ;; @@ -808,5 +840,3 @@ case $command in usage; ;; esac - - |