2018-10-31 22:48:36 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Standalone KOReader application for BQ Cervantes
|
|
|
|
# this file is intended to replace /etc/rc.local on BQ developers firmware
|
|
|
|
|
|
|
|
# turn off the green flashing led.
|
|
|
|
echo "ch 4" >/sys/devices/platform/pmic_light.1/lit
|
|
|
|
echo "cur 0" >/sys/devices/platform/pmic_light.1/lit
|
|
|
|
echo "dc 0" >/sys/devices/platform/pmic_light.1/lit
|
|
|
|
|
|
|
|
# ensure we have a proper time.
|
|
|
|
if [ "$(date '+%Y')" -lt 2010 ]; then
|
|
|
|
echo "Fixing date before 2010"
|
|
|
|
date +%Y%m%d -s "20100101"
|
|
|
|
hwclock -w
|
|
|
|
fi
|
|
|
|
|
|
|
|
# assign public & private partition devices based on pcb.
|
|
|
|
PCB_ID=$(/usr/bin/ntxinfo /dev/mmcblk0 | grep pcb | cut -d ":" -f2)
|
2020-02-02 19:35:21 +00:00
|
|
|
if [ "${PCB_ID}" -eq 22 ] || [ "${PCB_ID}" -eq 23 ]; then
|
2018-10-31 22:48:36 +00:00
|
|
|
PRIVATE="/dev/mmcblk0p5"
|
|
|
|
PUBLIC="/dev/mmcblk0p7"
|
|
|
|
else
|
|
|
|
PRIVATE="/dev/mmcblk0p7"
|
|
|
|
PUBLIC="/dev/mmcblk0p4"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# mount internal partitions
|
2020-02-02 19:35:21 +00:00
|
|
|
mount ${PRIVATE} /mnt/private
|
|
|
|
mount ${PUBLIC} /mnt/public
|
2018-10-31 22:48:36 +00:00
|
|
|
|
|
|
|
# mount sdcard if present
|
|
|
|
if [ -b /dev/mmcblk1p1 ]; then
|
|
|
|
mount /dev/mmcblk1p1 /mnt/sd
|
|
|
|
fi
|
|
|
|
|
2018-11-10 12:21:48 +00:00
|
|
|
# stop connman daemon, KOReader will use wpa_supplicant directly.
|
|
|
|
[ -x /etc/init.d/connman ] && /etc/init.d/connman stop
|
|
|
|
|
|
|
|
# for Cervantes 4 unload realtek module.
|
2020-02-02 19:35:21 +00:00
|
|
|
if [ "${PCB_ID}" -eq 68 ] && lsmod | grep -q 8189fs; then
|
2018-10-31 22:48:36 +00:00
|
|
|
modprobe -r 8189fs
|
|
|
|
fi
|
|
|
|
|
2018-11-10 12:25:48 +00:00
|
|
|
# use 'safemode' tool whenever possible instead of enabling usbnet unconditionally.
|
|
|
|
if [ -x /usr/bin/safemode ]; then
|
|
|
|
safemode network
|
|
|
|
else
|
|
|
|
# start usbnet using BQ scripts
|
|
|
|
/usr/bin/usbup.sh
|
|
|
|
/usr/sbin/inetd
|
|
|
|
fi
|
2018-10-31 22:48:36 +00:00
|
|
|
|
|
|
|
# check if KOReader script exists.
|
|
|
|
if [ -x /mnt/private/koreader/koreader.sh ]; then
|
|
|
|
# yada! KOReader is installed and ready to run.
|
|
|
|
while true; do
|
|
|
|
/mnt/private/koreader/koreader.sh
|
2018-11-10 12:25:48 +00:00
|
|
|
if [ -x /usr/bin/safemode ]; then
|
|
|
|
safemode storage || sleep 1
|
|
|
|
else
|
|
|
|
sleep 1
|
|
|
|
fi
|
2018-10-31 22:48:36 +00:00
|
|
|
done
|
|
|
|
else
|
2018-11-10 12:25:48 +00:00
|
|
|
# KOReader script not found or not executable.
|
|
|
|
# if 'safemode' was found enable usbnet now, since it is currently disabled
|
|
|
|
if [ -x /usr/bin/safemode ]; then
|
|
|
|
/usr/bin/usbup.sh
|
|
|
|
/usr/sbin/inetd
|
|
|
|
fi
|
|
|
|
|
2018-10-31 22:48:36 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|