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 [ ! "$1" ]; then 29 echo "A program needs to be given as an argument to this script." 1>&2 30 exit 1 31 fi 32 33 COMMAND="$1" 34 shift 1 35 36 echo "Accessing the image..." 1>&2 37 if [ ! -e "$IMAGEDIR" ]; then 38 mkdir "$IMAGEDIR" 39 fi 40 41 if ! sudo mount -o loop "$IMAGE" "$IMAGEDIR" ; then 42 echo "Could not mount the image." 1>&2 43 exit 1 44 fi 45 46 echo "Performing the requested activity..." 1>&2 47 "$COMMAND" $* 48 49 echo "Unmounting the image..." 1>&2 50 sudo umount "$IMAGEDIR" 51 rmdir "$IMAGEDIR"