Last active
January 9, 2017 21:47
-
-
Save dapperfu/251a79d2409744330989a81d53828c9c to your computer and use it in GitHub Desktop.
Bootstrap a chroot environment.
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
#!/usr/bin/env bash | |
# Root for debootstrap | |
ROOT=$1 | |
# apt-cacher-ng location | |
PROXY=http://127.0.0.1:3142 | |
# Unmount and drop the bootstrap location. | |
umount ${ROOT}/* | |
rm -rf ${ROOT} | |
# Bootstrap | |
debootstrap xenial ${ROOT} ${PROXY}/ubuntu | |
# Put the apt-cacher-ng proxy into the appropriate place. | |
echo "Acquire::http::Proxy \"${PROXY}\";" > ${ROOT}/etc/apt/apt.conf.d/80proxy | |
# Copy the full sources file over. | |
cp /etc/apt/sources.list ${ROOT}/etc/apt/sources.list | |
# Mounts | |
mount -t proc proc ${ROOT}/proc/ | |
mount -t sysfs sys ${ROOT}/sys/ | |
mount -o bind /dev ${ROOT}/dev/ | |
# Update and upgrade | |
chroot ${ROOT} apt-get update | |
chroot ${ROOT} apt-get upgrade -y | |
# Housekeeping. | |
chroot ${ROOT} locale-gen en_US en_US.UTF-8 | |
chroot ${ROOT} echo "LC_ALL=\"en_US.UTF-8\"" > /etc/default/locale | |
chroot ${ROOT} echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/environment | |
chroot ${ROOT} echo "America/Detroit" > /etc/timezone | |
# Drop into new environment | |
chroot ${ROOT} su - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment