blob: fc9a2c4cd748fe77a8b1c60d56978c5683021afc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/system/bin/sh
CONFIG_FILE="$1"
CONFIG_PARAMS="mount_options mount_source mount_target mount_max_retries mount_retry_interval"
# source user-specified config file
if [ -r "${CONFIG_FILE}" ]; then
. "${CONFIG_FILE}" >> "${LOG_FILE}" 2>&1
missing_count=0
for p in ${CONFIG_PARAMS}; do
if [[ -z $(eval "echo \"\$${p}\"") ]]; then
echo "Config file \"${CONFIG_FILE}\" is missing param \"${p}\"." >> "${LOG_FILE}" 2>&1
missing_count=$((missing_count+1))
fi
done
if [ ${missing_count} -gt 0 ]; then
exit
fi
else
echo "Unable to read config file \"${CONFIG_FILE}\"." >> "${LOG_FILE}" 2>&1
exit
fi
# attempt to mount
mkdir -p "${mount_target}" >> "${LOG_FILE}" 2>&1
retries=0
while : ; do
su -c "mount ${mount_options} \"${mount_source}\" \"${mount_target}\"" >> "${LOG_FILE}" 2>&1
if grep -q "${mount_target}" /proc/mounts; then
echo "Successfully mounted source \"${mount_source}\" at \"${mount_target}\"." >> "${LOG_FILE}" 2>&1
break
elif [ ${retries} -lt "${mount_max_retries}" ]; then
sleep "${mount_retry_interval}"
retries=$((retries+1))
else
echo "Failed to mount source \"${mount_source}\" at \"${mount_target}\" after $((retries+1)) attempts (${retries} retries)." >> "${LOG_FILE}" 2>&1
exit
fi
done
|