Merge branch 'master' of ssh://skeezixgit@git.openpandora.org/srv/git/pandora-libraries
authorskeezix <skeezix@flotsam-vm.(none)>
Wed, 10 Mar 2010 20:39:06 +0000 (15:39 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Wed, 10 Mar 2010 20:39:06 +0000 (15:39 -0500)
Pulled from stupid git :)

Conflicts:
testdata/scripts/pnd_run.sh

1  2 
testdata/scripts/pnd_run.sh

index 37ef213,c663cbe..ae10e32
mode 100644,100755..100644
@@@ -9,8 -9,6 +9,6 @@@
  # look at the comments in the nox part, adjust 
  #use "lsof /usr/lib/libX11.so.6 | awk '{print $1}'| sort | uniq > whitelist" with nothing running to generate the whitelist
   
- #launch the script with nohup for -x to work!
-  
  #todo - no proper order
  #validate params better
  #make uid/basename mandatory (and rename var, its confusing!)
@@@ -61,34 -59,34 +59,34 @@@ if [ ! $EXENAME ]; the
        fi
  fi
  
- if [ $(pidof X) ]; then 
- unset $nox
- fi
  fork () {
  echo in fork!
  if [ $nox ]; then #the app doesnt want x to run, so we kill it and restart it once the app quits
-       applist=$(lsof /usr/lib/libX11.so.6 | awk '{print $1}'| sort | uniq)
-       whitelist=$(cat ~/pndtest/whitelist) #adjust this to a fixed whitelist, maybe in the config dir
-       filteredlist=$(echo -e "$applist\n\n$whitelist\n\n$whitelist" | sort | uniq -u) #whitelist appended two times so those items are always removed
-       if [ ${#filteredlist} -ge 1 ]; then
-               message=$(echo -e "The following applications are still running, are you sure you want to close x? \n$filteredlist")
-               echo -e ?ae[34me[30m?
-               xmessage -center "$message", -buttons yes,no
-               if [ $? = 102 ]; then
-               exit 1
-               fi
-               sudo /etc/init.d/slim-init stop
-               sleep 5s
+       if [ ! $(pidof X) ]; then 
+               unset $nox
        else
-               echo -e ?ae[34me[30m?
-               xmessage -center "killing x, nothing of value will be lost", -buttons ok,cancel
-               if [ $? = 102 ]; then
-               exit 1
+               applist=$(lsof /usr/lib/libX11.so.6 | awk '{print $1}'| sort | uniq)
+               whitelist=$(cat ~/pndtest/whitelist) #adjust this to a fixed whitelist, maybe in the config dir
+               filteredlist=$(echo -e "$applist\n\n$whitelist\n\n$whitelist" | sort | uniq -u) #whitelist appended two times so those items are always removed
+               if [ ${#filteredlist} -ge 1 ]; then
+                       message=$(echo -e "The following applications are still running, are you sure you want to close x? \n$filteredlist")
+                       echo -e ?ae[34me[30m?
+                       xmessage -center "$message", -buttons yes,no
+                       if [ $? = 102 ]; then
+                       exit 1
+                       fi
+                       sudo /etc/init.d/slim-init stop
+                       sleep 5s
+               else
+                       echo -e ?ae[34me[30m?
+                       xmessage -center "killing x, nothing of value will be lost", -buttons ok,cancel
+                       if [ $? = 102 ]; then
+                       exit 1
+                       fi
+                       # close x now, do we want to use slim stop or just kill x?
+                       sudo /etc/init.d/slim-init stop
+                       sleep 5s
                fi
-               # close x now, do we want to use slim stop or just kill x?
-               sudo /etc/init.d/slim-init stop
-               sleep 5s
        fi
  fi
   
@@@ -96,8 -94,7 +94,7 @@@
  DFS=$(file -b $PND | awk '{ print $1 }') #is -p a zip/iso or folder?
  MOUNTPOINT=$(df $PND | sed -ne 's/.*\% \(\S*\)/\1/p' | tail -n1) #find out on which mountpoint the pnd is
  if [ ! -d "$MOUNTPOINT" ]; then MOUNTPOINT="/"; fi #make sure folder exists, if it doesnt assume rootfs
- FILESYSTEM=$(mount | grep "on $MOUNTPOINT " | grep -v rootfs | awk '{print $5}' | tail -n1) #get filesystem appdata is on to determine aufs options
- echo "Filesystem is $FILESYSTEM"
  #if the pnd is on / set mountpoint to "" so we dont and up with // at the start,
  #this is to make sure sudo doesnt get confused
  if [ $MOUNTPOINT = "/" ]; then MOUNTPOINT=""; fi
@@@ -111,19 -108,15 +108,15 @@@ if [ ! $BASENAME ]; then BASENAME=$(bas
   
   
   
- oCWD=$(pwd)
+ if [ ! $umount ]; then 
  
-  
- #create mountpoints, check if they exist already first to avoid annoying error messages
- if [ ! -d /mnt/pnd/$BASENAME ]; then sudo mkdir -p /mnt/pnd/$BASENAME ; fi #mountpoint for iso, ro
- #writeable dir for union
- if [ ! -d $MOUNTPOINT/pandora/appdata/$BASENAME ]; then sudo mkdir -p $MOUNTPOINT/pandora/appdata/$BASENAME; sudo chmod -R a+xrw $MOUNTPOINT/pandora/appdata/$BASENAME; fi
- if [ ! -d /mnt/utmp/$BASENAME ]; then sudo mkdir -p /mnt/utmp/$BASENAME; fi #union over the two
+       oCWD=$(pwd)
      #create mountpoints, check if they exist already first to avoid annoying error messages
      if [ ! -d /mnt/pnd/$BASENAME ]; then sudo mkdir -p /mnt/pnd/$BASENAME ; fi #mountpoint for iso, ro
      #writeable dir for union
      if [ ! -d $MOUNTPOINT/pandora/appdata/$BASENAME ]; then sudo mkdir -p $MOUNTPOINT/pandora/appdata/$BASENAME; sudo chmod -R a+xrw $MOUNTPOINT/pandora/appdata/$BASENAME; fi
      if [ ! -d /mnt/utmp/$BASENAME ]; then sudo mkdir -p /mnt/utmp/$BASENAME; fi #union over the two
  
- #mount
-  
- if [ ! $umount ]; then
        if [ ! $cpuspeed -eq $(cat /proc/pandora/cpu_mhz_max) ]; then 
          gksu --message "$BASENAME wants to set the cpu speed to $cpuspeed, enter root password to allow" echo $cpuspeed > /proc/pandora/cpu_mhz_max
        fi
                        echo "$mntline"
                        $mntline #mount the pnd/folder
                        echo "mounting union!"
+                       FILESYSTEM=$(mount | grep "on $MOUNTPOINT " | grep -v rootfs | awk '{print $5}' | tail -n1) #get filesystem appdata is on to determine aufs options
+                       echo "Filesystem is $FILESYSTEM"
                        if [ $FILESYSTEM = vfat ]; then # use noplink on fat, dont on other fs's 
                                #append is fucking dirty, need to clean that up
                                sudo mount -t aufs -o exec,noplink,dirs=$MOUNTPOINT/pandora/appdata/$BASENAME=rw+nolwh:/mnt/pnd/$BASENAME=rr$append none /mnt/utmp/$BASENAME # put union on top
@@@ -235,22 -230,22 +230,22 @@@ if [ $? -eq 0 ]; then # check if the um
        sudo rmdir /mnt/pnd/$BASENAME #delete pnd mountpoint
        echo cleanup done
  else
- echo umount failed, didnt clean up
      echo umount failed, didnt clean up
  fi
  
  if [ $nox ]; then #restart x if it was killed
- echo "starting x in 5s"
- sleep 5
- sudo /etc/init.d/slim-init start
      echo "starting x in 5s"
      sleep 5
      sudo /etc/init.d/slim-init start
  fi
  
  } #function end!
  
  if [ $nox ]; then
- echo forking now!
- fork &> /tmp/pndrun$BASENAME$mount.out & 
- disown
      echo forking now!
      fork &> /tmp/pndrun$BASENAME$mount.out & 
      disown
  else
- echo Running with x, not disowning!
- fork &> /tmp/pndrun$BASENAME$mount.out
- fi
+       echo Running with x, not disowning!
+       fork &> /tmp/pndrun$BASENAME$mount.out
 -fi
++fi