diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2010-08-14 21:12:05 -0400 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2010-08-14 21:12:05 -0400 |
commit | 5a69cb0659dae2bfb481c31a6c57ff4f829225ac (patch) | |
tree | 00f6cf60aa9c11a0972c1f970abc7e0edad5e40d /PCBSD/pc-sysinstall/backend/functions-parse.sh | |
parent | 3fcc3999dacb8e92d22fa68922a0cb07141c481d (diff) | |
download | pfsense-5a69cb0659dae2bfb481c31a6c57ff4f829225ac.zip pfsense-5a69cb0659dae2bfb481c31a6c57ff4f829225ac.tar.gz |
Sync pc-sysinstall with FreeBSD-CURRENT and remove old /PCBSD version. Change installer.php to match new path
Diffstat (limited to 'PCBSD/pc-sysinstall/backend/functions-parse.sh')
-rw-r--r-- | PCBSD/pc-sysinstall/backend/functions-parse.sh | 205 |
1 files changed, 0 insertions, 205 deletions
diff --git a/PCBSD/pc-sysinstall/backend/functions-parse.sh b/PCBSD/pc-sysinstall/backend/functions-parse.sh deleted file mode 100644 index 1fa138d..0000000 --- a/PCBSD/pc-sysinstall/backend/functions-parse.sh +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/sh -# functions.sh -# Library of functions which pc-sysinstall may call upon for parsing the config - -# which gets the value of a setting in the provided line -get_value_from_string() -{ - if [ ! -z "${1}" ] - then - VAL="`echo ${1} | cut -d '=' -f 2`" - export VAL - else - echo "Error: Did we forgot to supply a string to parse?" - exit 1 - fi -}; - -# Get the value from the cfg file including spaces -get_value_from_cfg_with_spaces() -{ - if [ ! -z "${1}" ] - then - VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2` - export VAL - else - exit_err "Error: Did we forgot to supply a setting to grab?" - fi -}; - - -# Get the value from the cfg file -get_value_from_cfg() -{ - if [ ! -z "${1}" ] - then - VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` - export VAL - else - exit_err "Error: Did we forgot to supply a setting to grab?" - fi -}; - -# Checks the value of a setting in the provided line with supplied possibilities -# 1 = setting we are checking, 2 = list of valid values -if_check_value_exists() -{ - if [ ! -z "${1}" -a ! -z "${2}" ] - then - # Get the first occurance of the setting from the config, strip out whitespace - - VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` - if [ -z "${VAL}" ] - then - # This value doesn't exist, lets return - return 0 - fi - - - VALID="1" - for i in ${2} - do - if [ "$VAL" = "${i}" ] - then - VALID="0" - fi - done - if [ "$VALID" = "1" ] - then - exit_err "Error: ${1} is set to unknown value $VAL" - fi - else - exit_err "Error: Did we forgot to supply a string to parse and setting to grab?" - fi -}; - -# Checks the value of a setting in the provided line with supplied possibilities -# 1 = setting we are checking, 2 = list of valid values -check_value() -{ - if [ ! -z "${1}" -a ! -z "${2}" ] - then - # Get the first occurance of the setting from the config, strip out whitespace - VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` - VALID="1" - for i in ${2} - do - if [ "$VAL" = "${i}" ] - then - VALID="0" - fi - done - if [ "$VALID" = "1" ] - then - exit_err "Error: ${1} is set to unknown value $VAL" - fi - else - exit_err "Error: Did we forgot to supply a string to parse and setting to grab?" - fi -}; - -# Checks for the presense of the supplied arguements in the config file -# 1 = values to confirm exist -file_sanity_check() -{ - if [ ! -z "$CFGF" -a ! -z "$1" ] - then - for i in $1 - do - grep "^${i}=" $CFGF >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` - if [ -z "${LN}" ] - then - echo "Error: Config fails sanity test! ${i}= is empty" - exit 1 - fi - else - echo "Error: Config fails sanity test! Missing ${i}=" - exit 1 - fi - done - else - echo "Error: Missing config file, and / or values to sanity check for!" - exit 1 - fi -}; - - -# Function which merges the contents of a new config into the specified old one -# Only works with <val>= type configurations -merge_config() -{ - OLDCFG="${1}" - NEWCFG="${2}" - FINALCFG="${3}" - - # Copy our oldcfg to the new one, which will be used as basis - cp ${OLDCFG} ${FINALCFG} - - # Remove blank lines from new file - cat ${NEWCFG} | sed '/^$/d' > ${FINALCFG}.tmp - - # Set our marker if we've found any - FOUNDMERGE="NO" - - while read newline - do - echo ${newline} | grep "^#" >/dev/null 2>/dev/null - if [ "$?" != "0" ] ; then - VAL="`echo ${newline} | cut -d '=' -f 1`" - cat ${OLDCFG} | grep ${VAL} >/dev/null 2>/dev/null - if [ "$?" != "0" ] ; then - if [ "${FOUNDMERGE}" = "NO" ] ; then - echo "" >> ${FINALCFG} - echo "# Auto-merged values from newer ${NEWCFG}" >> ${FINALCFG} - FOUNDMERGE="YES" - fi - echo "${newline}" >> ${FINALCFG} - fi - fi - done < ${FINALCFG}.tmp - rm ${FINALCFG}.tmp - -}; - -# Loop to check for a specified mount-point in a list -check_for_mount() -{ - MNTS="${1}" - FINDMNT="${2}" - - # Check if we found a valid root partition - for CHECKMNT in `echo ${MNTS} | sed 's|,| |g'` - do - if [ "${CHECKMNT}" = "${FINDMNT}" ] ; then - return 0 - fi - done - - return 1 -}; - -# Function which returns the next line in the specified config file -get_next_cfg_line() -{ - CURFILE="$1" - CURLINE="$2" - - FOUND="1" - - while read line - do - if [ "$FOUND" = "0" ] ; then - VAL="$line" ; export VAL - return - fi - if [ "$line" = "${CURLINE}" ] ; then - FOUND="0" - fi - done <${CURFILE} - - # Got here, couldn't find this line or at end of file, set VAL to "" - VAL="" ; export VAL -}; |