Skip to content

Instantly share code, notes, and snippets.

@dijeesh
Last active August 15, 2016 13:30
Show Gist options
  • Select an option

  • Save dijeesh/2ca76f6cf25110c97a88a281b060b6b6 to your computer and use it in GitHub Desktop.

Select an option

Save dijeesh/2ca76f6cf25110c97a88a281b060b6b6 to your computer and use it in GitHub Desktop.
Bash Script to install XenServer patches
#! /bin/bash
# XenServer Pool Patching Script
set -euo pipefail
readonly PATCHFILE=$1
pushd /root/hotfix >/dev/null || exit 1
readonly HOSTS=$(xe host-list --minimal |tr , ' ')
UUID=$(xe patch-upload file-name="$PATCHFILE")
echo "Patch UUID:"
echo "$UUID"
xe patch-list uuid="$UUID" &>/dev/null || exit 1
echo "Running prechecks:"
for host in $HOSTS; do
echo -e "\t$host"
xe patch-precheck uuid="$UUID" host-uuid="$host"
done
echo "Applying patch to pool"
xe patch-pool-apply uuid="$UUID"
echo "Cleaning patch"
xe patch-pool-clean uuid="$UUID"
xe patch-list uuid="$UUID"
exit
# Usage
#1. Download the script and save /root/hotfix/apply-hotfix.sh
#2. Set permissions for the script chmod +x /root/hotfix/apply-hotfix.sh
#3. Apply Patches ./apply-hotfix.sh <patch.xsupdate>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment