[molecules] add Amazon EC2 ext3-based image generation specs

This commit is contained in:
Fabio Erculiani
2011-07-22 13:40:47 +02:00
parent 1756f52a5c
commit 3621eda846
5 changed files with 260 additions and 0 deletions

19
scripts/image_error_script.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/sh
if [ -d "${CHROOT_DIR}/proc" ]; then
echo "Unmounting ${CHROOT_DIR}/proc"
umount "${CHROOT_DIR}/proc"
fi
CHROOT_PKGS_DIR="${CHROOT_DIR}/var/lib/entropy/client/packages"
if [ -d "${CHROOT_PKGS_DIR}" ]; then
echo "Umounting bind to ${CHROOT_PKGS_DIR}"
umount "${CHROOT_PKGS_DIR}" || exit 1
fi
echo "trying to umount ${CHROOT_DIR}"
umount "${CHROOT_DIR}"
#if [ -n "${LOOP_DEVICE}" ]; then
# echo "trying to umount loop device ${LOOP_DEVICE}"
# /sbin/losetup -d "${LOOP_DEVICE}"
#fi

View File

@@ -0,0 +1,89 @@
#!/bin/sh
echo
echo "Configuring AMI chroot"
echo
/usr/sbin/env-update && source /etc/profile
# setup networking, make sure networkmanager is gone
rc-update del networkmanager default &> /dev/null
# add eth0, should get dhcp by default already
rc-update add net.eth0 default
# drop ufw
rc-update del ufw default
# drop other useless services
rc-update del sabayonlive boot
rc-update del x-setup boot
# Enable ssh
rc-update add sshd default
# setup default root password
echo "root:sabayonamichangeme" | chpasswd
# setup UTC clock
sed -i 's:clock=".*":clock="UTC":' /etc/conf.d/hwclock || exit 1
# setup fstab
# TODO: really needed?
echo "# molecule generated fstab
/dev/sda1 / ext3 defaults 1 1
/dev/sdb /mnt ext3 defaults 0 0
none /dev/shm tmpfs defaults 0 0" > /etc/fstab
echo -5 | equo conf update
mount -t proc proc /proc
export ETP_NONINTERACTIVE=1
# need to install grub-1
equo install sys-boot/grub:0 || exit 1
# remove grub-2
equo remove sys-boot/grub:2 --nodeps --force-system || exit 1
# configure grub-1 config
kernel_bin=$(ls /boot/kernel-genkernel-* | sort | tail -n 1)
# we need a bzImage
#initrd_bin=$(ls /boot/initramfs-genkernel-* | sort | tail -n 1)
rm -f /boot/grub/grub.cfg
echo "default 0
timeout 3
title EC2
root (hd0)
kernel ${kernel_bin} root=/dev/sda1
" > /boot/grub/grub.conf
# initrd ${initrd_bin}
# Generate list of installed packages
equo query list installed -qv > /etc/sabayon-pkglist
/lib/rc/bin/rc-depend -u
echo "Vacuum cleaning client db"
rm /var/lib/entropy/client/database/*/sabayonlinux.org -rf
rm /var/lib/entropy/client/database/*/sabayon-weekly -rf
equo rescue vacuum
# restore original repositories.conf (all mirrors were filtered for speed)
cp /etc/entropy/repositories.conf.example /etc/entropy/repositories.conf || exit 1
# cleanup log dir
rm /var/lib/entropy/logs -rf
# Generate openrc cache
touch /lib/rc/init.d/softlevel
/etc/init.d/savecache start
/etc/init.d/savecache zap
ldconfig
ldconfig
umount /proc
# remove hw hash
rm -f /etc/entropy/.hw.hash