pandora-scripts: First (working) version of mass storage script. Needs more checks :)
authorMichael Mrozek <EvilDragon@openpandora.de>
Mon, 21 Jun 2010 01:01:02 +0000 (03:01 +0200)
committerMichael Mrozek <EvilDragon@openpandora.de>
Mon, 21 Jun 2010 01:01:02 +0000 (03:01 +0200)
recipes/pandora-system/pandora-scripts/op_storage.sh [new file with mode: 0755]

diff --git a/recipes/pandora-system/pandora-scripts/op_storage.sh b/recipes/pandora-system/pandora-scripts/op_storage.sh
new file mode 100755 (executable)
index 0000000..760cff6
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+while mainsel=$(zenity --title="SD Card Mass Storage" --width="380" --height="200" --list --column "id" --column "Please select" --hide-column=1 --text="What do you want to do?" "sd1" "Switch SD Card 1 to Mass Storage Mode" "sd2" "Switch SD Card 2 to Mass Storage Mode" ); do
+  case $mainsel in
+  "sd1")
+  remount=$(cat /proc/mounts | grep /dev/mmcblk0p1 | awk '{print "mount " $1 " " $2 " -o " $4}' | sed "s/,codepage=[A-Za-z0-9]*,/,/g")
+  if umount /dev/mmcblk0p1
+  then
+    # switch to mass storage
+    rmmod g_cdc
+    modprobe g_file_storage file=/dev/mmcblk0p1 stall=0
+    zenity --title="SD Card 1 Mass Storage Mode" --info --text="SD Card Slot 1 is currently in Mass Storage Mode.\n\nClick on OK when you're finished with your data transfer\nand want to go back to normal mode."
+    rmmod g_file_storage
+    modprobe g_cdc
+    $remount
+  else
+     zenity --title="Error" --error --text="Error.\nEither there is no card in SD Slot 1 or some program\nis currently accessing the card.\n\nPlease make sure to close any programs that currently access te SD Card." --timeout 6
+  fi
+  ;;
+  "sd2")
+  remount=$(cat /proc/mounts | grep /dev/mmcblk0p1 | awk '{print "mount " $1 " " $2 " -o " $4}' | sed "s/,codepage=[A-Za-z0-9]*,/,/g")
+  if umount /dev/mmcblk1p1
+  then
+    # switch to mass storage
+    rmmod g_cdc
+    modprobe g_file_storage file=/dev/mmcblk1p1 stall=0
+    zenity --title="SD Card 2 Mass Storage Mode" --info --text="SD Card Slot 2 is currently in Mass Storage Mode.\n\nClick on OK when you're finished with your data transfer\nand want to go back to normal mode."
+    rmmod g_file_storage
+    insmod g_cdc
+    $remount
+  else
+     zenity --title="Error" --error --text="Error.\nEither there is no card in SD Slot 2 or some program\nis currently accessing the card.\n\nPlease make sure to close any programs that currently access te SD Card." --timeout 6
+  fi
+  ;;
+  esac
+done
\ No newline at end of file