Skip to content

Instantly share code, notes, and snippets.

@th3architect
Forked from ei-grad/ghe-lxc-image
Created January 23, 2017 01:25
Show Gist options
  • Save th3architect/66892947d8adf897a462cb0e997625f8 to your computer and use it in GitHub Desktop.
Save th3architect/66892947d8adf897a462cb0e997625f8 to your computer and use it in GitHub Desktop.
Script to convert Github Enterprise OVA image to tar.gz for LXC.
#!/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