3 #input pnd_run.sh -p "/path/to/foobar.pnd" -e "exe" --a "arguments for exe"
4 # -u to skip union mount
6 # arguments can be inside -e, -a is optional
8 ############################# dont forget to remove the echos! ############################
11 TEMP=`getopt -o p:e:a:b:u::s: --long p-long,e-long:,a-long: -- "$@"`
13 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
15 # Note the quotes around `$TEMP': they are essential!
20 -p|--p-long) echo "pnd set to \`$2'" ;PND=$2;shift 2;;
21 -e|--e-long) echo "exec set to \`$2'" ;EXENAME=$2;shift 2 ;;
22 -u) echo "u set, no union pls!";UNION=1;shift 2 ;;
23 -b) echo "BASENAME set to $2";BASENAME=$2;shift 2;;
24 -s) echo "startdir set to $2";STARTDIR=$2;shift 2;;
27 "") echo "no arguments"; shift 2 ;;
28 *) echo "args set to \`$2'" ;ARGUMENTS=$2;shift 2 ;;
31 *) echo "Error while parsing arguments!" ; exit 1 ;;
38 DFS=$(file -b $PND | awk '{ print $1 }') # is -p a zip iso or folder?
39 MOUNTPOINT=$(df $PND | grep -vE '^Filesystem' | awk '{ print $6 }') #find out which mountpoint the pnd/folder is on
41 #if -b is set use that as basename, else generate it from PND
42 #get basename (strip extension if file) for union mountpoints etc, maybe this should be changed to something specified inside the xml
43 if [ ! $BASENAME ]; then BASENAME=$(basename "$PND" | cut -d'.' -f1) ; fi
49 if [ $DFS = ISO ]; then
50 mntline="mount -o loop,fmask=000 $PND /mnt/pnd/$BASENAME"
51 echo "Filetype is $DFS"
52 elif [ $DFS = Zip ]; then
53 mntline="fuse-zip $PND /mnt/pnd/$BASENAME -o ro,fmask=000"
54 echo "Filetype is $DFS"
55 elif [ $DFS = directory ]; then
56 mntline="mount --bind -o ro,fmask=000 $PND /mnt/pnd/$BASENAME"
57 #we bind the folder, now it can be treated in a unified way ATENTION: -o ro doesnt work for --bind at least on 25, on 26 its possible using remount, may have changed on 27
58 echo "Filetype is $DFS"
66 if [ ! -d /mnt/pnd/$BASENAME ]; then echo "mkdir -p /mnt/pnd/$BASENAME "; fi
67 if [ ! -d $MOUNTPOINT/appdata/$BASENAME ]; then echo "mkdir -p $MOUNTPOINT/appdata/$BASENAME "; fi
68 if [ ! -d /mnt/utmp/$BASENAME ]; then echo "mkdir -p /mnt/utmp/$BASENAME "; fi
71 if [ ! $UNION ] ; then
72 #is the union already mounted? if not mount evrything, else launch the stuff
73 mount | grep "on /mnt/utmp/$BASENAME type" > /dev/null
74 if [ ! $? -eq 0 ]; then
76 $mntline #mount the pnd/folder
77 #mount -t unionfs -o exec,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro unionfs /mnt/utmp/$BASENAME #union mount
78 #aufs, one of those should work, bit unsure.
79 mount -t aufs -o exec,fmask=000,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro none /mnt/utmp/$BASENAME #aufs?
80 #mount -t aufs -o exec,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro aufs /mnt/utmp/$BASENAME #aufs?
88 cd /mnt/utmp/$BASENAME
89 if [ $STARTDIR ]; then cd $STARTDIR; fi
97 if [ $STARTDIR ]; then cd $STARTDIR; fi
102 umount /mnt/utmp/$BASENAME
103 if [ $? -eq 0 ]; then
105 umount /mnt/pnd/$BASENAME
106 rmdir /mnt/pnd/$BASENAME
107 rmdir /mnt/utmp/$BASENAME