pnd_run.sh: move pre/post-run scripts where env is set up
authorGrazvydas Ignotas <notasas@gmail.com>
Sun, 13 Sep 2015 16:58:37 +0000 (19:58 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 13 Sep 2015 16:58:37 +0000 (19:58 +0300)
Note: pre was run before env was set up and post still with env set,
now both are ran with env (PATH and LD_LIBRARY_PATH) set, so things may
break. This is unlikely though as almost nobody is using pre/post scripts.

testdata/scripts/pnd_run.sh

index abf1b1e..2244ef3 100755 (executable)
@@ -561,6 +561,12 @@ runApp() {
        export XDG_DATA_HOME="$HOME"
        export XDG_CACHE_HOME="$HOME"
 
        export XDG_DATA_HOME="$HOME"
        export XDG_CACHE_HOME="$HOME"
 
+       if [ -e "${APPDATADIR}/PND_pre_script.sh" ]; then
+               echo "Starting user configured pre-script ${APPDATADIR}/PND_pre_script.sh"
+               . ${APPDATADIR}/PND_pre_script.sh # Sourcing so it can shared vars with post-script ;)
+               echo "${APPDATADIR}/PND_pre_script.sh is done"
+       fi
+
        if [ "$DOTSLASH" = "true" ]; then
                "$EXENAME" $ARGUMENTS "$@"
        else
        if [ "$DOTSLASH" = "true" ]; then
                "$EXENAME" $ARGUMENTS "$@"
        else
@@ -571,6 +577,12 @@ runApp() {
        #the app could have exited now, OR it went into bg, we still need to wait in that case till it really quits!
        LD_LIBRARY_PATH= PATH="$REAL_PATH" PND_WaitForExit "$EXENAME"
 
        #the app could have exited now, OR it went into bg, we still need to wait in that case till it really quits!
        LD_LIBRARY_PATH= PATH="$REAL_PATH" PND_WaitForExit "$EXENAME"
 
+       if [ -e "${APPDATADIR}/PND_post_script.sh" ]; then
+               echo "Starting user configured post-script ${APPDATADIR}/PND_post_script.sh"
+               . ${APPDATADIR}/PND_post_script.sh
+               echo "${APPDATADIR}/PND_post_script.sh is done"
+       fi
+
        # clean up to avoid any effects of the .pnd on the remaining parts of this script
        unset LD_LIBRARY_PATH
        export HOME="$REAL_HOME"
        # clean up to avoid any effects of the .pnd on the remaining parts of this script
        unset LD_LIBRARY_PATH
        export HOME="$REAL_HOME"
@@ -611,21 +623,11 @@ main() {
                fi
                oPWD=$(pwd)
                old_fb0_geometry=$(fbset -fb /dev/fb0 -s | grep geometry | awk '{print $2, $3, $4, $5, $6}')
                fi
                oPWD=$(pwd)
                old_fb0_geometry=$(fbset -fb /dev/fb0 -s | grep geometry | awk '{print $2, $3, $4, $5, $6}')
-               if [ -e "${APPDATADIR}/PND_pre_script.sh" ]; then
-                       PND_BeginTask "Starting user configured pre-script"
-                       . ${APPDATADIR}/PND_pre_script.sh # Sourcing so it can shared vars with post-script ;)
-                       PND_EndTask
-               fi
 
                PND_BeginTask "Starting the application ( $EXENAME $ARGUMENTS "$@")"
                runApp "$@"
                PND_EndTask
 
 
                PND_BeginTask "Starting the application ( $EXENAME $ARGUMENTS "$@")"
                runApp "$@"
                PND_EndTask
 
-               if [ -e "${APPDATADIR}/PND_post_script.sh" ]; then
-                       PND_BeginTask "Starting user configured post-script"
-                       . ${APPDATADIR}/PND_post_script.sh
-                       PND_EndTask
-               fi
                cd $oPWD
                if [ $CLOSE_X ]; then
                        PND_BeginTask "Restarting X"
                cd $oPWD
                if [ $CLOSE_X ]; then
                        PND_BeginTask "Restarting X"