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