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-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 PROGNAME=`basename "$0"` 29 30 if [ ! "$1" ] || [ "$1" = '--help' ]; then 31 echo "Usage: $PROGNAME <memory-with-unit> [ --net ] [ --initrd <initrd-file> [ --root <device> ] <filesystem-image> ]" 1>&2 32 exit 1 33 fi 34 35 UML_MEMORY="$1" 36 37 # Discard the memory argument. 38 39 shift 1 40 41 # Test for networking. 42 43 if [ "$1" = '--net' ]; then 44 UML_NETWORKING="$NETDEVICE=tuntap,$TUNDEVICE,fe:fd:0:0:0:1,$HOSTADDRESS" 45 xhost +"$GUESTADDRESS" 46 shift 1 47 fi 48 49 # Test for initrd. 50 51 if [ "$1" = '--initrd' ]; then 52 INITRD=$2 53 shift 2 54 if [ "$1" = '--root' ]; then 55 ROOTDEVICE=$2 56 shift 2 57 else 58 ROOTDEVICE=/dev/ram 59 fi 60 ISOIMAGE=$1 61 INITRD_OPTIONS="initrd=$INITRD root=$ROOTDEVICE load_ramdisk=1 ubd2=$ISOIMAGE" 62 shift 1 63 else 64 INITRD_OPTIONS= 65 fi 66 67 # Now we start the virtual machine. 68 # Note that con0 is not necessarily a login console, so a login prompt may not 69 # appear on standard input/output. 70 71 ./linux ubd0="$IMAGE" rw ubd1="$SWAPIMAGE" rw mem="$UML_MEMORY" con0=fd:0,fd:1 con=pts "$UML_NETWORKING" $INITRD_OPTIONS $*