Last active
March 3, 2016 09:58
-
-
Save gourytch/4d1ee464258d2196ff5d to your computer and use it in GitHub Desktop.
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/bash | |
| # prepumdu.sh -- # prepare usermodded debootstapped ubuntu | |
| # using debootstrap, fakeroot, fakechroot | |
| # | |
| # usage: | |
| # arch=amd64 \ | |
| # suite="trusty" \ | |
| # mirror="http://ru.archive.ubuntu.com/ubuntu" \ | |
| # proxy="http://proxy.mine:3128/" \ | |
| # root="/tmp/my_ubuntu" \ | |
| # ./prepumdu.sh | |
| # | |
| # all options are optional | |
| # | |
| ############################################################################ | |
| set -e | |
| set -x | |
| base="$(dirname $(readlink -f $0))" | |
| : ${suite:="trusty"} | |
| mirror="http://ru.archive.ubuntu.com/ubuntu" | |
| machine=$(uname -m) | |
| case "$machine" in | |
| "x86_64") | |
| : ${arch:=amd64} | |
| ;; | |
| i*86) | |
| : ${arch:=i686} | |
| ;; | |
| *) | |
| echo "unknown machine: '$machine'" | |
| exit 2 | |
| ;; | |
| esac | |
| : ${root:="$base/$suite-$arch"} | |
| : ${proxy:=""} | |
| : ${user:="$(id -un)"} | |
| : ${uid:="$(id -u)"} | |
| # : ${home:="/home/$user"} | |
| : ${home:="/data"} | |
| test -x /usr/bin/fakeroot | |
| test -x /usr/bin/fakechroot | |
| test -x /usr/sbin/debootstrap | |
| if [ ! -d $root ]; then | |
| export DEBIAN_FRONTEND=noninteractive | |
| fakechroot fakeroot debootstrap --arch $arch $suite $root $mirror | |
| cat >$root/etc/apt/sources.list <<_EOF_ | |
| deb $mirror $suite main restricted universe multiverse | |
| deb $mirror $suite-updates main restricted universe multiverse | |
| deb $mirror $suite-backports main restricted universe multiverse | |
| _EOF_ | |
| if [ ! "x$proxy" = "x" ]; then | |
| cat >$root/etc/apt/apt.conf.d/proxy <<_EOF_ | |
| Acquire::http::Timeout "10"; | |
| Acquire::http::Proxy "$proxy"; | |
| Acquire::ftp::Proxy "$proxy"; | |
| _EOF_ | |
| cat >$root/etc/profile.d/proxy.sh <<_EOF_ | |
| export HTTP_PROXY="$proxy" | |
| export HTTPS_PROXY="$proxy" | |
| export http_proxy="$proxy" | |
| export https_proxy="$proxy" | |
| export no_proxy="127.0.0.0/8,192.168.0.0/16,172.0.0.0/8,10.0.0.0/8" | |
| _EOF_ | |
| fi | |
| mkdir -p $root/var/lib/locales/supported.d/ | |
| cat >$root/var/lib/locales/supported.d/en <<_EOF_ | |
| en_US.UTF-8 UTF-8 | |
| _EOF_ | |
| cat >$root/var/lib/locales/supported.d/local <<_EOF_ | |
| ru_RU.UTF-8 UTF-8 | |
| en_US.UTF-8 UTF-8 | |
| _EOF_ | |
| fakechroot fakeroot chroot $root /bin/bash --login <<_EOF_ | |
| set -e | |
| set -x | |
| dpkg-reconfigure locales | |
| apt-get update | |
| apt-get upgrade -y | |
| apt-get autoclean | |
| apt-get clean | |
| apt-get autoremove | |
| mkdir -p $home | |
| useradd --user-group --uid $uid --home $home --shell /bin/bash $user | |
| chown -R $user:$user $home | |
| _EOF_ | |
| fi | |
| echo "$root prepared." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment