1 #!/bin/sh 2 3 # Configuration: 4 if [ -e userinstall-defaults ]; then 5 . "$PWD/userinstall-defaults" 6 elif [ -e /etc/default/userinstall ]; then 7 . /etc/default/userinstall 8 else 9 echo "No defaults found for userinstall." 1>&2 10 exit 1 11 fi 12 13 if [ "$1" = '--help' ]; then 14 echo "Usage: `basename $0` [ --root ] [ <country> ]" 1>&2 15 elif [ "$1" = '--root' ]; then 16 AS_ROOT="$1" 17 AS_USER="sudo" 18 shift 1 19 fi 20 21 export COUNTRY="$1" 22 23 THIS_DIR=`dirname "$0"` 24 25 if [ ! "$PACKAGEROOT" ] || [ "$PACKAGEROOT" = '/' ]; then 26 echo "The package root must be specified and not be set to / (the system root)." 1>&2 27 exit 1 28 fi 29 30 echo "Copying host DNS configuration..." 1>&2 31 "$AS_USER" cp /etc/resolv.conf "$PACKAGEROOT/etc/" 32 33 echo "Copying filesystems configuration..." 1>&2 34 "$AS_USER" cp /etc/fstab "$PACKAGEROOT/etc/" 35 36 echo "Copying network configuration..." 1>&2 37 "$AS_USER" cp /etc/hosts "$PACKAGEROOT/etc/" 38 "$AS_USER" cp /etc/network/interfaces "$PACKAGEROOT/etc/network/" 39 40 echo "Copying package repository configuration..." 1>&2 41 42 # For installations of the same distribution, copy the host's sources list. 43 44 if [ "$USERINSTALL_CODENAME" = "$DISTRIB_CODENAME" ]; then 45 "$AS_USER" cp /etc/apt/sources.list "$PACKAGEROOT/etc/apt/" 46 47 # Otherwise, attempt to make a new sources list. 48 49 else 50 echo "Attempting to generate a repository definition for $USERINSTALL_CODENAME." 1>&2 51 "$AS_USER" USERINSTALL_ID="$USERINSTALL_ID" USERINSTALL_CODENAME="$USERINSTALL_CODENAME" \ 52 "$THIS_DIR/user-makesources" "$PACKAGEROOT/etc/apt/sources.list" "$COUNTRY" 53 fi 54 55 echo "Updating package details and upgrading..." 1>&2 56 "$THIS_DIR/user-do" $AS_ROOT apt-get update 57 "$THIS_DIR/user-do" $AS_ROOT apt-get upgrade 58 59 # Root installations also need further configuration. 60 61 if [ "$AS_ROOT" ]; then 62 echo "Configuring a root installation..." 1>&2 63 "$THIS_DIR/user-do" $AS_ROOT apt-get install locales console-data 64 "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure locales 65 "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure tzdata 66 "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure console-data 67 fi