removed bad prep.sh, added correct prep.sh and renamed to cloud-prep.sh
old script was the qcow generation script renamed to cloud-prep.sh to be more clear as to it's purpose
This commit is contained in:
parent
6e2cef0da1
commit
65df2e34bf
6 changed files with 83 additions and 83 deletions
79
releases/weekly/scripts/cloud-prep.sh
Normal file
79
releases/weekly/scripts/cloud-prep.sh
Normal file
|
@ -0,0 +1,79 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Set timezone
|
||||
echo 'UTC' > /etc/timezone
|
||||
|
||||
# Set locale
|
||||
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
|
||||
echo 'en_US ISO-8859-1' >> /etc/locale.gen
|
||||
locale-gen
|
||||
eselect locale set en_US.utf8
|
||||
|
||||
# Some rootfs stuff
|
||||
grep -v rootfs /proc/mounts > /etc/mtab
|
||||
|
||||
# This is set in rackspaces prep, might help us
|
||||
echo 'net.ipv4.conf.eth0.arp_notify = 1' >> /etc/sysctl.conf
|
||||
echo 'vm.swappiness = 0' >> /etc/sysctl.conf
|
||||
|
||||
# Let's configure out grub
|
||||
mkdir /boot/grub
|
||||
echo 'GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"' >> /etc/default/grub
|
||||
grub2-mkconfig -o /boot/grub/grub.cfg
|
||||
sed -r -i 's/loop[0-9]+p1/vda2/g' /boot/grub/grub.cfg
|
||||
sed -i 's/UUID=[a-z,0-9,-]*/\/dev\/vda2/g' /boot/grub/grub.cfg
|
||||
|
||||
# And the fstab
|
||||
echo '/dev/vda2 / ext4 defaults 0 0' > /etc/fstab
|
||||
|
||||
# allow the console log
|
||||
sed -i 's/#s0/s0/g' /etc/inittab
|
||||
|
||||
# let ipv6 use normal slaac
|
||||
sed -i 's/slaac/#slaac/g' /etc/dhcpcd.conf
|
||||
# don't let dhcpcd set domain name or hostname
|
||||
sed -i 's/domain_name\,\ domain_search\,\ host_name/domain_search/g' /etc/dhcpcd.conf
|
||||
|
||||
# need to do this here because it clobbers an openrc owned file
|
||||
cat > /etc/conf.d/hostname << "EOL"
|
||||
# Set to the hostname of this machine
|
||||
if [ -f /etc/hostname ];then
|
||||
hostname=$(cat /etc/hostname 2> /dev/null | cut -d"." -f1 2> /dev/null)
|
||||
else
|
||||
hostname="localhost"
|
||||
fi
|
||||
EOL
|
||||
chmod 0644 /etc/conf.d/hostname
|
||||
chown root:root /etc/conf.d/hostname
|
||||
|
||||
# set a nice default for /etc/resolv.conf
|
||||
cat > /etc/resolv.conf << EOL
|
||||
nameserver 8.8.8.8
|
||||
EOL
|
||||
|
||||
# let's upgrade (security fixes and otherwise)
|
||||
USE="-build" emerge -uDNv --with-bdeps=y --jobs=2 @world
|
||||
USE="-build" emerge --verbose=n --depclean
|
||||
USE="-build" emerge -v --usepkg=n @preserved-rebuild
|
||||
etc-update --automode -3
|
||||
|
||||
# Clean up portage
|
||||
emerge --verbose=n --depclean
|
||||
eix-update
|
||||
emaint all -f
|
||||
eselect news read all
|
||||
eclean-dist --destructive
|
||||
sed -i '/^USE=\"\${USE}\ \ build\"$/d' /etc/portage/make.conf
|
||||
|
||||
# clean up system
|
||||
passwd -d root
|
||||
passwd -l root
|
||||
rm -f /usr/portage/distfiles/*
|
||||
rm -f /etc/ssh/ssh_host_*
|
||||
rm -f /root/.bash_history
|
||||
rm -f /root/.nano_history
|
||||
rm -f /root/.lesshst
|
||||
rm -f /root/.ssh/known_hosts
|
||||
rm -f /usr/src/linux
|
||||
for i in $(find /var/log -type f); do echo > $i; done
|
||||
for i in $(find /tmp -type f); do rm -f $i; done
|
|
@ -1,79 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Okay, so here's some real meat. We take a drive (as 02 said, I use a VM),
|
||||
# and we spray that stage4 all over it. Then we rub some grub (0.97) all over
|
||||
# it to make it feel better, and then we box it up and ship it out.
|
||||
|
||||
set -e -u -x -o pipefail
|
||||
|
||||
# Vars
|
||||
export TEMP_DIR=${TEMP_DIR:-'/root/tmp/catalyst/gentoo'}
|
||||
export MOUNT_DIR=${MOUNT_DIR:-'/mnt'}
|
||||
export DATE=${DATE:-"$(date +%Y%m%d)"}
|
||||
export PORTAGE_DIR=${PORTAGE_DIR:-"/var/tmp/catalyst/snapshots"}
|
||||
# profiles supported are as follows
|
||||
# default/linux/amd64/13.0
|
||||
# default/linux/amd64/13.0/no-multilib
|
||||
# hardened/linux/amd64
|
||||
# hardened/linux/amd64/no-multilib
|
||||
# hardened/linux/amd64/selinux (eventually)
|
||||
# hardened/linux/amd64/no-multilib/selinux (eventually)
|
||||
export PROFILE=${PROFILE:-"default/linux/amd64/13.0"}
|
||||
if [[ "${PROFILE}" == "default/linux/amd64/13.0" ]]; then
|
||||
PROFILE_SHORTNAME="amd64-default"
|
||||
elif [[ "${PROFILE}" == "default/linux/amd64/13.0/no-multilib" ]]; then
|
||||
PROFILE_SHORTNAME="amd64-default-nomultilib"
|
||||
elif [[ "${PROFILE}" == "hardened/linux/amd64" ]]; then
|
||||
PROFILE_SHORTNAME="amd64-hardened"
|
||||
elif [[ "${PROFILE}" == "hardened/linux/amd64/no-multilib" ]]; then
|
||||
PROFILE_SHORTNAME="amd64-hardened-nomultilib"
|
||||
else
|
||||
echo 'invalid profile, exiting'
|
||||
exit 1
|
||||
fi
|
||||
export TARBALL=${TARBALL:-"/root/tmp/catalyst/gentoo/stage4-${PROFILE_SHORTNAME}-${DATE}.tar.bz2"}
|
||||
export TEMP_IMAGE=${TEMP_IMAGE:-"gentoo-${PROFILE_SHORTNAME}.img"}
|
||||
export TARGET_IMAGE=${TARGET_IMAGE:-"/root/openstack-${PROFILE_SHORTNAME}-${DATE}.qcow2"}
|
||||
|
||||
# create a raw partition and do stuff with it
|
||||
fallocate -l 5G "${TEMP_DIR}/${TEMP_IMAGE}"
|
||||
BLOCK_DEV=$(losetup -f --show "${TEMP_DIR}/${TEMP_IMAGE}")
|
||||
|
||||
# Okay, we have the disk, let's prep it
|
||||
echo 'Building disk'
|
||||
parted -s "${BLOCK_DEV}" mklabel gpt
|
||||
parted -s --align=none "${BLOCK_DEV}" mkpart bios_boot 0 2M
|
||||
parted -s --align=none "${BLOCK_DEV}" mkpart primary 2M 100%
|
||||
parted -s "${BLOCK_DEV}" set 1 boot on
|
||||
parted -s "${BLOCK_DEV}" set 1 bios_grub on
|
||||
mkfs.ext4 -F "${BLOCK_DEV}p2"
|
||||
|
||||
# Mount it
|
||||
echo 'Mounting disk'
|
||||
mkdir -p "${MOUNT_DIR}/${PROFILE_SHORTNAME}"
|
||||
mount "${BLOCK_DEV}p2" "${MOUNT_DIR}/${PROFILE_SHORTNAME}"
|
||||
|
||||
# Expand the stage
|
||||
echo 'Expanding tarball'
|
||||
tar --xattrs -xjpf "${TARBALL}" -C "${MOUNT_DIR}/${PROFILE_SHORTNAME}"
|
||||
|
||||
echo 'Adding in /usr/portage'
|
||||
tar --xattrs -xjpf "${PORTAGE_DIR}/portage-latest.tar.bz2" -C "${MOUNT_DIR}/${PROFILE_SHORTNAME}/usr"
|
||||
|
||||
# Install grub
|
||||
echo 'Installing grub'
|
||||
grub2-install "${BLOCK_DEV}" --boot-directory "${MOUNT_DIR}/${PROFILE_SHORTNAME}/boot"
|
||||
|
||||
# Clean up
|
||||
echo 'Syncing; unmounting'
|
||||
sync
|
||||
umount "${MOUNT_DIR}/${PROFILE_SHORTNAME}"
|
||||
|
||||
# get rid of block mapping
|
||||
losetup -d "${BLOCK_DEV}"
|
||||
|
||||
echo 'Converting raw image to qcow2'
|
||||
qemu-img convert -c -f raw -O qcow2 "${TEMP_DIR}/${TEMP_IMAGE}" "${TARGET_IMAGE}"
|
||||
|
||||
echo 'Cleaning up'
|
||||
rm "${TEMP_DIR}/${TEMP_IMAGE}"
|
|
@ -36,7 +36,7 @@ stage4/packages:
|
|||
sys-devel/bc
|
||||
sys-power/acpid
|
||||
sys-process/cronie
|
||||
stage4/fsscript: /release/releng/releases/weekly/scripts/prep.sh
|
||||
stage4/fsscript: /release/releng/releases/weekly/scripts/cloud-prep.sh
|
||||
stage4/root_overlay: /release/releng/releases/weekly/overlays/cloud-overlay
|
||||
stage4/rcadd:
|
||||
acpid|default
|
||||
|
|
|
@ -36,7 +36,7 @@ stage4/packages:
|
|||
sys-devel/bc
|
||||
sys-power/acpid
|
||||
sys-process/cronie
|
||||
stage4/fsscript: /release/releng/releases/weekly/scripts/prep.sh
|
||||
stage4/fsscript: /release/releng/releases/weekly/scripts/cloud-prep.sh
|
||||
stage4/root_overlay: /release/releng/releases/weekly/overlays/cloud-overlay
|
||||
stage4/rcadd:
|
||||
acpid|default
|
||||
|
|
|
@ -36,7 +36,7 @@ stage4/packages:
|
|||
sys-devel/bc
|
||||
sys-power/acpid
|
||||
sys-process/cronie
|
||||
stage4/fsscript: /release/releng/releases/weekly/scripts/prep.sh
|
||||
stage4/fsscript: /release/releng/releases/weekly/scripts/cloud-prep.sh
|
||||
stage4/root_overlay: /release/releng/releases/weekly/overlays/cloud-overlay
|
||||
stage4/rcadd:
|
||||
acpid|default
|
||||
|
|
|
@ -36,7 +36,7 @@ stage4/packages:
|
|||
sys-devel/bc
|
||||
sys-power/acpid
|
||||
sys-process/cronie
|
||||
stage4/fsscript: /release/releng/releases/weekly/scripts/prep.sh
|
||||
stage4/fsscript: /release/releng/releases/weekly/scripts/cloud-prep.sh
|
||||
stage4/root_overlay: /release/releng/releases/weekly/overlays/cloud-overlay
|
||||
stage4/rcadd:
|
||||
acpid|default
|
||||
|
|
Loading…
Add table
Reference in a new issue