3 #input pnd_run.sh -p "/path/to/foobar.pnd" -e "exe" --a "arguments for exe"
4 # -u to skip union mount
5 # -b to override basename
8 ########################### FS NAMES NEED ADJUSTMENT #################
10 # check if all vars are set to sensible values
13 TEMP=`getopt -o p:e:a:b:u:: --long p-long,e-long:,a-long: -- "$@"`
15 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
17 # Note the quotes around `$TEMP': they are essential!
22 -p|--p-long) echo "pnd set to \`$2'" ;PND=$2;shift 2;;
23 -e|--e-long) echo "exec set to \`$2'" ;EXENAME=$2;shift 2 ;;
24 -u) echo "u set, no union pls!";UNION=1;shift 2 ;;
25 -b) echo "BASENAME set to $2";BASENAME=$2;shift 2;;
28 "") echo "no arguments"; shift 2 ;;
29 *) echo "args set to \`$2'" ;ARGUMENTS=$2;shift 2 ;;
32 *) echo "Error while parsing arguments!" ; exit 1 ;;
39 DFS=$(file -b $PND | awk '{ print $1 }') # is -p a zip iso or folder?
40 MOUNTPOINT=$(df $PND | grep -vE '^Filesystem' | awk '{ print $6 }') #find out which mountpoint the pnd/folder is on
42 #if -b is set use that as basename, else generate it from PND
43 #get basename (strip extension if file) for union mountpoints etc, maybe this should be changed to something specified inside the xml
44 if [ ! $BASENAME ]; then BASENAME=$(basename "$PND" | cut -d'.' -f1) ; fi
50 if [ $DFS = ISO ]; then
51 mntline="mount -o loop,exec,umask=777 $PND /mnt/pnd/$BASENAME"
52 echo "Filetype is $DFS"
53 elif [ $DFS = Zip ]; then
54 mntline="fuse-zip $PND /mnt/pnd/$BASENAME -oro" #should be reight now
55 echo "Filetype is $DFS"
56 elif [ $DFS = directory ]; then
57 mntline="mount --bind -o ro $PND /mnt/pnd/$BASENAME"
58 #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
59 echo "Filetype is $DFS"
70 if [ ! -d /mnt/pnd/$BASENAME ]; then
71 echo "mkdir -p /mnt/pnd/$BASENAME "
73 if [ ! -d $MOUNTPOINT/appdata/$BASENAME ]; then
74 echo "mkdir -p $MOUNTPOINT/appdata/$BASENAME "
76 if [ ! -d /mnt/utmp/$BASENAME ]; then
77 echo "mkdir -p /mnt/utmp/$BASENAME "
81 if [ ! $UNION ] ; then
82 mount | grep "on /mnt/utmp/$BASENAME type" > /dev/null
83 if [ ! $? -eq 0 ]; then
85 $mntline #mount the pnd/folder
86 #mount -t unionfs -o exec,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro unionfs /mnt/utmp/$BASENAME #union mount
87 #aufs, one of those should work, bit unsure.
88 mount -t aufs -o exec,umask=777,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro none /mnt/utmp/$BASENAME #aufs?
89 #mount -t aufs -o exec,dirs\=$MOUNTPOINT/appdata/$BASENAME=rw:/mnt/pnd/$BASENAME=ro aufs /mnt/utmp/$BASENAME #aufs?
97 cd /mnt/utmp/$BASENAME
105 cd /mnt/pnd/$BASENAME
112 umount /mnt/utmp/$BASENAME
113 umount /mnt/pnd/$BASENAME
114 rmdir /mnt/pnd/$BASENAME
115 rmdir /mnt/utmp/$BASENAME