Last active
August 15, 2016 13:30
-
-
Save dijeesh/2ca76f6cf25110c97a88a281b060b6b6 to your computer and use it in GitHub Desktop.
Bash Script to install XenServer patches
This file contains hidden or 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 | |
| # 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