From 9efcf913e7c2017f6e54f7505acb69afab39954b Mon Sep 17 00:00:00 2001 From: Jason Mehring Date: Sun, 9 Nov 2014 12:52:35 -0500 Subject: [PATCH] debian: Modified template install script to read better --- create_template_list.sh | 67 ++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/create_template_list.sh b/create_template_list.sh index 2ede209..7d4fb07 100755 --- a/create_template_list.sh +++ b/create_template_list.sh @@ -1,48 +1,53 @@ #!/bin/bash +# vim: set ts=4 sw=4 sts=4 et : # # Creates a small script to copy to dom0 to retrieve the generated template rpm's # -TEMPLATES="./rpm/install-templates.sh" +template_dir="$(readlink -m ./rpm/install-templates.sh)" +files=( $(ls rpm/noarch) ) +name=$($XENSTORE_READ name) -write() { - echo "$1" >> "$TEMPLATES" -} +# ----------------------------------------------------------------------------- +# Write $vars +# ----------------------------------------------------------------------------- +cat << EOF > "${template_dir}" +#!/bin/bash -if [ -x /usr/sbin/xenstore-read ]; then - XENSTORE_READ="/usr/sbin/xenstore-read" -else - XENSTORE_READ="/usr/bin/xenstore-read" -fi +# Use the following command in DOM0 to retreive this file: +# qvm-run --pass-io ${name} 'cat ${template_dir}' > install-templates.sh -TEMPLATES="$(readlink -m $TEMPLATES)" -VERSION="-$(cat ./version)" -name=$($XENSTORE_READ name) -path="$(readlink -m .)" -files=$(ls rpm/noarch) +files=" +$(printf "%s \n" ${files[@]}) +" -# -# Write to install-templates -# +path="$(readlink -m .)/rpm/noarch" +version="-$(cat ./version)" +EOF -echo "#!/bin/bash" > "$TEMPLATES" -write "" +# ----------------------------------------------------------------------------- +# Write installation function +# ----------------------------------------------------------------------------- +cat << 'EOF' >> "${template_dir}" for file in ${files[@]}; do - write "qvm-run --pass-io development-qubes 'cat ${path}/rpm/noarch/${file}' > ${file}" - write "" - write "sudo yum erase $(echo "$file" | sed -r "s/($VERSION).+$//")" - write "" - write "sudo yum install ${file}" - write "" - write "" + if [ ! -e ${file} ]; then + qvm-run --pass-io development-qubes "cat ${path}/${file}" > ${file} + fi + + sudo yum erase $(echo "${file}" | sed -r "s/(${version}).+$//") && { + sudo yum install ${file} && { + rm -f ${file} + } + } done - -write "# Use the following command in DOM0 to retreive this file:" -write "# qvm-run --pass-io $name 'cat ${TEMPLATES}' > install-templates.sh" - +EOF + +# ----------------------------------------------------------------------------- +# Display instructions +# ----------------------------------------------------------------------------- echo "Use the following command in DOM0 to retreive this file:" -echo "qvm-run --pass-io $name 'cat ${TEMPLATES}' > install-templates.sh" +echo "qvm-run --pass-io ${name} 'cat ${template_dir}' > install-templates.sh"