[3bbf6d5] | 1 |
|
---|
[c0aeabe] | 2 | # $Id$
|
---|
[3bbf6d5] | 3 |
|
---|
[22670f4] | 4 | #----------------------------#
|
---|
| 5 | validate_config() { # Are the config values sane (within reason)
|
---|
| 6 | #----------------------------#
|
---|
| 7 | : <<inline_doc
|
---|
[3bbf6d5] | 8 | Validates the configuration parameters. The global var PROGNAME selects the
|
---|
[22670f4] | 9 | parameter list.
|
---|
[3bbf6d5] | 10 |
|
---|
[1b9148c] | 11 | input vars: $1 0/1 0=quiet, 1=verbose output
|
---|
[22670f4] | 12 | externals: color constants
|
---|
| 13 | PROGNAME (lfs,clfs,hlfs,blfs)
|
---|
| 14 | modifies: none
|
---|
| 15 | returns: nothing
|
---|
| 16 | on error: write text to console and dies
|
---|
| 17 | on success: write text to console and returns
|
---|
| 18 | inline_doc
|
---|
| 19 |
|
---|
[3f858ca] | 20 | local -r lfs_PARAM_LIST=""
|
---|
[22670f4] | 21 | local -r blfs_PARAM_LIST="BUILDDIR TEST DEPEND"
|
---|
[3f858ca] | 22 | local -r hlfs_PARAM_LIST="MODEL GRSECURITY_HOST"
|
---|
| 23 | local -r clfs_PARAM_LIST="ARCH BOOTMINIMAL"
|
---|
[12a5707] | 24 | local -r global_PARAM_LIST="BUILDDIR HPKG RUNMAKE TEST STRIP PAGE TIMEZONE VIMLANG"
|
---|
[22670f4] | 25 |
|
---|
| 26 | local -r ERROR_MSG='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid, ${nl_}check the config file ${BOLD}${GREEN}\<$PROGNAME.conf\>${OFF}'
|
---|
| 27 | local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
| 28 |
|
---|
| 29 | local PARAM_LIST=
|
---|
| 30 |
|
---|
| 31 | local config_param
|
---|
| 32 | local validation_str
|
---|
[3bbf6d5] | 33 |
|
---|
[22670f4] | 34 | write_error_and_die() {
|
---|
| 35 | echo -e "\n${DD_BORDER}"
|
---|
| 36 | echo -e "`eval echo ${ERROR_MSG}`" >&2
|
---|
| 37 | echo -e "${DD_BORDER}\n"
|
---|
| 38 | exit 1
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | set +e
|
---|
| 42 | for PARAM_GROUP in global_PARAM_LIST ${PROGNAME}_PARAM_LIST; do
|
---|
| 43 | for config_param in ${!PARAM_GROUP}; do
|
---|
| 44 | # This is a tricky little piece of code.. executes a cmd string.
|
---|
| 45 | [[ $1 = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
|
---|
| 46 | case $config_param in
|
---|
| 47 | BUILDDIR) # We cannot have an <empty> or </> root mount point
|
---|
| 48 | if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
|
---|
| 49 | write_error_and_die
|
---|
| 50 | fi
|
---|
| 51 | continue ;;
|
---|
| 52 | TIMEZONE) continue;;
|
---|
| 53 | MKFILE) continue;;
|
---|
| 54 | HPKG) validation_str="x0x x1x" ;;
|
---|
| 55 | RUNMAKE) validation_str="x0x x1x" ;;
|
---|
[12a5707] | 56 | TEST) validation_str="x0x x1x x2x x3x" ;;
|
---|
[22670f4] | 57 | STRIP) validation_str="x0x x1x" ;;
|
---|
| 58 | VIMLANG) validation_str="x0x x1x" ;;
|
---|
| 59 | DEPEND) validation_str="x0x x1x x2x" ;;
|
---|
| 60 | MODEL) validation_str="xglibcx xuclibcx" ;;
|
---|
| 61 | PAGE) validation_str="xletterx xA4x" ;;
|
---|
| 62 | ARCH) validation_str="xx86x xx86_64x xx86_64-64x xsparcx xsparcv8x xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xalphax" ;;
|
---|
| 63 | GRSECURITY_HOST) validation_str="x0x x1x" ;;
|
---|
| 64 | BOOTMINIMAL) validation_str="x0x x1x";;
|
---|
| 65 | *)
|
---|
| 66 | echo "WHAT PARAMETER IS THIS.. <<${config_param}>>"
|
---|
| 67 | exit
|
---|
| 68 | ;;
|
---|
| 69 | esac
|
---|
| 70 | #
|
---|
| 71 | # This is the 'regexp' test available in bash-3.0..
|
---|
| 72 | # using it as a poor man's test for substring
|
---|
| 73 | if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
|
---|
| 74 | # parameter value entered is no good
|
---|
| 75 | write_error_and_die
|
---|
| 76 | fi
|
---|
| 77 | done # for loop
|
---|
| 78 |
|
---|
| 79 | # Not further tests needed on globals
|
---|
| 80 | if [[ "$PARAM_GROUP" = "global_PARAM_LIST" ]]; then
|
---|
| 81 | echo " ${BOLD}${GREEN}${PARAM_GROUP%%_*T} parameters are valid${OFF}"
|
---|
| 82 | continue
|
---|
| 83 | fi
|
---|
[3bbf6d5] | 84 |
|
---|
[22670f4] | 85 | for config_param in LC_ALL LANG; do
|
---|
| 86 | [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
| 87 | [[ -z "${!config_param}" ]] && continue
|
---|
| 88 | # See it the locale values exist on this machine
|
---|
| 89 | [[ "`locale -a | grep -c ${!config_param}`" > 0 ]] && continue
|
---|
[3bbf6d5] | 90 |
|
---|
[22670f4] | 91 | # If you make it this far then there is a problem
|
---|
| 92 | write_error_and_die
|
---|
| 93 | done
|
---|
| 94 |
|
---|
| 95 | for config_param in FSTAB CONFIG KEYMAP BOOK; do
|
---|
| 96 | [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
| 97 | if [[ $config_param = BOOK ]]; then
|
---|
| 98 | [[ ! "${WC}" = 1 ]] && continue
|
---|
| 99 | fi
|
---|
| 100 | [[ -z "${!config_param}" ]] && continue
|
---|
| 101 | [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue
|
---|
[3bbf6d5] | 102 |
|
---|
[22670f4] | 103 | # If you make it this far then there is a problem
|
---|
| 104 | write_error_and_die
|
---|
| 105 | done
|
---|
| 106 | echo " ${BOLD}${GREEN}${PARAM_GROUP%%_*T} parameters are valid${OFF}"
|
---|
| 107 | done
|
---|
| 108 | set -e
|
---|
| 109 | echo "$tab_***${BOLD}${GREEN}Config parameters look good${OFF}***"
|
---|
| 110 | }
|
---|