pndevmapperd: support multiple charge devices
[pandora-libraries.git] / testdata / scripts / pnd_run.sh
index 62b8ebb..c009a3e 100755 (executable)
@@ -259,7 +259,7 @@ PND_RestartX(){
 show_mounted_info(){
        echo "+++++++"
        echo "Loopback devices :"
-       sudo losetup -a
+       sudo /sbin/losetup -a
        echo "Are mounted on :"
        mount|grep loop
        echo "For these Union :"
@@ -287,7 +287,7 @@ mountPnd() {
        MOUNT_TARGET="${1:-$PND_MOUNT_DIR}"
        if ! is_pnd_mounted;then
                #check if pnd is already attached to loop 
-               LOOP=$(losetup -a | grep "$PND" | tail -n1 | awk -F: '{print $1}')
+               LOOP=$(/sbin/losetup -a | grep "$PND" | tail -n1 | awk -F: '{print $1}')
                #check if the loop device is already mounted
                if ! [ -z "$LOOP" ];then
                        echo "Found a loop ($LOOP), using it"
@@ -314,8 +314,8 @@ mountPnd() {
                        #detect fs
                        case $PND_FSTYPE in
                        ISO)
-                               /sbin/losetup $FREELOOP "$PND" #attach the pnd to the loop device
-                               mntline="mount" #setup the mountline for later
+                               /sbin/losetup -r $FREELOOP "$PND" #attach the pnd to the loop device
+                               mntline="mount -o ro" #setup the mountline for later
                                mntdev="${FREELOOP}"
                                ;;
                        directory)
@@ -325,8 +325,8 @@ mountPnd() {
                                mntdev="${PND}"
                                ;;
                        Squashfs)
-                               /sbin/losetup $FREELOOP "$PND" #attach the pnd to the loop device
-                               mntline="mount -t squashfs"
+                               /sbin/losetup -r $FREELOOP "$PND" #attach the pnd to the loop device
+                               mntline="mount -t squashfs -o ro"
                                mntdev="${FREELOOP}"
                                ;;
                        *)
@@ -443,11 +443,11 @@ cleanups() {
 
        # Clean the loopback device
        if [ $PND_FSTYPE = ISO ] || [ $PND_FSTYPE = Squashfs ]; then # check if we where running an iso, clean up loop device if we did
-               LOOP=$(losetup -a | grep "$(basename $PND)" | tail -n1 | awk -F: '{print $1}')
+               LOOP=$(/sbin/losetup -a | grep "$(basename $PND)" | tail -n1 | awk -F: '{print $1}')
                /sbin/losetup -d $LOOP
                #rm $LOOP
        fi
-       losetup -a|cut -d':' -f 1|while read l;do
+       /sbin/losetup -a|cut -d':' -f 1|while read l;do
                if ! mount|grep -q $l;then
                        echo "WARNING Found $l loop as unused. flushing"
                        /sbin/losetup -d $l
@@ -537,6 +537,8 @@ runApp() {
        fi
 
        export XDG_CONFIG_HOME="$UNION_MOUNT_DIR/$PND_NAME"
+       export REAL_HOME="$HOME"
+       export HOME="$UNION_MOUNT_DIR/$PND_NAME"
 
        if echo "$EXENAME"|grep -q ^\.\/;then
                "$EXENAME" $ARGUMENTS
@@ -551,6 +553,7 @@ runApp() {
                sleep 10s
                PID=`pidof -o %PPID -x \"$EXENAME\"`
        done
+       export HOME="$REAL_HOME"
        return $RC
 }
 
@@ -606,6 +609,11 @@ main() {
                        PND_resetCPUSpeed
                        PND_EndTask
                fi
+               if ! lsof /dev/fb1 > /dev/null; then
+                       PND_BeginTask "Restoring the frame buffer status"
+                       ofbset -fb /dev/fb1 -mem 0 -size 0 0 -en 0
+                       PND_EndTask
+               fi
                PND_BeginTask "uMount the PND"
                umountUnion
                PND_EndTask