-
-
Save kuzetsa/82c8af4ce72cd448179ac3007bccc2d3 to your computer and use it in GitHub Desktop.
How To Install Gentoo Onto Any OpenVZ VPS
This file contains hidden or 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/sh | |
set -e | |
if [ `whoami` != "root" ]; then | |
echo "This script must run as root!" | |
exit 1 | |
fi | |
if [ ! -f /root/stage3-*.tar.bz2 ]; then | |
echo "Could not find stage3 tarball!" | |
exit 1 | |
fi | |
echo "Extracting stage3 tarball ..." | |
rm -fr /root/gentoo | |
mkdir /root/gentoo | |
tar xjpf /root/stage3-*.tar.bz2 -C /root/gentoo | |
echo "Patching Gentoo installation ..." | |
# Fix mtab. | |
rm -f /root/gentoo/etc/mtab | |
ln -s /proc/mounts /root/gentoo/etc/mtab | |
# The host, not the container, mounts file systems. | |
echo "proc /proc proc defaults 0 0" > /root/gentoo/etc/fstab | |
echo "none /dev/pts devpts rw 0 0" >> /root/gentoo/etc/fstab | |
# The container has no terminals, don't run agetty. | |
sed -i -e '/agetty/d' /root/gentoo/etc/inittab | |
# Force a password to be set. | |
sed -i -e '/^root/s/\*/!/' /root/gentoo/etc/shadow | |
# Update PAM so that the host can set passwords. | |
sed -i -e \ | |
'/^password/s/include.*/required pam_unix.so md5 shadow/' \ | |
/root/gentoo/etc/pam.d/chpasswd | |
echo "Activating Gentoo ..." | |
mount | grep -q /root/new && umount /root/new | |
rm -fr /root/new | |
mkdir /root/new | |
mount --bind / /root/new | |
rsync -alH --delete-after \ | |
--exclude=/dev \ | |
--exclude=/lib/init \ | |
--exclude=/root \ | |
/root/gentoo/ /root/new/ | |
echo "Setting root password ..." | |
passwd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment