pnd_run.sh: restore nub settings on last pnd exit
authorGrazvydas Ignotas <notasas@gmail.com>
Sun, 19 Oct 2014 23:19:03 +0000 (02:19 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 19 Oct 2014 23:19:03 +0000 (02:19 +0300)
For misbehaving PNDs. Idea by LinuxSwat.

testdata/scripts/pnd_run.sh

index ab02b26..c6cdc9b 100755 (executable)
@@ -626,6 +626,17 @@ main() {
                        ofbset -fb /dev/fb1 -mem 0 -size 0 0 -en 0
                fi
                PND_EndTask
+
+               running_pnd_count=$(ps ax | grep "pnd_run.s[h]" | wc -l)
+               # restore settings if we are the last exiting pnd
+               # compare with 2 because one is used by subshell where "ps ax | ..." runs
+               if [ "$running_pnd_count" -eq "2" ]; then
+                       PND_BeginTask "Restoring nub mode"
+                       sed -n '1p' /etc/pandora/conf/nubs.state > /proc/pandora/nub0/mode
+                       sed -n '7p' /etc/pandora/conf/nubs.state > /proc/pandora/nub1/mode
+                       PND_EndTask
+               fi
+
                PND_BeginTask "uMount the PND"
                umountUnion
                PND_EndTask