2012-10-02 22:45:45 +00:00
#!/bin/sh
2020-01-11 03:05:14 +00:00
# NOTE: Stupid workaround to make sure the script we end up running is a *copy*,
# living in a magical land that doesn't suffer from gross filesystem deficiencies.
# Otherwise, the vfat+fuse mess means an OTA update will break the script on exit,
# and potentially leave the user in a broken state, with the WM still paused...
if [ " $( dirname " ${ 0 } " ) " != "/var/tmp" ] ; then
cp -pf " ${ 0 } " /var/tmp/koreader.sh
chmod 777 /var/tmp/koreader.sh
exec /var/tmp/koreader.sh " $@ "
fi
2012-10-02 22:45:45 +00:00
export LC_ALL = "en_US.UTF-8"
2012-12-12 02:02:32 +00:00
PROC_KEYPAD = "/proc/keypad"
PROC_FIVEWAY = "/proc/fiveway"
2018-07-01 22:23:18 +00:00
[ -e " ${ PROC_KEYPAD } " ] && echo unlock >" ${ PROC_KEYPAD } "
[ -e " ${ PROC_FIVEWAY } " ] && echo unlock >" ${ PROC_FIVEWAY } "
2013-09-29 19:30:14 +00:00
2014-08-01 17:24:38 +00:00
# KOReader's working directory
2018-09-05 23:35:48 +00:00
export KOREADER_DIR = "/mnt/us/koreader"
2014-08-01 17:15:35 +00:00
2020-01-11 03:05:14 +00:00
# NOTE: Same vfat+fuse shenanigans needed for FBInk, before we source libko...
cp -pf " ${ KOREADER_DIR } /fbink " /var/tmp/fbink
chmod 777 /var/tmp/fbink
2014-08-01 17:15:35 +00:00
# Load our helper functions...
2017-04-11 09:28:01 +00:00
if [ -f " ${ KOREADER_DIR } /libkohelper.sh " ] ; then
# shellcheck source=/dev/null
. " ${ KOREADER_DIR } /libkohelper.sh "
2014-07-04 01:55:21 +00:00
else
2017-04-11 09:28:01 +00:00
echo "Can't source helper functions, aborting!"
exit 1
2014-07-04 01:55:21 +00:00
fi
# Handle logging...
2017-04-11 09:28:01 +00:00
logmsg( ) {
# Use the right tools for the platform
if [ " ${ INIT_TYPE } " = "sysv" ] ; then
msg " koreader: ${ 1 } " "I"
elif [ " ${ INIT_TYPE } " = "upstart" ] ; then
f_log I koreader wrapper "" " ${ 1 } "
fi
# And throw that on stdout too, for the DIY crowd ;)
echo " ${ 1 } "
2014-07-04 01:55:21 +00:00
}
2014-07-09 23:17:32 +00:00
# Go away if we're on FW 5.0, it's not supported
2017-04-11 09:28:01 +00:00
if [ " ${ INIT_TYPE } " = "upstart" ] ; then
if grep '^Kindle 5\.0' /etc/prettyversion.txt >/dev/null 2>& 1; then
logmsg "FW 5.0 is not supported. Update to 5.1!"
# And... scene!
exit 0
fi
2014-07-09 23:17:32 +00:00
fi
2014-07-04 01:55:21 +00:00
# Keep track of what we do with pillow...
2022-08-07 18:11:03 +00:00
export STOP_FRAMEWORK = "no"
2016-02-29 15:59:15 +00:00
export AWESOME_STOPPED = "no"
2021-01-06 15:50:58 +00:00
export CVM_STOPPED = "no"
2018-05-18 16:54:44 +00:00
export VOLUMD_STOPPED = "no"
2015-10-16 00:54:07 +00:00
PILLOW_HARD_DISABLED = "no"
PILLOW_SOFT_DISABLED = "no"
2020-03-15 00:28:37 +00:00
USED_WMCTRL = "no"
2016-02-29 16:09:44 +00:00
PASSCODE_DISABLED = "no"
2014-07-04 01:55:21 +00:00
2021-06-16 22:23:21 +00:00
# List of services we stop in order to reclaim a tiny sliver of RAM...
2021-08-23 09:31:18 +00:00
TOGGLED_SERVICES = "stored webreader kfxreader kfxview todo tmd rcm archive scanner otav3 otaupd"
2021-06-16 22:23:21 +00:00
2018-07-07 20:27:38 +00:00
REEXEC_FLAGS = ""
2014-07-04 17:55:15 +00:00
# Keep track of if we were started through KUAL
2018-07-07 20:27:38 +00:00
if [ " ${ 1 } " = "--kual" ] ; then
shift 1
FROM_KUAL = "yes"
REEXEC_FLAGS = " ${ REEXEC_FLAGS } --kual "
else
FROM_KUAL = "no"
fi
2014-07-04 17:55:15 +00:00
2014-07-05 13:05:03 +00:00
# By default, don't stop the framework.
2018-07-07 20:27:38 +00:00
if [ " ${ 1 } " = "--framework_stop" ] ; then
2017-04-11 09:28:01 +00:00
shift 1
STOP_FRAMEWORK = "yes"
NO_SLEEP = "no"
2018-07-07 20:27:38 +00:00
REEXEC_FLAGS = " ${ REEXEC_FLAGS } --framework_stop "
elif [ " ${ 1 } " = "--asap" ] ; then
2017-04-11 09:28:01 +00:00
# Start as soon as possible, without sleeping to workaround UI quirks
shift 1
NO_SLEEP = "yes"
2018-07-07 20:27:38 +00:00
REEXEC_FLAGS = " ${ REEXEC_FLAGS } --asap "
2017-04-11 09:28:01 +00:00
# Don't sleep during eips calls either...
export EIPS_NO_SLEEP = "true"
2014-07-05 13:05:03 +00:00
else
2017-04-11 09:28:01 +00:00
NO_SLEEP = "no"
2014-07-05 13:05:03 +00:00
fi
2018-07-07 20:27:38 +00:00
# If we were started by KUAL (either Kindlet or Booklet), we have a few more things to do...
if [ " ${ FROM_KUAL } " = "yes" ] ; then
# Yield a bit to let stuff stop properly...
logmsg "Hush now . . ."
2020-09-16 19:08:47 +00:00
if [ " ${ NO_SLEEP } " = "no" ] ; then
# NOTE: This may or may not be terribly useful...
usleep 250000
fi
2018-07-07 20:27:38 +00:00
# If we were started by the KUAL Kindlet, and not the Booklet, we have a nice value to correct...
if [ " $( nice) " = "5" ] ; then
# Kindlet threads spawn with a nice value of 5, go back to a neutral value
logmsg "Be nice!"
renice -n -5 $$
2017-04-11 09:28:01 +00:00
fi
2014-07-04 01:55:21 +00:00
fi
2014-08-01 17:15:35 +00:00
# we're always starting from our working directory
2017-04-09 08:42:16 +00:00
cd " ${ KOREADER_DIR } " || exit
2014-08-01 04:36:32 +00:00
2014-08-01 17:15:35 +00:00
# Handle pending OTA update
2018-07-04 17:25:55 +00:00
ko_update_check( ) {
NEWUPDATE = " ${ KOREADER_DIR } /ota/koreader.updated.tar "
INSTALLED = " ${ KOREADER_DIR } /ota/koreader.installed.tar "
if [ -f " ${ NEWUPDATE } " ] ; then
2018-09-05 23:35:48 +00:00
logmsg "Updating KOReader . . ."
# Let our checkpoint script handle the detailed visual feedback...
eips_print_bottom_centered "Updating KOReader" 3
2021-04-24 23:15:38 +00:00
# Setup the FBInk daemon
export FBINK_NAMED_PIPE = "/tmp/koreader.fbink"
rm -f " ${ FBINK_NAMED_PIPE } "
FBINK_PID = " $( /var/tmp/fbink --daemon 1 %KOREADER% -q -y -6 -P 0) "
2018-09-05 23:35:48 +00:00
# NOTE: See frontend/ui/otamanager.lua for a few more details on how we squeeze a percentage out of tar's checkpoint feature
# NOTE: %B should always be 512 in our case, so let stat do part of the maths for us instead of using %s ;).
FILESIZE = " $( stat -c %b " ${ NEWUPDATE } " ) "
BLOCKS = " $(( FILESIZE / 20 )) "
export CPOINTS = " $(( BLOCKS / 100 )) "
2019-02-17 21:57:05 +00:00
# NOTE: To avoid blowing up when tar truncates itself during an update, copy our GNU tar binary to the system's tmpfs,
# and run that one (c.f., #4602)...
2019-02-17 22:08:49 +00:00
# This is most likely a side-effect of the weird fuse overlay being used for /mnt/us (vs. the real vfat on /mnt/base-us),
# which we cannot use because it's been mounted noexec for a few years now...
2020-03-26 03:56:34 +00:00
cp -pf " ${ KOREADER_DIR } /tar " /var/tmp/gnutar
2018-09-05 23:35:48 +00:00
# shellcheck disable=SC2016
2021-04-24 23:15:38 +00:00
/var/tmp/gnutar --no-same-permissions --no-same-owner --checkpoint= " ${ CPOINTS } " --checkpoint-action= exec = 'printf "%s" $((TAR_CHECKPOINT / CPOINTS)) > ${FBINK_NAMED_PIPE}' -C "/mnt/us" -xf " ${ NEWUPDATE } "
2018-09-05 23:35:48 +00:00
fail = $?
2021-04-24 23:15:38 +00:00
kill -TERM " ${ FBINK_PID } "
2019-02-17 21:57:05 +00:00
# And remove our temporary tar binary...
rm -f /var/tmp/gnutar
2018-07-04 17:25:55 +00:00
# Cleanup behind us...
if [ " ${ fail } " -eq 0 ] ; then
mv " ${ NEWUPDATE } " " ${ INSTALLED } "
logmsg "Update successful :)"
eips_print_bottom_centered "Update successful :)" 2
eips_print_bottom_centered "KOReader will start momentarily . . ." 1
2019-02-17 22:08:49 +00:00
# NOTE: Because, yep, that'll probably happen, as there's a high probability sh will throw a bogus syntax error,
# probably for the same fuse-related reasons as tar...
2020-05-05 15:59:28 +00:00
# NOTE: Even if it doesn't necessarily leave the device in an unusable state,
# always recommend a hard-reboot to flush stale ghost copies...
eips_print_bottom_centered "If it doesn't, you'll want to force a hard reboot" 0
2018-07-04 17:25:55 +00:00
else
# Huh ho...
2019-02-17 21:52:57 +00:00
logmsg " Update failed :( ( ${ fail } ) "
2018-07-04 17:25:55 +00:00
eips_print_bottom_centered "Update failed :(" 2
eips_print_bottom_centered "KOReader may fail to function properly" 1
fi
2021-04-24 23:15:38 +00:00
rm -f " ${ NEWUPDATE } " # always purge newupdate to prevent update loops
unset CPOINTS FBINK_NAMED_PIPE
unset BLOCKS FILESIZE FBINK_PID
2019-12-16 23:28:51 +00:00
# Ensure everything is flushed to disk before we restart. This *will* stall for a while on slow storage!
sync
2017-04-11 09:28:01 +00:00
fi
2018-07-04 17:25:55 +00:00
}
2018-07-07 20:27:38 +00:00
# NOTE: Keep doing an initial update check, in addition to one during the restart loop, so we can pickup potential updates of this very script...
2018-07-04 17:25:55 +00:00
ko_update_check
2018-07-07 20:27:38 +00:00
# If an update happened, and was successful, reexec
if [ -n " ${ fail } " ] && [ " ${ fail } " -eq 0 ] ; then
# By now, we know we're in the right directory, and our script name is pretty much set in stone, so we can forgo using $0
# NOTE: REEXEC_FLAGS *needs* to be unquoted: we *want* word splitting here ;).
# shellcheck disable=SC2086
exec ./koreader.sh ${ REEXEC_FLAGS } " ${ @ } "
fi
2014-08-01 04:36:32 +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"
2018-06-23 22:08:11 +00:00
# export external font directories (In order: stock, stock custom (both legacy & 5.9.6+), stock extra, font hack)
2018-06-02 16:10:55 +00:00
export EXT_FONT_DIR = "/usr/java/lib/fonts;/mnt/us/fonts;/var/local/font/mnt;/mnt/us/linkfonts/fonts"
2015-01-25 08:52:01 +00:00
2018-07-01 22:23:18 +00:00
# Only setup IPTables on devices where it makes sense to do so (FW 5.x & K4)
2017-04-11 09:28:01 +00:00
if [ " ${ INIT_TYPE } " = "upstart" ] || [ " $( uname -r) " = "2.6.31-rt11-lab126" ] ; then
logmsg "Setting up IPTables rules . . ."
# accept input ports for calibre companion
iptables -A INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT
2015-09-06 14:53:24 +00:00
fi
2014-06-25 13:31:42 +00:00
2016-02-29 16:09:44 +00:00
# check if we need to disable the system passcode, because it messes with us in fun and interesting (and, more to the point, intractable) ways...
2016-02-29 17:09:24 +00:00
# NOTE: The most egregious one being that it inhibits the outOfScreenSaver event on wakeup until the passcode is validated, which we can't do, since we capture all input...
2017-04-11 09:28:01 +00:00
if [ -f "/var/local/system/userpasswdenabled" ] ; then
logmsg "Disabling system passcode . . ."
rm -f "/var/local/system/userpasswdenabled"
PASSCODE_DISABLED = "yes"
2016-02-29 16:09:44 +00:00
fi
2012-10-02 22:45:45 +00:00
# check if we are supposed to shut down the Amazon framework
2017-04-11 09:28:01 +00:00
if [ " ${ STOP_FRAMEWORK } " = "yes" ] ; then
logmsg "Stopping the framework . . ."
# 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 "" TERM
stop lab126_gui
# NOTE: Let the framework teardown finish, so we don't start before the black screen...
usleep 1250000
# And remove the trap like a ninja now!
trap - TERM
fi
2012-10-02 22:45:45 +00:00
fi
2018-11-11 01:05:38 +00:00
# Normalize a version string for easy numeric comparisons
# c.f., https://stackoverflow.com/a/37939589
2018-11-14 21:58:04 +00:00
version( ) { echo " $@ " | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }' ; }
2018-11-11 01:05:38 +00:00
2022-03-19 22:57:31 +00:00
# Detect kernels w/ CLOEXEC support
if [ " $( version " $( uname -r | sed -n -r 's/^([[:digit:]\.]*)(.*?)$/\1/p' ) " ) " -lt " $( version "2.6.23" ) " ] ; then
export KINDLE_LEGACY = "yes"
fi
2018-11-16 01:36:21 +00:00
# There's no pillow if we stopped the framework, and it's only there on systems with upstart anyway
2017-04-11 09:28:01 +00:00
if [ " ${ STOP_FRAMEWORK } " = "no" ] && [ " ${ INIT_TYPE } " = "upstart" ] ; then
2018-11-16 01:36:21 +00:00
# NOTE: If we were launched from KUAL, don't even try to deal with KPVBooklet-specific workarounds
if [ " ${ FROM_KUAL } " = "yes" ] ; then
kpv_launch_count = "0"
else
kpv_launch_count = " $( lipc-get-prop -eiq com.github.koreader.kpvbooklet.timer count) "
fi
# Check if KPVBooklet was launched more than once, if not we will disable pillow
# c.f., https://github.com/koreader/koreader/commit/60f83e842ccce57931cbed5ffcebb28515f6f5d7
if [ " ${ kpv_launch_count } " = "" ] || [ " ${ kpv_launch_count } " = "0" ] ; then
2017-04-11 09:28:01 +00:00
# NOTE: Dump the fb so we can restore something useful on exit...
cat /dev/fb0 >/var/tmp/koreader-fb.dump
2018-11-11 01:05:38 +00:00
# We're going to need our current FW version...
FW_VERSION = " $( grep '^Kindle 5' /etc/prettyversion.txt 2>& 1 | sed -n -r 's/^(Kindle)([[:blank:]]*)([[:digit:]\.]*)(.*?)$/\3/p' ) "
2017-04-11 09:28:01 +00:00
# NOTE: We want to disable the status bar (at the very least). Unfortunately, the soft hide/unhide method doesn't work properly anymore since FW 5.6.5...
2018-11-11 01:05:38 +00:00
if [ " $( version " ${ FW_VERSION } " ) " -ge " $( version "5.6.5" ) " ] ; then
2020-12-18 17:26:58 +00:00
export PILLOW_HARD_DISABLED = "yes"
2017-04-11 09:28:01 +00:00
# FIXME: So we resort to killing pillow completely on FW >= 5.6.5...
logmsg "Disabling pillow . . ."
lipc-set-prop com.lab126.pillow disableEnablePillow disable
# NOTE: And, oh, joy, on FW >= 5.7.2, this is not enough to prevent the clock from refreshing, so, take the bull by the horns, and SIGSTOP the WM while we run...
2018-11-11 01:05:38 +00:00
if [ " $( version " ${ FW_VERSION } " ) " -ge " $( version "5.7.2" ) " ] ; then
2020-03-15 00:28:37 +00:00
# Less drastically, we'll also be "minimizing" (actually, resizing) the title bar manually (c.f., https://www.mobileread.com/forums/showpost.php?p=2449275&postcount=5).
# NOTE: Hiding it "works", but has a nasty side-effect of triggering ligl timeouts in some circumstances (c.f., https://github.com/koreader/koreader/pull/5943#issuecomment-598514376)
2020-05-29 02:05:07 +00:00
# FIXME: There's apparently a nasty side-effect on FW >= 5.12.4 which somehow softlocks the UI on exit (despite wmctrl succeeding). Don't have the HW to investigate, so, just drop it. (#6117)
if [ " $( version " ${ FW_VERSION } " ) " -lt " $( version "5.12.4" ) " ] ; then
logmsg "Hiding the title bar . . ."
TITLEBAR_GEOMETRY = " $( ${ KOREADER_DIR } /wmctrl -l -G | grep ":titleBar_ID:" | awk '{print $2,$3,$4,$5,$6}' OFS = ',' ) "
${ KOREADER_DIR } /wmctrl -r ":titleBar_ID:" -e " ${ TITLEBAR_GEOMETRY %,* } ,1 "
logmsg " Title bar geometry: ' ${ TITLEBAR_GEOMETRY } ' -> ' $( ${ KOREADER_DIR } /wmctrl -l -G | grep ":titleBar_ID:" | awk '{print $2,$3,$4,$5,$6}' OFS = ',' ) ' "
USED_WMCTRL = "yes"
fi
2020-03-15 00:28:37 +00:00
if [ " ${ FROM_KUAL } " = "yes" ] ; then
logmsg "Stopping awesome . . ."
2020-05-29 02:05:07 +00:00
killall -STOP awesome
2020-03-15 00:28:37 +00:00
AWESOME_STOPPED = "yes"
fi
2017-04-11 09:28:01 +00:00
fi
else
logmsg "Hiding the status bar . . ."
# NOTE: One more great find from eureka (http://www.mobileread.com/forums/showpost.php?p=2454141&postcount=34)
lipc-set-prop com.lab126.pillow interrogatePillow '{"pillowId": "default_status_bar", "function": "nativeBridge.hideMe();"}'
2020-12-18 17:26:58 +00:00
export PILLOW_SOFT_DISABLED = "yes"
2017-04-11 09:28:01 +00:00
fi
# NOTE: We don't need to sleep at all if we've already SIGSTOPped awesome ;)
if [ " ${ NO_SLEEP } " = "no" ] && [ " ${ AWESOME_STOPPED } " = "no" ] ; then
# NOTE: Leave the framework time to refresh the screen, so we don't start before it has finished redrawing after collapsing the title bar
usleep 250000
# NOTE: If we were started from KUAL, we risk getting a list item to popup right over us, so, wait some more...
# The culprit appears to be a I WindowManager:flashTimeoutExpired:window=Root 0 0 600x30
if [ " ${ FROM_KUAL } " = "yes" ] ; then
logmsg "Playing possum to wait for the window manager . . ."
usleep 2500000
fi
fi
2021-06-16 22:23:21 +00:00
# Murder a few services to reclaim some RAM...
for job in ${ TOGGLED_SERVICES } ; do
stop " ${ job } "
done
2017-04-11 09:28:01 +00:00
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)
2017-04-11 09:28:01 +00:00
if [ " ${ STOP_FRAMEWORK } " = "no" ] && [ " ${ INIT_TYPE } " = "sysv" ] ; then
logmsg "Stopping cvm . . ."
2020-05-29 02:05:07 +00:00
killall -STOP cvm
2021-01-06 15:50:58 +00:00
CVM_STOPPED = "yes"
2013-09-29 19:54:23 +00:00
fi
2012-10-02 22:45:45 +00:00
2018-05-18 16:54:44 +00:00
# SIGSTOP volumd, to inhibit USBMS (sysv & upstart)
if [ -e "/etc/init.d/volumd" ] || [ -e "/etc/upstart/volumd.conf" ] ; then
logmsg "Stopping volumd . . ."
2020-05-29 02:05:07 +00:00
killall -STOP volumd
2018-05-18 16:54:44 +00:00
VOLUMD_STOPPED = "yes"
fi
2012-10-02 22:45:45 +00:00
# finally call reader
2014-07-04 01:55:21 +00:00
logmsg "Starting KOReader . . ."
2014-08-05 15:23:20 +00:00
# That's not necessary when using KPVBooklet ;).
2017-04-11 09:28:01 +00:00
if [ " ${ FROM_KUAL } " = "yes" ] ; then
eips_print_bottom_centered "Starting KOReader . . ." 1
2014-08-05 15:23:20 +00:00
fi
2016-10-15 03:36:00 +00:00
2018-07-01 22:23:18 +00:00
# we keep at most 500KB worth of crash log
2017-04-09 08:42:16 +00:00
if [ -e crash.log ] ; then
2017-04-11 09:28:01 +00:00
tail -c 500000 crash.log >crash.log.new
mv -f crash.log.new crash.log
2017-04-09 08:42:16 +00:00
fi
2017-05-16 09:11:11 +00:00
RETURN_VALUE = 85
2018-07-01 22:23:18 +00:00
while [ " ${ RETURN_VALUE } " -eq 85 ] ; do
2018-07-04 17:25:55 +00:00
# Do an update check now, so we can actually update KOReader via the "Restart KOReader" menu entry ;).
ko_update_check
2017-05-16 09:11:11 +00:00
./reader.lua " $@ " >>crash.log 2>& 1
RETURN_VALUE = $?
done
2012-10-02 22:45:45 +00:00
2014-07-04 01:55:21 +00:00
# clean up our own process tree in case the reader crashed (if needed, to avoid flooding KUAL's log)
2017-04-11 09:28:01 +00:00
if pidof reader.lua >/dev/null 2>& 1; then
logmsg "Sending a SIGTERM to stray KOreader processes . . ."
killall -TERM reader.lua
2013-09-29 19:30:14 +00:00
fi
2013-07-12 03:11:28 +00:00
2018-05-18 16:54:44 +00:00
# Resume volumd, if need be
if [ " ${ VOLUMD_STOPPED } " = "yes" ] ; then
logmsg "Resuming volumd . . ."
2020-05-29 02:05:07 +00:00
killall -CONT volumd
2018-05-18 16:54:44 +00:00
fi
2014-07-04 01:55:21 +00:00
# Resume cvm (only if we stopped it)
2017-04-11 09:28:01 +00:00
if [ " ${ STOP_FRAMEWORK } " = "no" ] && [ " ${ INIT_TYPE } " = "sysv" ] ; then
logmsg "Resuming cvm . . ."
2020-05-29 02:05:07 +00:00
killall -CONT cvm
2017-04-11 09:28:01 +00:00
# We need to handle the screen refresh ourselves, frontend/device/kindle/device.lua's Kindle3.exit is called before we resume cvm ;).
echo 'send 139' >/proc/keypad
echo 'send 139' >/proc/keypad
2014-07-04 01:55:21 +00:00
fi
# Restart framework (if need be)
2017-04-11 09:28:01 +00:00
if [ " ${ STOP_FRAMEWORK } " = "yes" ] ; then
logmsg "Restarting framework . . ."
if [ " ${ INIT_TYPE } " = "sysv" ] ; then
2023-07-16 01:51:57 +00:00
cd / && /etc/init.d/framework start
2017-04-11 09:28:01 +00:00
else
2023-07-16 01:51:57 +00:00
cd / && start lab126_gui
2017-04-11 09:28:01 +00:00
fi
2013-09-29 19:30:14 +00:00
fi
2013-03-12 14:14:17 +00:00
2015-10-16 00:40:03 +00:00
# Display chrome bar if need be (upstart & framework up only)
2017-04-11 09:28:01 +00:00
if [ " ${ STOP_FRAMEWORK } " = "no" ] && [ " ${ INIT_TYPE } " = "upstart" ] ; then
2021-06-19 16:10:13 +00:00
# Resume the services we murdered
for job in ${ TOGGLED_SERVICES } ; do
start " ${ job } "
done
2017-04-11 09:28:01 +00:00
# Depending on the FW version, we may have handled things in a few different manners...
if [ " ${ AWESOME_STOPPED } " = "yes" ] ; then
logmsg "Resuming awesome . . ."
2020-05-29 02:05:07 +00:00
killall -CONT awesome
2017-04-11 09:28:01 +00:00
fi
if [ " ${ PILLOW_HARD_DISABLED } " = "yes" ] ; then
logmsg "Enabling pillow . . ."
# NOTE: Try to leave the user with a slightly more useful FB content than our own last screen...
cat /var/tmp/koreader-fb.dump >/dev/fb0
rm -f /var/tmp/koreader-fb.dump
2020-03-15 00:28:37 +00:00
lipc-set-prop com.lab126.pillow disableEnablePillow enable
2017-04-11 09:28:01 +00:00
lipc-set-prop com.lab126.appmgrd start app://com.lab126.booklet.home
fi
if [ " ${ PILLOW_SOFT_DISABLED } " = "yes" ] ; then
logmsg "Restoring the status bar . . ."
# NOTE: Try to leave the user with a slightly more useful FB content than our own last screen...
cat /var/tmp/koreader-fb.dump >/dev/fb0
rm -f /var/tmp/koreader-fb.dump
lipc-set-prop com.lab126.pillow interrogatePillow '{"pillowId": "default_status_bar", "function": "nativeBridge.showMe();"}'
lipc-set-prop com.lab126.appmgrd start app://com.lab126.booklet.home
fi
2020-03-15 00:28:37 +00:00
if [ " ${ USED_WMCTRL } " = "yes" ] ; then
logmsg "Restoring the title bar . . ."
2020-03-29 03:39:41 +00:00
# NOTE: Wait and retry for a bit, because apparently there may be timing issues (c.f., #5990)?
usleep 250000
WMCTRL_COUNT = 0
until [ " $( ${ KOREADER_DIR } /wmctrl -l -G | grep ":titleBar_ID:" | awk '{print $2,$3,$4,$5,$6}' OFS = ',' ) " = " ${ TITLEBAR_GEOMETRY } " ] ; do
# Abort after 5s
if [ ${ WMCTRL_COUNT } -gt 20 ] ; then
log "Giving up on restoring the title bar geometry!"
break
fi
${ KOREADER_DIR } /wmctrl -r ":titleBar_ID:" -e " ${ TITLEBAR_GEOMETRY } "
usleep 250000
WMCTRL_COUNT = $(( WMCTRL_COUNT + 1 ))
done
logmsg " Title bar geometry restored to ' $( ${ KOREADER_DIR } /wmctrl -l -G | grep ":titleBar_ID:" | awk '{print $2,$3,$4,$5,$6}' OFS = ',' ) ' (ought to be: ' ${ TITLEBAR_GEOMETRY } ') [after ${ WMCTRL_COUNT } attempts] "
2020-03-15 00:28:37 +00:00
fi
2013-09-29 19:30:14 +00:00
fi
2013-03-12 14:14:17 +00:00
2017-04-11 09:28:01 +00:00
if [ " ${ INIT_TYPE } " = "upstart" ] || [ " $( uname -r) " = "2.6.31-rt11-lab126" ] ; then
logmsg "Restoring IPTables rules . . ."
# restore firewall rules
iptables -D INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT
2015-09-06 14:53:24 +00:00
fi
2014-06-25 14:06:43 +00:00
2017-04-11 09:28:01 +00:00
if [ " ${ PASSCODE_DISABLED } " = "yes" ] ; then
logmsg "Restoring system passcode . . ."
touch "/var/local/system/userpasswdenabled"
2016-02-29 16:09:44 +00:00
fi
2017-05-16 09:11:11 +00:00
2020-01-11 03:05:14 +00:00
# Wipe the clones on exit
rm -f /var/tmp/koreader.sh /var/tmp/fbink
2018-07-01 22:23:18 +00:00
exit ${ RETURN_VALUE }