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 "$PACKAGEROOT" ]; then 29 echo "A package root must first be made using user-setup." 1>&2 30 exit 1 31 fi 32 33 if [ ! "$IMAGEDIR" ]; then 34 echo "An image directory must be defined." 1>&2 35 exit 1 36 fi 37 38 THISDIR=`dirname "$0"` 39 40 echo "Installing the package root..." 1>&2 41 cp -a "$PACKAGEROOT/"* "$IMAGEDIR"/ 42 43 if [ -h "$IMAGEDIR/dev" ]; then 44 echo "Removing linked /dev entry..." 1>&2 45 rm "$IMAGEDIR/dev" 46 fi 47 48 if [ -e "$IMAGEDIR/dev" ]; then 49 echo "Moving existing /dev directory..." 1>&2 50 mv "$IMAGEDIR/dev" "$IMAGEDIR/dev.old" 51 fi 52 53 if [ ! -e "$IMAGEDIR/dev" ]; then 54 echo "Making /dev directory..." 1>&2 55 mkdir "$IMAGEDIR/dev" 56 fi 57 58 cp "/dev/MAKEDEV" "$IMAGEDIR/dev" 59 60 if [ -h "$IMAGEDIR/proc" ]; then 61 echo "Removing any linked /proc entry..." 1>&2 62 rm "$IMAGEDIR/proc" 63 fi 64 65 if [ -e "$IMAGEDIR/proc" ]; then 66 echo "Moving existing /proc directory..." 1>&2 67 mv "$IMAGEDIR/proc" "$IMAGEDIR/proc.old" 68 fi 69 70 if [ ! -e "$IMAGEDIR/proc" ]; then 71 echo "Making /proc directory..." 1>&2 72 mkdir "$IMAGEDIR/proc" 73 fi 74 75 echo "Using a special fstab..." 1>&2 76 if [ -e "$IMAGEDIR/etc/fstab" ]; then 77 if [ ! -e "$IMAGEDIR/etc/fstab.orig" ]; then 78 mv "$IMAGEDIR/etc/fstab" "$IMAGEDIR/etc/fstab.orig" 79 fi 80 fi 81 cp "$THISDIR/UML/fstab" "$IMAGEDIR/etc/fstab" 82 83 # Tweak the inittab to only use tty0 and add it to securetty. 84 echo "Reconfiguring the console settings..." 1>&2 85 if [ ! -e "$IMAGEDIR/etc/inittab.orig" ]; then 86 if [ -e "$IMAGEDIR/etc/inittab" ]; then 87 cp "$IMAGEDIR/etc/inittab" "$IMAGEDIR/etc/inittab.orig" 88 grep -v "getty" "$IMAGEDIR/etc/inittab.orig" > "$IMAGEDIR/etc/inittab" 89 fi 90 cat >> "$IMAGEDIR/etc/inittab" <<EOF 91 # We launch just one console for UML: 92 c0:1235:respawn:/sbin/getty 38400 tty0 linux 93 EOF 94 95 cat >> "$IMAGEDIR/etc/securetty" <<EOF 96 # UML modification: use tty0 or vc/0 97 tty0 98 vc/0 99 EOF 100 fi 101 102 sudo "$THISDIR/uml-make-devices" "$IMAGEDIR"