op_cpusettings.sh: Shows warning message if user tries to change OPP with experimenta...
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_storage.sh
1 #!/bin/bash
2 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
3 selection2=$(echo "$selection" | sed 's/ /\\\\040/g')
4 options=$(grep "${selection2}" /proc/mounts | awk '{print $4}' | sed "s/,codepage=[A-Za-z0-9]*,/,/g" | sed 's/\\040/\\ /g' )
5 device=$(grep "${selection2}" /proc/mounts | awk '{print substr($1,1,12)}')
6 device2=$(grep "${selection2}" /proc/mounts | awk '{print $1}')
7
8 if umount $device2
9  
10   then
11     # switch to mass storage
12    if lsmod | grep g_cdc &>/dev/null
13         then
14         echo Found g_cdc - removing...
15         rmmod g_cdc
16         sleep 2
17         ethernet=1
18     fi
19    modprobe g_file_storage file=$device stall=0
20    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."
21     rmmod g_file_storage
22     if [ $ethernet=1 ]; then
23       echo Reloading g_cdc...
24       modprobe g_cdc
25     fi
26    if [ ! -d "$selection" ]; then
27     mkdir "$selection"
28    fi 
29         mount $device2 "$selection" -o $options
30   else
31      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
32 fi
33 done