
Allows for faster configuration in known environments Signed-off-by: Robert Baldyga <robert.baldyga@intel.com> Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
54 lines
1.2 KiB
Bash
Executable File
54 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright(c) 2012-2019 Intel Corporation
|
|
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
|
#
|
|
|
|
check_util() {
|
|
which $1 2>&1 > /dev/null || { echo >&2 "Error: missing '$1' utility"; exit 1; }
|
|
}
|
|
|
|
check_util dirname
|
|
check_util realpath
|
|
check_util basename
|
|
check_util awk
|
|
|
|
SCRIPTPATH=`dirname $0`
|
|
SCRIPTPATH=`realpath $SCRIPTPATH`
|
|
|
|
CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf | sort`
|
|
FILES_COUNT=`echo $CONFIG_FILES | wc -w`
|
|
|
|
generate_config() {
|
|
rm -f config.out
|
|
progress=0
|
|
for file in $CONFIG_FILES; do
|
|
progress=$((progress+1))
|
|
echo -ne "Generating configuration: $progress/$FILES_COUNT\033[0K\r"
|
|
CONF="$(/bin/bash $file "check")"
|
|
echo "$(basename $file) $CONF" >> config.out
|
|
done
|
|
echo ""
|
|
}
|
|
|
|
generate_header() {
|
|
rm -f $SCRIPTPATH/modules/generated_defines.h
|
|
progress=0
|
|
for file in $CONFIG_FILES; do
|
|
progress=$((progress+1))
|
|
echo -ne "Configuring OpenCAS: $progress/$FILES_COUNT\033[0K\r"
|
|
CONF=$(cat config.out | awk -v file=$(basename $file) '{ if ($1 == file) print $2 }')
|
|
/bin/bash $file "apply" "$CONF"
|
|
done
|
|
echo ""
|
|
}
|
|
|
|
if [ -z "$1" ]; then
|
|
generate_config
|
|
CONFIG_FILE="config.out"
|
|
else
|
|
CONFIG_FILE="$1"
|
|
fi
|
|
|
|
generate_header
|