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 if [ "$USERINSTALL_CODENAME" = "$DISTRIB_CODENAME" ]; then 42 "$AS_USER" cp /etc/apt/sources.list "$PACKAGEROOT/etc/apt/" 43 elif [ -e "$USERINSTALL_CODENAME/sources.list" ]; then 44 "$AS_USER" cp "$USERINSTALL_CODENAME/sources.list" "$PACKAGEROOT/etc/apt/" 45 else 46 echo "Attempting to generate a repository definition for $USERINSTALL_CODENAME." 1>&2 47 "$AS_USER" "$THIS_DIR/user-makesources" "$PACKAGEROOT/etc/apt/sources.list" "$COUNTRY" 48 fi 49 50 if [ "$AS_ROOT" ]; then 51 echo "Mounting filesystems..." 1>&2 52 "$THIS_DIR/user-do" $AS_ROOT mount -t proc proc /proc 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 if [ "$AS_ROOT" ]; then 60 echo "Configuring a root installation..." 1>&2 61 "$THIS_DIR/user-do" $AS_ROOT apt-get install locales console-data 62 "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure locales 63 "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure tzdata 64 "$THIS_DIR/user-do" $AS_ROOT dpkg-reconfigure console-data 65 66 echo "Unmounting filesystems..." 1>&2 67 "$THIS_DIR/user-do" $AS_ROOT umount /proc 68 fi