aboutsummaryrefslogtreecommitdiffstats
path: root/service.sh
diff options
context:
space:
mode:
Diffstat (limited to 'service.sh')
-rw-r--r--service.sh33
1 files changed, 17 insertions, 16 deletions
diff --git a/service.sh b/service.sh
index 37f50dd..7740dc1 100644
--- a/service.sh
+++ b/service.sh
@@ -8,7 +8,7 @@ export LOG_FILE="${MODDIR}/magisk-fstab.log"
LOG_MAX_LINES=1000
BOOTWAIT_MAX_COUNT=20
-BOOTWAIT_COUNT_INTERVAL=15s
+BOOTWAIT_COUNT_INTERVAL=15
CONF_MAIN="${MODDIR}/config/main.conf"
CONF_FSTAB="${MODDIR}/config/fstab.conf"
@@ -16,38 +16,39 @@ CONF_FSTAB="${MODDIR}/config/fstab.conf"
# Check if configs are readable
if [ ! -r "$CONF_MAIN" ]; then
- echo "File '$CONF_MAIN' not readable."
- exit 2
+ echo "File '$CONF_MAIN' not readable." >>"${LOG_FILE}" 2>&1
+ exit 2
fi
if [ ! -r "$CONF_FSTAB" ]; then
- echo "File '$CONF_FSTAB' not readable."
- exit 2
+ echo "File '$CONF_FSTAB' not readable." >>"${LOG_FILE}" 2>&1
+ exit 2
fi
# Read main config
-. "${CONF_MAIN}" >> "${LOG_FILE}" 2>&1
+. "${CONF_MAIN}" >>"${LOG_FILE}" 2>&1
# wait for system boot to complete
bootwait_count=0
-until [[ $(getprop sys.boot_completed) || ${bootwait_count} -ge ${BOOTWAIT_MAX_COUNT} ]]; do
- sleep ${BOOTWAIT_COUNT_INTERVAL}
- bootwait_count=$((bootwait_count+1))
+while [ "$(getprop sys.boot_completed)" != "1" ] && [ ${bootwait_count} -lt ${BOOTWAIT_MAX_COUNT} ]; do
+ sleep ${BOOTWAIT_COUNT_INTERVAL}
+ bootwait_count=$((bootwait_count + 1))
done
if [ ${bootwait_count} -ge ${BOOTWAIT_MAX_COUNT} ]; then
- exit 1
+ echo "Boot wait timeout" >>"${LOG_FILE}" 2>&1
+ exit 1
fi
# prevent log file from growing too large
-tail -n "${LOG_MAX_LINES}" "${LOG_FILE}" > "${LOGFILE}.tmp"
-mv "${LOGFILE}.tmp" "${LOG_FILE}"
+tail -n "${LOG_MAX_LINES}" "${LOG_FILE}" >"${LOG_FILE}.tmp"
+mv "${LOG_FILE}.tmp" "${LOG_FILE}"
-echo "=== $(date) ===" >> "${LOG_FILE}" 2>&1
+echo "=== $(date) ===" >>"${LOG_FILE}" 2>&1
-if [ -f "${CONF}" ]
- "${MODDIR}/fstab.sh" "${CONF_FSTAB}" &
+if [ -f "${CONF_FSTAB}" ]; then
+ /system/bin/sh "${MODDIR}/fstab.sh" --su-options "${su_options}" --log-file "${LOG_FILE}" "${CONF_FSTAB}" &
else
- echo "${CONF} not found." >> "${LOG_FILE}" 2>&1
+ echo "${CONF_FSTAB} not found." >>"${LOG_FILE}" 2>&1
fi
wait