2012-10-02 22:45:45 +00:00
|
|
|
#!/bin/sh
|
|
|
|
export LC_ALL="en_US.UTF-8"
|
|
|
|
|
2012-12-12 02:02:32 +00:00
|
|
|
PROC_KEYPAD="/proc/keypad"
|
|
|
|
PROC_FIVEWAY="/proc/fiveway"
|
2013-09-29 19:30:14 +00:00
|
|
|
[ -e $PROC_KEYPAD ] && echo unlock > $PROC_KEYPAD
|
|
|
|
[ -e $PROC_FIVEWAY ] && echo unlock > $PROC_FIVEWAY
|
|
|
|
|
|
|
|
# By default, don't stop the framework.
|
|
|
|
if [ "$1" == "--framework_stop" ] ; then
|
|
|
|
shift 1
|
|
|
|
STOP_FRAMEWORK="yes"
|
|
|
|
# Yield a bit to let stuff stop properly...
|
|
|
|
echo "Stopping framework . . ."
|
|
|
|
sleep 2
|
|
|
|
else
|
|
|
|
STOP_FRAMEWORK="no"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check which type of init system we're using
|
|
|
|
if [ -d /etc/upstart ] ; then
|
|
|
|
INIT_TYPE="upstart"
|
|
|
|
else
|
|
|
|
INIT_TYPE="sysv"
|
|
|
|
fi
|
2012-10-02 22:45:45 +00:00
|
|
|
|
|
|
|
# we're always starting from our working directory
|
2013-09-29 19:30:14 +00:00
|
|
|
cd /mnt/us/koreader
|
2012-10-02 22:45:45 +00:00
|
|
|
|
2013-04-23 22:59:52 +00:00
|
|
|
# export trained OCR data directory
|
|
|
|
export TESSDATA_PREFIX="data"
|
|
|
|
|
2013-04-30 10:47:30 +00:00
|
|
|
# export dict directory
|
|
|
|
export STARDICT_DATA_DIR="data/dict"
|
|
|
|
|
2012-10-02 22:45:45 +00:00
|
|
|
# bind-mount system fonts
|
2013-09-29 19:30:14 +00:00
|
|
|
if ! grep /mnt/us/koreader/fonts/host /proc/mounts ; then
|
2013-03-24 16:22:22 +00:00
|
|
|
mount -o bind /usr/java/lib/fonts /mnt/us/koreader/fonts/host
|
2012-10-02 22:45:45 +00:00
|
|
|
fi
|
|
|
|
|
2013-09-29 19:30:14 +00:00
|
|
|
# bind-mount altfonts
|
|
|
|
if [ -d /mnt/us/fonts ] ; then
|
|
|
|
mkdir -p /mnt/us/koreader/fonts/altfonts
|
|
|
|
if ! grep /mnt/us/koreader/fonts/altfonts /proc/mounts ; then
|
|
|
|
mount -o bind /mnt/us/fonts /mnt/us/koreader/fonts/altfonts
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# bind-mount linkfonts
|
|
|
|
if [ -d /mnt/us/linkfonts/fonts ] ; then
|
|
|
|
mkdir -p /mnt/us/koreader/fonts/linkfonts
|
|
|
|
if ! grep /mnt/us/koreader/fonts/linkfonts /proc/mounts ; then
|
|
|
|
mount -o bind /mnt/us/linkfonts/fonts /mnt/us/koreader/fonts/linkfonts
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-10-02 22:45:45 +00:00
|
|
|
# check if we are supposed to shut down the Amazon framework
|
2013-09-29 19:30:14 +00:00
|
|
|
if [ "${STOP_FRAMEWORK}" == "yes" ]; then
|
|
|
|
# Upstart or SysV?
|
|
|
|
if [ "${INIT_TYPE}" == "sysv" ] ; then
|
|
|
|
/etc/init.d/framework stop
|
|
|
|
else
|
|
|
|
# The framework job sends a SIGTERM on stop, trap it so we don't get killed if we were launched by KUAL
|
|
|
|
trap "" SIGTERM
|
|
|
|
stop lab126_gui
|
|
|
|
fi
|
2012-10-02 22:45:45 +00:00
|
|
|
fi
|
|
|
|
|
2013-06-13 08:42:19 +00:00
|
|
|
# check if kpvbooklet was launched for more than once, if not we will disable pillow
|
2013-09-29 19:30:14 +00:00
|
|
|
# there's no pillow if we stopped the framework, and it's only there on systems with upstart anyway
|
|
|
|
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
|
|
|
|
count=`lipc-get-prop -eiq com.github.koreader.kpvbooklet.timer count`
|
|
|
|
if [ "$count" == "" -o "$count" == "0" ]; then
|
|
|
|
lipc-set-prop com.lab126.pillow disableEnablePillow disable
|
|
|
|
fi
|
2013-06-13 08:42:19 +00:00
|
|
|
fi
|
2013-03-12 14:14:17 +00:00
|
|
|
|
2013-09-29 19:54:23 +00:00
|
|
|
# stop cvm (sysv & framework up only)
|
|
|
|
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "sysv" ] ; then
|
|
|
|
killall -stop cvm
|
|
|
|
fi
|
2012-10-02 22:45:45 +00:00
|
|
|
|
|
|
|
# finally call reader
|
2013-08-06 14:53:44 +00:00
|
|
|
./reader.lua "$@" 2> crash.log
|
2012-10-02 22:45:45 +00:00
|
|
|
|
2013-07-12 03:11:28 +00:00
|
|
|
# clean up forked process in case the reader crashed
|
2013-09-29 19:30:14 +00:00
|
|
|
if [ "${INIT_TYPE}" == "sysv" ] ; then
|
|
|
|
killall -TERM reader.lua
|
|
|
|
else
|
|
|
|
# We trapped SIGTERM, remember? ;)
|
|
|
|
killall -KILL reader.lua
|
|
|
|
fi
|
2013-07-12 03:11:28 +00:00
|
|
|
|
2012-10-02 22:45:45 +00:00
|
|
|
# unmount system fonts
|
2013-09-29 19:30:14 +00:00
|
|
|
if grep /mnt/us/koreader/fonts/host /proc/mounts ; then
|
2013-03-24 16:22:22 +00:00
|
|
|
umount /mnt/us/koreader/fonts/host
|
2012-10-02 22:45:45 +00:00
|
|
|
fi
|
|
|
|
|
2013-09-29 19:30:14 +00:00
|
|
|
# unmount altfonts
|
|
|
|
if grep /mnt/us/koreader/fonts/altfonts /proc/mounts ; then
|
|
|
|
umount /mnt/us/koreader/fonts/altfonts
|
|
|
|
fi
|
|
|
|
|
|
|
|
# unmount linkfonts
|
|
|
|
if grep /mnt/us/koreader/fonts/linkfonts /proc/mounts ; then
|
|
|
|
umount /mnt/us/koreader/fonts/linkfonts
|
|
|
|
fi
|
|
|
|
|
2012-10-02 22:45:45 +00:00
|
|
|
# always try to continue cvm
|
2013-09-29 19:30:14 +00:00
|
|
|
if ! killall -cont cvm ; then
|
|
|
|
if [ "${INIT_TYPE}" == "sysv" ] ; then
|
|
|
|
/etc/init.d/framework start
|
|
|
|
else
|
|
|
|
start lab126_gui
|
|
|
|
fi
|
|
|
|
fi
|
2013-03-12 14:14:17 +00:00
|
|
|
|
2013-09-29 19:30:14 +00:00
|
|
|
# display chrome bar (upstart & framework up only)
|
|
|
|
if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then
|
|
|
|
lipc-set-prop com.lab126.pillow disableEnablePillow enable
|
|
|
|
fi
|
2013-03-12 14:14:17 +00:00
|
|
|
|