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> <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 shift 1 53 INITRD_OPTIONS="initrd=$1 root=/dev/ram load_ramdisk=1 ubd2=$2" 54 shift 2 55 else 56 INITRD_OPTIONS= 57 fi 58 59 # Now we start the virtual machine... 60 61 ./linux ubd0="$IMAGE" rw ubd1="$SWAPIMAGE" rw mem="$UML_MEMORY" con0=fd:0,fd:1 con=pts "$UML_NETWORKING" $INITRD_OPTIONS $*