2014-10-18 12:59:21 +00:00
|
|
|
#!/bin/bash
|
2014-11-09 17:52:35 +00:00
|
|
|
# vim: set ts=4 sw=4 sts=4 et :
|
2014-10-18 12:59:21 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Creates a small script to copy to dom0 to retrieve the generated template rpm's
|
|
|
|
#
|
|
|
|
|
2014-11-09 17:52:35 +00:00
|
|
|
template_dir="$(readlink -m ./rpm/install-templates.sh)"
|
|
|
|
files=( $(ls rpm/noarch) )
|
2014-11-09 18:24:08 +00:00
|
|
|
name=$(xenstore-read name)
|
2014-10-18 12:59:21 +00:00
|
|
|
|
2014-11-09 17:52:35 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Write $vars
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
cat << EOF > "${template_dir}"
|
|
|
|
#!/bin/bash
|
2014-10-18 12:59:21 +00:00
|
|
|
|
2014-11-09 17:52:35 +00:00
|
|
|
# Use the following command in DOM0 to retreive this file:
|
|
|
|
# qvm-run --pass-io ${name} 'cat ${template_dir}' > install-templates.sh
|
2014-10-18 12:59:21 +00:00
|
|
|
|
2014-11-09 17:52:35 +00:00
|
|
|
files="
|
|
|
|
$(printf "%s \n" ${files[@]})
|
|
|
|
"
|
2014-10-18 12:59:21 +00:00
|
|
|
|
2014-11-09 17:52:35 +00:00
|
|
|
path="$(readlink -m .)/rpm/noarch"
|
|
|
|
version="-$(cat ./version)"
|
2014-11-11 14:00:54 +00:00
|
|
|
name="${name}"
|
2014-11-09 17:52:35 +00:00
|
|
|
EOF
|
2014-10-18 14:53:11 +00:00
|
|
|
|
2014-11-09 17:52:35 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Write installation function
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
cat << 'EOF' >> "${template_dir}"
|
2014-10-18 14:53:11 +00:00
|
|
|
|
2014-10-18 12:59:21 +00:00
|
|
|
for file in ${files[@]}; do
|
2014-11-09 17:52:35 +00:00
|
|
|
if [ ! -e ${file} ]; then
|
2014-11-11 14:00:54 +00:00
|
|
|
echo "Copying ${file} from ${name} to ${PWD}/${file}..."
|
2014-11-17 21:39:02 +00:00
|
|
|
qvm-run --pass-io ${name} "cat ${path}/${file}" > ${file}
|
2014-11-09 17:52:35 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
sudo yum erase $(echo "${file}" | sed -r "s/(${version}).+$//") && {
|
|
|
|
sudo yum install ${file} && {
|
|
|
|
rm -f ${file}
|
|
|
|
}
|
|
|
|
}
|
2014-10-18 12:59:21 +00:00
|
|
|
done
|
2014-11-09 17:52:35 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Display instructions
|
|
|
|
# -----------------------------------------------------------------------------
|
2014-10-18 12:59:21 +00:00
|
|
|
echo "Use the following command in DOM0 to retreive this file:"
|
2014-11-09 17:52:35 +00:00
|
|
|
echo "qvm-run --pass-io ${name} 'cat ${template_dir}' > install-templates.sh"
|
2014-10-18 12:59:21 +00:00
|
|
|
|
|
|
|
|