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