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 | |
# based on https://access.redhat.com/documentation/en-us/red_hat_virtualization/4.1/html-single/installation_guide/#Automating_RHVH_Deployment | |
SOURCEDIR=/var/lib/pulp/tmp | |
isofile=$1 | |
isopath=$SOURCEDIR/$isofile | |
DESTDIR=/mnt/$isofile | |
if [ ! -e $isopath ]; then | |
echo Please ensure file $isofile exists in $SOURCEDIR . | |
exit 1 | |
fi | |
echo Mounting $isopath in $DESTDIR ... | |
mkdir -p $DESTDIR | |
umount $DESTDIR 2> /dev/null | |
mount -o loop $isopath $DESTDIR | |
if [ ! -e $DESTDIR/LiveOS ]; then | |
echo "It seems ISO $isofile could not be mounted properly, or it isn't a RHV iso" | |
exit 1 | |
fi | |
echo "Copying ISO contents to /var/www/html/pub/$isofile ..." | |
if [ -e /var/www/html/pub/$isofile/LiveOS ]; then | |
rm -rf /var/www/html/pub/$isofile | |
fi | |
mkdir -p /var/www/html/pub/$isofile | |
cp -r $DESTDIR/* /var/www/html/pub/$isofile | |
echo -e Extracting redhat-virtualization-host-image-update ... | |
cd /tmp | |
rpm2cpio $DESTDIR/Packages/redhat-virtualization-host-image-update*rpm | cpio -idmv || exit 1 | |
echo OK | |
echo -e Copying squash.img to public directory . Available as http://$HOSTNAME/pub/$isofile/squashfs.img ... | |
mkdir -p /var/www/html/pub/$isofile | |
cp /tmp/usr/share/redhat-virtualization-host/image/*.squashfs.img /var/www/html/pub/$isofile/squashfs.img || exit 1 | |
rm -rf /tmp/usr | |
# copy vmlinuz and initrd.img to tftp directory | |
echo -e Copying $DESTDIR/images/pxeboot/{vmlinuz,initrd.img} to /var/lib/tftpboot/$isofile ... | |
mkdir -p /var/lib/tftpboot/$isofile | |
cp $DESTDIR/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/$isofile || exit 1 | |
echo OK | |
echo Unmounting $DESTDIR | |
umount $DESTDIR || exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment