2015-01-12 16:14:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
export LC_ALL="en_US.UTF-8"
|
|
|
|
|
|
|
|
# working directory of koreader
|
2015-01-17 01:09:36 +00:00
|
|
|
KOREADER_DIR=/mnt/ext1/applications/koreader
|
2015-01-12 16:14:56 +00:00
|
|
|
|
|
|
|
# update to new version from OTA directory
|
|
|
|
NEWUPDATE="${KOREADER_DIR}/ota/koreader.updated.tar"
|
|
|
|
INSTALLED="${KOREADER_DIR}/ota/koreader.installed.tar"
|
2017-04-23 01:59:22 +00:00
|
|
|
if [ -f "${NEWUPDATE}" ]; then
|
2015-01-12 16:14:56 +00:00
|
|
|
# TODO: any graphic indication for the updating progress?
|
2017-04-24 00:02:55 +00:00
|
|
|
cd /mnt/ext1/ && "${KOREADER_DIR}/tar" xf "${NEWUPDATE}" --no-same-permissions --no-same-owner \
|
2017-04-23 01:59:22 +00:00
|
|
|
&& mv "${NEWUPDATE}" "${INSTALLED}"
|
|
|
|
rm -f "${NEWUPDATE}" # always purge newupdate in all cases to prevent update loop
|
2015-01-12 16:14:56 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# we're always starting from our working directory
|
2017-04-11 09:23:42 +00:00
|
|
|
cd ${KOREADER_DIR} || exit
|
2015-01-12 16:14:56 +00:00
|
|
|
|
2015-02-07 04:40:36 +00:00
|
|
|
# export load library path for some old firmware
|
2017-04-11 09:23:42 +00:00
|
|
|
export LD_LIBRARY_PATH=${KOREADER_DIR}/libs:${LD_LIBRARY_PATH}
|
2015-02-07 04:40:36 +00:00
|
|
|
|
2015-01-12 16:14:56 +00:00
|
|
|
# export trained OCR data directory
|
|
|
|
export TESSDATA_PREFIX="data"
|
|
|
|
|
|
|
|
# export dict directory
|
|
|
|
export STARDICT_DATA_DIR="data/dict"
|
|
|
|
|
2015-01-27 18:17:54 +00:00
|
|
|
# export external font directory
|
|
|
|
export EXT_FONT_DIR="/mnt/ext1/fonts"
|
2015-01-25 08:52:01 +00:00
|
|
|
|
2017-04-11 09:23:42 +00:00
|
|
|
# shellcheck disable=2000
|
|
|
|
if [ "$(echo "$@" | wc -c)" -eq 1 ]; then
|
2015-01-17 01:09:36 +00:00
|
|
|
args="/mnt/ext1/"
|
|
|
|
else
|
2017-04-11 09:23:42 +00:00
|
|
|
args="$*"
|
2015-01-17 01:09:36 +00:00
|
|
|
fi
|
|
|
|
|
2016-12-05 01:02:35 +00:00
|
|
|
# we keep maximum 500K worth of crash log
|
2017-04-11 09:23:42 +00:00
|
|
|
if [ -e crash.log ]; then
|
2017-04-11 09:28:01 +00:00
|
|
|
tail -c 500000 crash.log >crash.log.new
|
2017-04-11 09:23:42 +00:00
|
|
|
mv -f crash.log.new crash.log
|
|
|
|
fi
|
|
|
|
|
2017-05-16 09:11:11 +00:00
|
|
|
RETURN_VALUE=85
|
|
|
|
while [ $RETURN_VALUE -eq 85 ]; do
|
|
|
|
./reader.lua "${args}" >>crash.log 2>&1
|
|
|
|
RETURN_VALUE=$?
|
|
|
|
done
|
2015-01-12 16:14:56 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
if pidof reader.lua >/dev/null 2>&1; then
|
2017-04-11 09:23:42 +00:00
|
|
|
killall -TERM reader.lua
|
2015-01-12 16:14:56 +00:00
|
|
|
fi
|
2017-05-16 09:11:11 +00:00
|
|
|
|
|
|
|
exit $RETURN_VALUE
|