-
-
Save mdeguzis/c787ee1cd04b56750f89 to your computer and use it in GitHub Desktop.
Little script to create a minimal ubuntu using debootstrap and bring it up to date
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 | |
set -e | |
DEFAULT_PACKAGES=ssh,language-pack-en-base | |
DEFAULT_COMPONENTS=main,universe | |
DEBOOTSTRAP=/usr/sbin/debootstrap | |
DEFAULT_MIRROR=http://archive.ubuntu.com/ubuntu | |
DEFAULT_VARIANT=minbase | |
MIRROR=${STRAP_MIRROR:-$DEFAULT_MIRROR} | |
ROOTFS=$1 | |
PACKAGES=${STRAP_PACKAGES:-$DEFAULT_PACKAGES} | |
COMPONENTS=${STRAP_COMPONENTS:-$DEFAULT_COMPONENTS} | |
SUITE=${STRAP_SUITE:-precise} | |
VARIANT=${STRAP_VARIANT:-$DEFAULT_VARIANT} | |
type $DEBOOTSTRAP >/dev/null | |
if [ $? -ne 0 ]; then | |
echo "debootstrap not installed" | |
exit 1 | |
fi | |
if [ "x$ROOTFS" == "x" ]; then | |
echo "Usage: $0 <path_to_root>" | |
exit 1 | |
fi | |
$DEBOOTSTRAP --include $PACKAGES --components $COMPONENTS --variant $VARIANT $SUITE $ROOTFS $MIRROR | |
cat > $ROOTFS/etc/apt/sources.list << EOF | |
deb $MIRROR $SUITE ${COMPONENTS//,/ } | |
deb $MIRROR $SUITE-updates ${COMPONENTS//,/ } | |
deb $MIRROR $SUITE-security ${COMPONENTS//,/ } | |
EOF | |
chroot $ROOTFS mount -t proc /proc /proc | |
chroot $ROOTFS apt-get update | |
chroot $ROOTFS apt-get dist-upgrade -y | |
umount $ROOTFS/proc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment