[molecules] Add Amazon EC2 EBS Sabayon filesystem images for amd64 and x86
This commit is contained in:
30
scripts/amazon_ebs_image_inner_chroot_script.sh
Executable file
30
scripts/amazon_ebs_image_inner_chroot_script.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
# make sure there is no stale pid file around that prevents entropy from running
|
||||
rm -f /var/run/entropy/entropy.lock
|
||||
|
||||
export FORCE_EAPI=2
|
||||
equo update
|
||||
if [ "${?}" != "0" ]; then
|
||||
sleep 1200 || exit 1
|
||||
equo update || exit 1
|
||||
fi
|
||||
|
||||
# disable all mirrors but GARR
|
||||
for repo_conf in /etc/entropy/repositories.conf /etc/entropy/repositories.conf.d/entropy_*; do
|
||||
# skip .example files
|
||||
if [[ "${repo_conf}" =~ .*\.example$ ]]; then
|
||||
echo "skipping ${repo_conf}"
|
||||
continue
|
||||
fi
|
||||
sed -n -e "/pkg.sabayon.org/p" -e "/garr.it/p" -e "/^branch/p" \
|
||||
-e "/^product/p" -e "/^official-repository-id/p" -e "/^differential-update/p" \
|
||||
-i "${repo_conf}"
|
||||
done
|
||||
|
||||
# mask icedtea and icedtea-bin, waiting to have virtual/jre-1.7.0 and
|
||||
# dev-java/oracle-jre-bin in Entropy
|
||||
# Once there, remove this script and use "remaster_generic_inner_chroot_script.sh"
|
||||
# instead.
|
||||
equo mask "dev-java/icedtea-bin"
|
||||
equo mask "dev-java/icedtea"
|
||||
102
scripts/amazon_ebs_image_inner_chroot_script_after.sh
Executable file
102
scripts/amazon_ebs_image_inner_chroot_script_after.sh
Executable file
@@ -0,0 +1,102 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo
|
||||
echo "Configuring AMI root filesystem"
|
||||
echo "Ext4 is the expected filesystem type"
|
||||
echo "/dev/sda1 is the expected root filesystem partition"
|
||||
echo "ec2-user is the expected user"
|
||||
echo
|
||||
|
||||
/usr/sbin/env-update
|
||||
. /etc/profile
|
||||
|
||||
# setup networking, make sure networkmanager is gone
|
||||
rc-update del NetworkManager boot
|
||||
rc-update del NetworkManager default
|
||||
# add eth0, should get dhcp by default already
|
||||
rc-update add net.eth0 default
|
||||
|
||||
# drop other useless services
|
||||
rc-update del sabayonlive boot
|
||||
rc-update del x-setup boot
|
||||
|
||||
# Enable ssh
|
||||
rc-update add sshd default
|
||||
|
||||
# delete root password, only ssh allowed
|
||||
passwd -d root
|
||||
|
||||
# create ec2-user
|
||||
useradd -d /home/ec2-user -k /etc/skel -g users -G wheel,disk,crontab -m ec2-user || exit 1
|
||||
|
||||
# enable passwordless sudo for ec2-user
|
||||
echo -e "\n# molecule generated rule\nec2-user ALL=NOPASSWD: ALL" >> /etc/sudoers
|
||||
|
||||
# setup UTC clock
|
||||
sed -i 's:clock=".*":clock="UTC":' /etc/conf.d/hwclock || exit 1
|
||||
|
||||
# setup fstab
|
||||
echo "# molecule generated fstab
|
||||
/dev/sda1 / ext4 defaults 1 1
|
||||
none /dev/shm tmpfs defaults 0 0" > /etc/fstab
|
||||
|
||||
# setup networking, reset /etc/conf.d/net
|
||||
echo > /etc/conf.d/net
|
||||
|
||||
echo -5 | equo conf update
|
||||
mount -t proc proc /proc
|
||||
|
||||
export ETP_NONINTERACTIVE=1
|
||||
|
||||
# setup kernel
|
||||
eselect bzimage set 1 || exit 1
|
||||
|
||||
rm -f /boot/grub/grub.{cfg,conf}*
|
||||
echo "
|
||||
default=0
|
||||
fallback=1
|
||||
timeout=3
|
||||
hiddenmenu
|
||||
|
||||
title Sabayon Linux AMI (PV)
|
||||
root (hd0)
|
||||
kernel /boot/bzImage root=/dev/sda1 console=hvc0 rootfstype=ext4
|
||||
initrd /boot/Initrd
|
||||
" > /boot/grub/grub.conf
|
||||
|
||||
# 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
|
||||
for repo_conf in /etc/entropy/repositories.conf.d/entropy_*.example; do
|
||||
new_repo_conf="${repo_conf%.example}"
|
||||
cp "${repo_conf}" "${new_repo_conf}"
|
||||
done
|
||||
|
||||
# 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
|
||||
# remove entropy pid file
|
||||
rm -f /var/run/entropy/entropy.lock
|
||||
|
||||
exit 0
|
||||
10
scripts/amazon_ebs_image_pre_tar_script.sh
Executable file
10
scripts/amazon_ebs_image_pre_tar_script.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copy packages list outside tarball
|
||||
pkglist_file="${CHROOT_DIR}/etc/sabayon-pkglist"
|
||||
if [ -f "${pkglist_file}" ]; then
|
||||
tar_dirname=$(dirname "${TAR_PATH}")
|
||||
if [ -d "${tar_dirname}" ]; then
|
||||
cp "${pkglist_file}" "${TAR_PATH}.pkglist"
|
||||
fi
|
||||
fi
|
||||
16
scripts/amazon_ebs_image_remaster_post.sh
Executable file
16
scripts/amazon_ebs_image_remaster_post.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
# execute parent script
|
||||
/sabayon/scripts/remaster_post.sh
|
||||
if [ "${?}" != "0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Setup provisioning script for Amazon EC2 to load at startup
|
||||
EC2_DIR="/sabayon/remaster/ec2_image"
|
||||
PROV_SCRIPT="ebs.ec2.start"
|
||||
cp -p "${EC2_DIR}/${PROV_SCRIPT}" "${CHROOT_DIR}/etc/local.d/" || exit 1
|
||||
chown root:root "${CHROOT_DIR}/etc/local.d/${PROV_SCRIPT}" || exit 1
|
||||
chmod 744 "${CHROOT_DIR}/etc/local.d/${PROV_SCRIPT}" || exit 1
|
||||
|
||||
exit 0
|
||||
@@ -65,13 +65,17 @@ if [ "${ACTION}" = "weekly" ]; then
|
||||
"Sabayon_Linux_DAILY_amd64_ForensicsXfce.iso"
|
||||
"Sabayon_Linux_DAILY_x86_ForensicsXfce.iso"
|
||||
)
|
||||
REMASTER_OPENVZ_SPECS=(
|
||||
REMASTER_TAR_SPECS=(
|
||||
"sabayon-x86-spinbase-openvz-template.spec"
|
||||
"sabayon-amd64-spinbase-openvz-template.spec"
|
||||
"sabayon-x86-spinbase-amazon-ebs-image.spec"
|
||||
"sabayon-amd64-spinbase-amazon-ebs-image.spec"
|
||||
)
|
||||
REMASTER_OPENVZ_SPECS_TAR=(
|
||||
REMASTER_TAR_SPECS_TAR=(
|
||||
"Sabayon_Linux_SpinBase_DAILY_x86_openvz.tar.gz"
|
||||
"Sabayon_Linux_SpinBase_DAILY_amd64_openvz.tar.gz"
|
||||
"Sabayon_Linux_SpinBase_DAILY_x86_Amazon_EBS_ext4_filesystem_image.tar.gz"
|
||||
"Sabayon_Linux_SpinBase_DAILY_x86_Amazon_EBS_ext4_filesystem_image.tar.gz"
|
||||
)
|
||||
elif [ "${ACTION}" = "daily" ]; then
|
||||
ARM_SOURCE_SPECS=()
|
||||
@@ -119,8 +123,8 @@ elif [ "${ACTION}" = "daily" ]; then
|
||||
"Sabayon_Linux_ServerBase_DAILY_amd64.iso"
|
||||
"Sabayon_Linux_ServerBase_DAILY_x86.iso"
|
||||
)
|
||||
REMASTER_OPENVZ_SPECS=()
|
||||
REMASTER_OPENVZ_SPECS_TAR=()
|
||||
REMASTER_TAR_SPECS=()
|
||||
REMASTER_TAR_SPECS_TAR=()
|
||||
fi
|
||||
|
||||
[[ -d "/sabayon/molecules/daily" ]] || mkdir -p /sabayon/molecules/daily
|
||||
@@ -205,17 +209,17 @@ build_sabayon() {
|
||||
remaster_specs+="${dst} "
|
||||
done
|
||||
|
||||
for i in ${!REMASTER_OPENVZ_SPECS[@]}
|
||||
for i in ${!REMASTER_TAR_SPECS[@]}
|
||||
do
|
||||
src="/sabayon/molecules/${REMASTER_OPENVZ_SPECS[i]}"
|
||||
dst="/sabayon/molecules/daily/remaster/${REMASTER_OPENVZ_SPECS[i]}"
|
||||
src="/sabayon/molecules/${REMASTER_TAR_SPECS[i]}"
|
||||
dst="/sabayon/molecules/daily/remaster/${REMASTER_TAR_SPECS[i]}"
|
||||
cp "${src}" "${dst}" -p || return 1
|
||||
# tweak tar name
|
||||
sed -i "s/^#.*tar_name/tar_name:/" "${dst}" || return 1
|
||||
sed -i "s/tar_name.*/tar_name: ${REMASTER_OPENVZ_SPECS_TAR[i]}/" "${dst}" || return 1
|
||||
sed -i "s/tar_name.*/tar_name: ${REMASTER_TAR_SPECS_TAR[i]}/" "${dst}" || return 1
|
||||
# tweak release version
|
||||
sed -i "s/release_version.*/release_version: ${CUR_DATE}/" "${dst}" || return 1
|
||||
echo "${dst}: tar: ${REMASTER_OPENVZ_SPECS_TAR[i]} date: ${CUR_DATE}"
|
||||
echo "${dst}: tar: ${REMASTER_TAR_SPECS_TAR[i]} date: ${CUR_DATE}"
|
||||
remaster_specs+="${dst} "
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user