65 lines
1.2 KiB
Bash
65 lines
1.2 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
WORKDIR=${1}
|
||
|
|
||
|
sys_img=$(find ${WORKDIR} -name "*.img")
|
||
|
provisionDirectory=${2}
|
||
|
|
||
|
if [[ ! -d ${provisionDirectory} ]]
|
||
|
then
|
||
|
mkdir -p ${provisionDirectory}
|
||
|
fi
|
||
|
|
||
|
tmpMntPnt=$(mktemp -d)
|
||
|
tmpWorkDir=$(mktemp -d)
|
||
|
|
||
|
#
|
||
|
# $1 : qcow image
|
||
|
# $2 : mount point
|
||
|
#
|
||
|
function mountQcowImage()
|
||
|
{
|
||
|
guestmount -a $1 -i --ro ${2}
|
||
|
return ${?}
|
||
|
}
|
||
|
|
||
|
function getEoleDbConfig()
|
||
|
{
|
||
|
workdir=${1}
|
||
|
mntPnt=${2}
|
||
|
provisionDir=${3}
|
||
|
|
||
|
cd ${workdir}
|
||
|
cp ${mntPnt}/etc/eole/eole-db.d/* .
|
||
|
mkdir -p ${provisionDir}/etc/eole/eole-db.d
|
||
|
cp * ${provisionDir}/etc/eole/eole-db.d
|
||
|
cd -
|
||
|
|
||
|
}
|
||
|
|
||
|
function processConfiguration()
|
||
|
{
|
||
|
workdir=${1}
|
||
|
mntPnt=${2}
|
||
|
provisionDir=${3}
|
||
|
|
||
|
files=$(awk '/file:/ {gsub(/,|"|\047/,""); print $3}' ${mntPnt}/etc/eole/eole-db.d/*)
|
||
|
|
||
|
for file in ${files}
|
||
|
do
|
||
|
dirname=$(dirname ${file})
|
||
|
dest="${provisionDir}/${dirname}"
|
||
|
mkdir -p ${dest}
|
||
|
cp ${mntPnt}${file} ${dest}
|
||
|
done
|
||
|
}
|
||
|
|
||
|
mountQcowImage ${sys_img} ${tmpMntPnt}
|
||
|
|
||
|
getEoleDbConfig ${tmpWorkDir} ${tmpMntPnt} ${provisionDirectory}
|
||
|
|
||
|
processConfiguration ${tmpWorkDir} ${tmpMntPnt} ${provisionDirectory}
|
||
|
|
||
|
umount ${tmpMntPnt}
|
||
|
rm -rf ${tmpMntPnt}
|
||
|
#rm -rf ${tmpWorkDir}
|