Merge branch 'master' of git://git.openpandora.org/pandora-libraries
authorvimacs <vimacs@pndtest>
Wed, 10 Mar 2010 20:14:56 +0000 (21:14 +0100)
committervimacs <vimacs@pndtest>
Wed, 10 Mar 2010 20:14:56 +0000 (21:14 +0100)
Conflicts:
testdata/scripts/pnd_run.sh

1  2 
testdata/scripts/pnd_run.sh

index 37ef213,e59d73d..bd29c05
mode 100755,100644..100755
@@@ -9,8 -9,8 +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!)
@@@ -48,7 -48,7 +46,7 @@@ while true ; d
                *) echo "Error while parsing arguments!" ; exit 1 ;;
        esac
  done
 - 
 +
  if [ ! $PND ]; then #check if theres a pnd suplied, need to clean that up a bit more
        echo "Usage: pnd_run.sh -p your.pnd -e executeable [-a \"(arguments)\"] [ -s \"cd to folder inside pnd\"] [-b UID (name of mountpoint/pandora/appdata)] [-x close x before launching(script needs to be started with nohup for this to work]"
        exit 1
@@@ -61,34 -61,30 +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 -92,8 +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 -107,19 +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
  
-  
- #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
@@@ -215,7 -211,6 +210,7 @@@ f
   
  #clean up
  sudo rmdir /mnt/utmp/$BASENAME
 +sudo rm /mnt/utmp/$BASENAME
  sudo umount /mnt/utmp/$BASENAME #umount union
  if [ $? -eq 0 ]; then # check if the umount was successfull, if it wasnt it would mean that theres still something running so we skip this stuff, this WILL lead to clutter if it happens, so we should make damn sure it never happens
        #umount the actual pnd
        #delete appdata folder and ancestors if empty
        sudo rmdir -p $MOUNTPOINT/pandora/appdata/$BASENAME/
        #delete tmp mountpoint
 -      sudo rmdir /mnt/utmp/$BASENAME;
 +      sudo rmdir /mnt/utmp/$BASENAME
        if [ $DFS = ISO ] || [ $DFS = Squashfs ]; then # check if we where running an iso, clean up loop device if we did
 -              LOOP=$(sudo losetup -a | grep $PND | tail -n1 | awk -F: '{print $1}')
 +              LOOP=$(sudo losetup -a | grep $(basename $PND) | tail -n1 | awk -F: '{print $1}')
                sudo /sbin/losetup -d $LOOP
                sudo rm $LOOP
        fi
@@@ -248,9 -243,9 +243,9 @@@ f
  
  if [ $nox ]; then
  echo forking now!
 -fork &> /tmp/pndrun$BASENAME.out & 
 +fork &> /tmp/pndrun$BASENAME$mount.out & 
  disown
  else
  echo Running with x, not disowning!
 -fork &> /tmp/pndrun$BASENAME.out
 +fork &> /tmp/pndrun$BASENAME$mount.out
  fi