Skip to content

Instantly share code, notes, and snippets.

@mAster-rAdio
Last active January 11, 2017 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mAster-rAdio/0e9a4f482cfd6ad2b6913bf091088c5e to your computer and use it in GitHub Desktop.
Save mAster-rAdio/0e9a4f482cfd6ad2b6913bf091088c5e to your computer and use it in GitHub Desktop.
fork from patones/XenServer-Patcher-bash, exclude download list & sort list
#!/bin/sh
base_dir=`dirname $0`
patch_list="${base_dir}/patch_list.txt"
cd ${base_dir}
cat ${patch_list} | while read name url time uuid; do
# Save some typing
export short_url=`basename ${url}`
# Check to see if the patch has been installed already
if [ -n "`xe patch-list name-label=${name} 2> /dev/null`" ]; then
echo "${name} has aleady been installed"
else
# Check to see if the file already exists
if [ -f "${short_url}" ]; then
# Skips the file
echo "${short_url} already exists skipping download"
/bin/rm -f ${name}-src-pkgs.tar.* ${name}.xsupdate
xe patch-pool-clean uuid=${uuid}
xe patch-clean uuid=${uuid}
else
# Downloads the file and unzip it
echo "Downloading ${short_url}"
curl -#kLR "${url}" -o "${short_url}"
echo "Download Completed"
fi
# Unzip
echo "Unziping ${short_url}"
unzip -oq ${short_url}
# Upload to Xen Server
echo "Uploading to Xen Server"
xe patch-upload file-name=${name}.xsupdate
echo "Applying Patch"
xe patch-pool-apply uuid=${uuid}
echo "Verifying Installation"
if [ -n "`xe patch-list name-label=${name} 2> /dev/null`" ]; then
# Removing src xsupdate and cleaning with patch clean
echo "${name} has been installed successfully"
echo "Removing installation files"
/bin/rm -f ${name}-src-pkgs.tar.* ${name}.xsupdate
xe patch-pool-clean uuid=${uuid}
xe patch-clean uuid=${uuid}
else
echo "${name} Failed to Install please check it manually. Please fix the issue and run this program again"
# Remove patch for you to fix the issue and try again
/bin/rm -fr "/opt/xensource/patch-backup/${time}"
exit 0
fi
fi
done
@mAster-rAdio
Copy link
Author

@mAster-rAdio
Copy link
Author

Patching order

@mAster-rAdio
Copy link
Author

[TODO]

  • Checking md5sum
    • get ctx* page by curl and grep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment