| # read-conf {filename} {parameter name} [default value] |
| local value=`grep ^${2} ${1} | cut -d "=" -f 2 | sed -e 's/^[ \t]*//'` |
| if [ -z "${value}" ]; then |
| # revert "filename" from "filename.bak" if "filename.tmp" exists. |
| local temp="${filename}.tmp" |
| local backup="${filename}.bak" |
| if [ -f "${temp}" ]; then |
| echo -n "reverting ${filename} ... " |
| # create-conf-interactive {filename} {function to create conf} [param to function] |
| function create-conf-interactive { |
| local filename=`basename ${filepath}` |
| if [ -f ${filepath} ]; then |
| # confirmation to overwrite existing config file |
| echo -n "Overwriting ${filename} [Y/n]? " |
| if [ -z "${key}" -o "${key}" == "Y" -o "${key}" == "y" ]; then |
| elif [ "${key}" == "N" -o "${key}" == "n" ]; then |
| # begin-conf-creation {config file name} |
| function begin-conf-creation { |
| local backup="${conf}.bak" |
| local filename=`basename ${backup}` |
| # end-conf-creation {config file name} |
| function end-conf-creation { |