Last active
August 29, 2015 14:25
-
-
Save tstone2077/3dfef8353ccd3b2f2d44 to your computer and use it in GitHub Desktop.
Apply patches from a text file of urls onto a xen server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function failOnError { | |
RETVAL=$1 | |
ErrorText=$2 | |
if [[ $RETVAL -ne 0 ]]; then | |
echo $2 | |
exit $RETVAL | |
fi | |
} | |
for url in `cat patch_urls.txt`; do | |
echo "--------------------------------------------------" | |
mkdir tmp | |
pushd tmp | |
echo "### Downloading and applying $url..." | |
wget --no-check-certificate $url -O patch.zip | |
failOnError $? "wget failed: $url" | |
echo "### Unzipping...." | |
unzip patch.zip | |
failOnError $? "unzip failed" | |
file=`ls *.xsupdate` | |
echo "### Uploading patch..." | |
UUID=`xe patch-upload file-name=$file` | |
failOnError $? "xe patch-upload file-name=$file [FAILED]" | |
echo "### Applying patch to the pool..." | |
xe patch-pool-apply uuid=$UUID | |
failOnError $? "xe patch-pool-apply uuid=$UUID [FAILED]" | |
popd | |
echo "### Deleting tmp dir and /var/patch file..." | |
rm -rf tmp | |
find /var/patch/ -maxdepth 1 -type f -exec rm -f {} \; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment