Created
July 22, 2014 09:43
-
-
Save paulrobinson/be28a0c24cbbde677e3e to your computer and use it in GitHub Desktop.
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 | |
| NEW_VERSION=$1 | |
| if [ "${#NEW_VERSION}" != "3" ]; then | |
| echo "usage: $0 <new image version (must be 3 digits)>" | |
| exit 1 | |
| fi | |
| NEW_IMAGE_PATH=/vm/base-$NEW_VERSION.img | |
| if [ -e $NEW_IMAGE_PATH ]; then | |
| echo "File already exists: $NEW_IMAGE_PATH" | |
| exit 2 | |
| fi | |
| # Make sure only root can run our script | |
| if [ "$(id -u)" != "0" ]; then | |
| echo "This script must be run as root" 1>&2 | |
| exit 1 | |
| fi | |
| echo "Waiting for osprey-00 to become offline..." | |
| java -jar jenkins-cli.jar -s http://jenkins.mw.lab.eng.bos.redhat.com/hudson/ wait-node-offline osprey-00 | |
| echo "osprey-00 is now offline" | |
| NODE=osprey-00 | |
| if [ "$(virsh list | grep $NODE)" != "" ]; then | |
| virsh shutdown $NODE | |
| fi | |
| while [ "$(virsh list | grep $NODE)" != "" ]; do | |
| echo "Waiting for $NODE to shutdown..." | |
| sleep 2 | |
| done | |
| rsync -r -v --progress /vm/osprey-00.img $NEW_IMAGE_PATH | |
| kpartx -a $NEW_IMAGE_PATH | |
| pvscan | |
| vgchange -a y rhel | |
| mount /dev/rhel/root /mnt/tmp | |
| rm /mnt/tmp/etc/hostname | |
| rm -rf /mnt/tmp/tmp/* | |
| echo $NEW_VERSION > /mnt/tmp/etc/image-version | |
| umount /mnt/tmp | |
| vgchange -a n rhel | |
| pvscan | |
| kpartx -d $NEW_IMAGE_PATH | |
| virsh start osprey-00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment