Created
February 7, 2012 01:51
-
-
Save kagesenshi/1756562 to your computer and use it in GitHub Desktop.
Fedora 16 LXC script
This file contains 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/bash | |
if [ $# != 2 ]; then | |
echo "usage: $0 <directory> <hostname>" | |
exit 1 | |
fi | |
if [ ! -d $1 ];then | |
mkdir -p $1 | |
fi | |
ROOT=`cd $1;pwd` | |
RELEASEFILESRC=http://mirror.bytemark.co.uk/fedora/linux/releases/16/Everything/x86_64/os/Packages/fedora-release-16-1.noarch.rpm | |
ORIGIN=`pwd` | |
RELEASEFILE=`mktemp`.rpm | |
wget $RELEASEFILESRC -O $RELEASEFILE | |
rpm -ivh $RELEASEFILE --root $ROOT | |
cat >> $ROOT/etc/yum.conf << EOF | |
[main] | |
cachedir=/var/cache/yum/\$basearch/\$releasever | |
keepcache=0 | |
debuglevel=2 | |
logfile=/var/log/yum.log | |
exactarch=1 | |
obsoletes=1 | |
gpgcheck=1 | |
plugins=1 | |
installonly_limit=3 | |
color=never | |
EOF | |
yum --installroot $ROOT groupinstall Core | |
DEVDIR=$ROOT/dev | |
# create device nodes. taken from | |
# http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg01707/lxc-fedora.in | |
mkdir $DEVDIR | |
#mknod -m 666 ${DEVDIR}/null c 1 3 | |
mknod -m 660 ${DEVDIR}/kmsg c 1 11 | |
mknod -m 666 ${DEVDIR}/zero c 1 5 | |
mknod -m 666 ${DEVDIR}/random c 1 8 | |
mknod -m 666 ${DEVDIR}/urandom c 1 9 | |
mkdir -m 755 ${DEVDIR}/pts | |
mkdir -m 1777 ${DEVDIR}/shm | |
mknod -m 666 ${DEVDIR}/tty c 5 0 | |
mknod -m 666 ${DEVDIR}/tty0 c 4 0 | |
mknod -m 666 ${DEVDIR}/tty1 c 4 1 | |
mknod -m 666 ${DEVDIR}/tty2 c 4 2 | |
mknod -m 666 ${DEVDIR}/tty3 c 4 3 | |
mknod -m 666 ${DEVDIR}/tty4 c 4 4 | |
mknod -m 600 ${DEVDIR}/console c 5 1 | |
mknod -m 666 ${DEVDIR}/full c 1 7 | |
mknod -m 600 ${DEVDIR}/initctl p | |
mknod -m 666 ${DEVDIR}/ptmx c 5 2 | |
# edit stuff | |
wget --no-check-certificate https://raw.github.com/gist/1142202/setup_lxc_rootfs_fedora15.sh -O $ROOT/setup_lxc_rootfs.sh | |
chmod a+x $ROOT/setup_lxc_rootfs.sh | |
chroot $ROOT ./setup_lxc_rootfs.sh $2 | |
chroot $ROOT chkconfig network on | |
echo "root:password" | chroot $ROOT chpasswd | |
echo DONE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment