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