paul@31 | 1 | #!/bin/sh |
paul@22 | 2 | |
paul@63 | 3 | # Copyright (C) 2010, 2011, 2012, 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@22 | 18 | # Configuration: |
paul@22 | 19 | if [ -e userinstall-defaults-uml ]; then |
paul@31 | 20 | . "$PWD/userinstall-defaults-uml" |
paul@22 | 21 | elif [ -e /etc/default/userinstall-uml ]; then |
paul@31 | 22 | . /etc/default/userinstall-uml |
paul@22 | 23 | else |
paul@31 | 24 | echo "No defaults found for userinstall (UML)." 1>&2 |
paul@22 | 25 | exit 1 |
paul@22 | 26 | fi |
paul@22 | 27 | |
paul@31 | 28 | PROGNAME=`basename "$0"` |
paul@31 | 29 | |
paul@34 | 30 | if [ ! "$1" ] || [ "$1" = '--help' ]; then |
paul@42 | 31 | echo "Usage: $PROGNAME <memory-with-unit> [ --net ] [ --initrd <initrd-file> <filesystem-image> ]" 1>&2 |
paul@25 | 32 | exit 1 |
paul@25 | 33 | fi |
paul@25 | 34 | |
paul@31 | 35 | UML_MEMORY="$1" |
paul@22 | 36 | |
paul@27 | 37 | # Discard the memory argument. |
paul@27 | 38 | |
paul@27 | 39 | shift 1 |
paul@27 | 40 | |
paul@27 | 41 | # Test for networking. |
paul@27 | 42 | |
paul@31 | 43 | if [ "$1" = '--net' ]; then |
paul@31 | 44 | UML_NETWORKING="$NETDEVICE=tuntap,$TUNDEVICE,fe:fd:0:0:0:1,$HOSTADDRESS" |
paul@30 | 45 | xhost +"$GUESTADDRESS" |
paul@27 | 46 | shift 1 |
paul@27 | 47 | fi |
paul@27 | 48 | |
paul@42 | 49 | # Test for initrd. |
paul@42 | 50 | |
paul@42 | 51 | if [ "$1" = '--initrd' ]; then |
paul@42 | 52 | shift 1 |
paul@42 | 53 | INITRD_OPTIONS="initrd=$1 root=/dev/ram load_ramdisk=1 ubd2=$2" |
paul@42 | 54 | shift 2 |
paul@42 | 55 | else |
paul@42 | 56 | INITRD_OPTIONS= |
paul@42 | 57 | fi |
paul@42 | 58 | |
paul@22 | 59 | # Now we start the virtual machine... |
paul@25 | 60 | |
paul@44 | 61 | ./linux ubd0="$IMAGE" rw ubd1="$SWAPIMAGE" rw mem="$UML_MEMORY" con0=fd:0,fd:1 con=pts "$UML_NETWORKING" $INITRD_OPTIONS $* |