Created
March 11, 2013 17:18
-
-
Save ei-grad/5135864 to your computer and use it in GitHub Desktop.
Script to convert Github Enterprise OVA image to tar.gz for LXC.
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 | |
[ "`whoami`" != "root" ] && echo "Should be run by root!" && exit 1 | |
[ -e *.vmdk ] || ( echo Extracting VMDK image from *.ova ... ; tar xf *.ova ) | |
[ -e github.img ] || ( echo Converting *.vmdk to raw image ... ; qemu-img convert *.vmdk github.img ) | |
echo Preparing mounts ... | |
losetup -f github.img -P | |
vgchange -ay enterprise-11 | |
mkdir -p root/rootfs | |
cd root | |
mount /dev/enterprise-11/root rootfs | |
cd rootfs | |
mount /dev/loop0p1 boot | |
# XXX: configure network, rc hacks, etc. | |
#... | |
cd ../ # change dir to one which contain the 'rootfs' directory | |
echo "Creating github.tgz ..." | |
tar czf ../github.tgz . | |
echo "Umounting ..." | |
cd ../ | |
umount root/rootfs/boot && umount root/rootfs && rm -r root/rootfs root | |
vgchange -an enterprise-11 | |
losetup -d /dev/loop0 | |
echo Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment