Hi.. I need to run a script AFTER the sdcard is mounted. However, it seems that my script is always run before or when the sdcard is not mounted yet. My phone is rooted already.
This is my script, located at /etc/init.d/myscript.sh
How should I fix this code so that the script can always find /storage/0764-8617/foo.img
this is what mounted in my phone:
cat /proc/mounts
p/s: I have found a way quite simple, but crazy solution to my problem by directly check and wait for the file and IT WORKS.
but my question is still open: Suppose I don't know the file name "foo.img", how do I make sure that the sd card is fully loaded, and the script above can find /storage/0764-8617/foo.img?
This is my script, located at /etc/init.d/myscript.sh
Code:
#!system/bin/sh
#this is to show that my script is run properly as root.
chmod 777 /cache
mkdir /cache/foo
### and it runs without any problem. So far so good.
#now I want to check if there is file "foo.img" at my external sd card "/storage/0764-8617"
#of course, there IS the file at /storage/0764-8617
#i tried all "wait", "loop" below to make sure sdcard is loaded before the "if" block below..
wait /dev/block/loop1
count=10
until [ -d /storage/0764-8617 ] || [ $count -lt 1 ];
do
sleep 1
count=$((count-1));
done;
sleep 10
if [ -f /storage/0764-8617/foo.img ] ; then
echo "File existed
else
echo "File not found"
fi
#but it always spits out that "File not found!"
this is what mounted in my phone:
cat /proc/mounts
p/s: I have found a way quite simple, but crazy solution to my problem by directly check and wait for the file and IT WORKS.
Code:
until [ -f /storage/0764-8617/foo.img] || [ $count -lt 1 ];
from xda-developers http://ift.tt/2bngZvP
via IFTTT
Aucun commentaire:
Enregistrer un commentaire