X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=openpandora.oe.git;a=blobdiff_plain;f=recipes%2Fpandora-system%2Fpandora-scripts%2Fop_storage.sh;h=910443b4ef5600deb1d97485ad45f7d32fa0618c;hp=760cff6472a74f031475bf92d2ed97e85ba5fbe3;hb=ab587129c4308764e4d4e8e0430fa149c1eeb6f0;hpb=b291cdbe3e52da9d34c1a094d13f67473945cb71 diff --git a/recipes/pandora-system/pandora-scripts/op_storage.sh b/recipes/pandora-system/pandora-scripts/op_storage.sh index 760cff6..910443b 100755 --- a/recipes/pandora-system/pandora-scripts/op_storage.sh +++ b/recipes/pandora-system/pandora-scripts/op_storage.sh @@ -1,35 +1,30 @@ #!/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 +while selection=$(grep "/dev/mmcblk" /proc/mounts | cut -f 2 -d " " | sed 's/\\040/ /g' | zenity --title="SD Card Mass Storage" --width="380" --height="200" --list --text="Enable mass storage" --column="Select card"); do +selection2=$(echo $selection | sed 's/ /\\\\040/g') +options=$(grep ${selection2} /proc/mounts | awk '{print $4}' | sed "s/,codepage=[A-Za-z0-9]*,/,/g" | sed 's/\\040/\\ /g' ) +device=$(grep ${selection2} /proc/mounts | awk '{print substr($1,1,12)}') +device2=$(grep ${selection2} /proc/mounts | awk '{print $1}') + +if umount $device + 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." + if lsmod | grep g_cdc &>/dev/null + then + echo Found g_cdc - removing... + rmmod g_cdc + sleep 2 + ethernet=1 + fi + modprobe g_file_storage file=$device stall=0 + zenity --title="Mass Storage Mode" --info --text="SD Card $selection 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 + if [ $ethernet=1 ]; then + echo Reloading g_cdc... + modprobe g_cdc + fi + mount $device2 "$selection" -o $options 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 + zenity --title="Error" --error --text="Error.\nThe card could not be unmounted.\n\nPlease make sure to close any programs that currently access the SD Card." --timeout 10 +fi done \ No newline at end of file