2
0
mirror of https://gitlab.com/Nanolx/NanoDroid synced 2024-10-31 09:20:23 +00:00
NanoDroid/Full/system/etc/init.d/40_external_sd
2019-05-08 17:09:16 +00:00

43 lines
983 B
Bash
Executable File

#!/system/bin/sh
echo "external_sd init script"
# be sure init.rc post-fs-data completed
until [ `getprop vold.post_fs_data_done`. = 1. ]; do sleep 1; done
if getprop ro.build.characteristics | grep -q nosdcard; then
echo ">> no SD Card Slot"
exit 0
else
media_rw=$(grep "^/dev/block.*/mnt/media_rw" /proc/mounts \
| cut -d " " -f 2 \
| cut -d "/" -f 4)
storage="/storage/${media_rw}"
fi
if [[ -d ${storage} ]]; then
echo ">> SD Card inserted"
echo ">> storage: \"${storage}\""
if [[ -e /external_sd ]]; then
link=$(ls -l /external_sd | sed -e 's/.*-> //g')
if [[ "${link}" != "${storage}" ]]; then
echo ">> removing old link: \"${link}\""
mount -orw,remount /
rm -f /external_sd
mount -oro,remount /
fi
fi
if [[ -e /external_sd ]]; then
echo ">> /external_sd link up to date"
else
echo ">> /external_sd link created"
mount -orw,remount /
ln -sf ${storage} /external_sd
mount -oro,remount /
fi
else
echo ">> no SD Card inserted"
fi