paul@31 | 1 | #!/bin/sh |
paul@22 | 2 | |
paul@79 | 3 | # Copyright (C) 2010, 2011, 2012, 2013, 2014 Paul Boddie <paul@boddie.org.uk> |
paul@63 | 4 | # |
paul@63 | 5 | # This program is free software; you can redistribute it and/or modify it under |
paul@63 | 6 | # the terms of the GNU General Public License as published by the Free Software |
paul@63 | 7 | # Foundation; either version 3 of the License, or (at your option) any later |
paul@63 | 8 | # version. |
paul@63 | 9 | # |
paul@63 | 10 | # This program is distributed in the hope that it will be useful, but WITHOUT |
paul@63 | 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@63 | 12 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@63 | 13 | # details. |
paul@63 | 14 | # |
paul@63 | 15 | # You should have received a copy of the GNU General Public License along with |
paul@63 | 16 | # this program. If not, see <http://www.gnu.org/licenses/>. |
paul@63 | 17 | |
paul@22 | 18 | # Configuration: |
paul@22 | 19 | if [ -e userinstall-defaults ]; then |
paul@31 | 20 | . "$PWD/userinstall-defaults" |
paul@22 | 21 | elif [ -e /etc/default/userinstall ]; then |
paul@31 | 22 | . /etc/default/userinstall |
paul@22 | 23 | else |
paul@34 | 24 | echo "No defaults found for userinstall." 1>&2 |
paul@22 | 25 | exit 1 |
paul@22 | 26 | fi |
paul@22 | 27 | |
paul@34 | 28 | if [ "$1" = '--help' ]; then |
paul@34 | 29 | echo "Usage: `basename $0` [ --root ] [ <country> ]" 1>&2 |
paul@34 | 30 | elif [ "$1" = '--root' ]; then |
paul@34 | 31 | AS_ROOT="$1" |
paul@34 | 32 | AS_USER="sudo" |
paul@30 | 33 | shift 1 |
paul@25 | 34 | fi |
paul@25 | 35 | |
paul@30 | 36 | export COUNTRY="$1" |
paul@30 | 37 | |
paul@31 | 38 | THIS_DIR=`dirname "$0"` |
paul@25 | 39 | |
paul@34 | 40 | if [ ! "$PACKAGEROOT" ] || [ "$PACKAGEROOT" = '/' ]; then |
paul@34 | 41 | echo "The package root must be specified and not be set to / (the system root)." 1>&2 |
paul@34 | 42 | exit 1 |
paul@34 | 43 | fi |
paul@22 | 44 | |
paul@34 | 45 | echo "Copying host DNS configuration..." 1>&2 |
paul@59 | 46 | $AS_USER cp /etc/resolv.conf "$PACKAGEROOT/etc/" |
paul@34 | 47 | |
paul@34 | 48 | echo "Copying filesystems configuration..." 1>&2 |
paul@59 | 49 | $AS_USER cp /etc/fstab "$PACKAGEROOT/etc/" |
paul@22 | 50 | |
paul@34 | 51 | echo "Copying network configuration..." 1>&2 |
paul@59 | 52 | $AS_USER cp /etc/hosts "$PACKAGEROOT/etc/" |
paul@59 | 53 | $AS_USER cp /etc/network/interfaces "$PACKAGEROOT/etc/network/" |
paul@22 | 54 | |
paul@34 | 55 | echo "Copying package repository configuration..." 1>&2 |
paul@50 | 56 | |
paul@50 | 57 | # For installations of the same distribution, copy the host's sources list. |
paul@50 | 58 | |
paul@31 | 59 | if [ "$USERINSTALL_CODENAME" = "$DISTRIB_CODENAME" ]; then |
paul@59 | 60 | $AS_USER cp /etc/apt/sources.list "$PACKAGEROOT/etc/apt/" |
paul@50 | 61 | |
paul@79 | 62 | # Otherwise, attempt to make a new sources list, if necessary. |
paul@50 | 63 | |
paul@79 | 64 | elif [ ! -e "$PACKAGEROOT/etc/apt/sources.list.d/multistrap-"*".list" ]; then |
paul@79 | 65 | |
paul@34 | 66 | echo "Attempting to generate a repository definition for $USERINSTALL_CODENAME." 1>&2 |
paul@59 | 67 | $AS_USER USERINSTALL_ID="$USERINSTALL_ID" USERINSTALL_CODENAME="$USERINSTALL_CODENAME" \ |
paul@37 | 68 | "$THIS_DIR/user-makesources" "$PACKAGEROOT/etc/apt/sources.list" "$COUNTRY" |
paul@25 | 69 | fi |
paul@25 | 70 | |
paul@60 | 71 | echo "Setting the PATH..." 1>&2 |
paul@60 | 72 | PATH=$PATH${PATH:+:}/usr/sbin:/sbin |
paul@60 | 73 | |
paul@34 | 74 | echo "Updating package details and upgrading..." 1>&2 |
paul@34 | 75 | "$THIS_DIR/user-do" $AS_ROOT apt-get update |
paul@34 | 76 | "$THIS_DIR/user-do" $AS_ROOT apt-get upgrade |
paul@25 | 77 | |
paul@50 | 78 | # Root installations also need further configuration. |
paul@50 | 79 | |
paul@30 | 80 | if [ "$AS_ROOT" ]; then |
paul@34 | 81 | echo "Configuring a root installation..." 1>&2 |
paul@34 | 82 | "$THIS_DIR/user-do" $AS_ROOT apt-get install locales console-data |
paul@34 | 83 | "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure locales |
paul@34 | 84 | "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure tzdata |
paul@34 | 85 | "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure console-data |
paul@25 | 86 | fi |