2012-07-24 16:13:17 +02:00
|
|
|
#!/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
|
2012-07-29 16:26:02 +02:00
|
|
|
# Enable cron
|
|
|
|
rc-update add vixie-cron default
|
2012-07-24 16:13:17 +02:00
|
|
|
|
|
|
|
# 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
|
2012-07-29 12:35:33 +02:00
|
|
|
LABEL=/ / ext4 defaults 1 1
|
2012-07-24 16:13:17 +02:00
|
|
|
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)
|
2012-07-25 17:29:18 +02:00
|
|
|
kernel /boot/bzImage root=LABEL=/ console=hvc0 rootfstype=ext4
|
2012-07-24 16:13:17 +02:00
|
|
|
initrd /boot/Initrd
|
|
|
|
" > /boot/grub/grub.conf
|
2012-07-25 17:29:18 +02:00
|
|
|
( cd /boot/grub && ln -sf grub.conf menu.lst ) || exit 1
|
2012-07-24 16:13:17 +02:00
|
|
|
|
|
|
|
# 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
|
2012-07-25 17:29:18 +02:00
|
|
|
# cleanup install-data dir
|
|
|
|
rm -rf /install-data
|
2012-07-24 16:13:17 +02:00
|
|
|
|
|
|
|
# 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
|