paul@32 | 1 | #!/bin/sh |
paul@32 | 2 | |
paul@63 | 3 | # Copyright (C) 2011, 2013 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@32 | 18 | # Configuration: |
paul@32 | 19 | if [ -e userinstall-defaults-uml ]; then |
paul@32 | 20 | . "$PWD/userinstall-defaults-uml" |
paul@32 | 21 | elif [ -e /etc/default/userinstall-uml ]; then |
paul@32 | 22 | . /etc/default/userinstall-uml |
paul@32 | 23 | else |
paul@32 | 24 | echo "No defaults found for userinstall (UML)." 1>&2 |
paul@32 | 25 | exit 1 |
paul@32 | 26 | fi |
paul@32 | 27 | |
paul@32 | 28 | if [ -e "$IMAGEDIR/etc/hosts" ]; then |
paul@32 | 29 | if [ ! -e "$IMAGEDIR/etc/hosts.old" ]; then |
paul@32 | 30 | mv "$IMAGEDIR/etc/hosts" "$IMAGEDIR/etc/hosts.old" |
paul@32 | 31 | fi |
paul@32 | 32 | fi |
paul@32 | 33 | |
paul@32 | 34 | if [ ! -e "$IMAGEDIR/etc/hosts" ]; then |
paul@34 | 35 | echo "Creating hosts file..." 1>&2 |
paul@35 | 36 | echo "$GUESTADDRESS `hostname`" > "$IMAGEDIR/etc/hosts" |
paul@32 | 37 | echo "127.0.0.1 localhost" >> "$IMAGEDIR/etc/hosts" |
paul@35 | 38 | echo "$HOSTADDRESS `hostname`-uml" >> "$IMAGEDIR/etc/hosts" |
paul@32 | 39 | fi |
paul@32 | 40 | |
paul@32 | 41 | if [ -e "$IMAGEDIR/etc/network/interfaces" ]; then |
paul@32 | 42 | if [ ! -e "$IMAGEDIR/etc/network/interfaces.old" ]; then |
paul@32 | 43 | mv "$IMAGEDIR/etc/network/interfaces" "$IMAGEDIR/etc/network/interfaces.old" |
paul@32 | 44 | fi |
paul@32 | 45 | fi |
paul@32 | 46 | |
paul@32 | 47 | if [ ! -e "$IMAGEDIR/etc/network/interfaces" ]; then |
paul@34 | 48 | echo "Creating network configuration..." 1>&2 |
paul@35 | 49 | cat > "$IMAGEDIR/etc/network/interfaces" <<EOF |
paul@35 | 50 | auto lo |
paul@35 | 51 | iface lo inet loopback |
paul@35 | 52 | iface eth0 inet static |
paul@35 | 53 | network 192.168.0.0 |
paul@35 | 54 | broadcast 192.168.0.255 |
paul@35 | 55 | address $GUESTADDRESS |
paul@35 | 56 | netmask 255.255.255.0 |
paul@35 | 57 | up route add default gw $HOSTADDRESS |
paul@35 | 58 | |
paul@35 | 59 | auto eth0 |
paul@35 | 60 | EOF |
paul@32 | 61 | fi |