diff --git a/base b/base index 0dc71fd1b..8efd64995 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 0dc71fd1b43cf41d116404ad59ab2c5c9fa50898 +Subproject commit 8efd649950d296fc79d8ce5ef50060ef815f6f5a diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index c2220206a..05381aaa7 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -362,9 +362,22 @@ while [ ${RETURN_VALUE} -ne 0 ]; do if [ ${RETURN_VALUE} -eq ${KO_RC_USBMS} ]; then # User requested an USBMS session, setup the tool outside of onboard - mkdir -p "/tmp/usbms" - if ! ./tar xzf "./data/KoboUSBMS.tar.gz" -C "/tmp/usbms"; then - echo "Couldn't unpack KoboUSBMS to /tmp/usbms, restarting KOReader . . ." >>crash.log 2>&1 + USBMS_HOME="/mnt/usbms" + mkdir -p "${USBMS_HOME}" + # We're using a custom tmpfs in case /tmp is too small (mainly because we may need to import a large CJK font in there...) + if ! mount -t tmpfs tmpfs ${USBMS_HOME} -o defaults,size=32M,mode=1777,noatime; then + echo "Failed to create the USBMS tmpfs, restarting KOReader . . ." >>crash.log 2>&1 + continue + fi + + if ! ./tar xzf "./data/KoboUSBMS.tar.gz" -C "${USBMS_HOME}"; then + echo "Couldn't unpack KoboUSBMS, restarting KOReader . . ." >>crash.log 2>&1 + if ! umount "${USBMS_HOME}"; then + echo "Couldn't unmount the USBMS tmpfs, shutting down in 30 sec!" >>crash.log 2>&1 + sleep 30 + poweroff -f + fi + rm -rf "${USBMS_HOME}" continue fi @@ -375,9 +388,22 @@ while [ ${RETURN_VALUE} -ne 0 ]; do usbms_lang="C" fi + # If the language is CJK, copy the CJK font, too... + case "${usbms_lang}" in + ja* | ko* | zh*) + cp -pf "${KOREADER_DIR}/fonts/noto/NotoSansCJKsc-Regular.otf" "${USBMS_HOME}/resources/fonts/NotoSansCJKsc-Regular.otf" + ;; + esac + # Here we go! - if ! cd "/tmp/usbms"; then - echo "Couldn't chdir to /tmp/usbms, restarting KOReader . . ." >>crash.log 2>&1 + if ! cd "${USBMS_HOME}"; then + echo "Couldn't chdir to ${USBMS_HOME}, restarting KOReader . . ." >>crash.log 2>&1 + if ! umount "${USBMS_HOME}"; then + echo "Couldn't unmount the USBMS tmpfs, shutting down in 30 sec!" >>crash.log 2>&1 + sleep 30 + poweroff -f + fi + rm -rf "${USBMS_HOME}" continue fi env LANGUAGE="${usbms_lang}" ./usbms @@ -401,7 +427,14 @@ while [ ${RETURN_VALUE} -ne 0 ]; do sleep 30 poweroff -f fi - rm -rf "/tmp/usbms" + + # Tear down the tmpfs... + if ! umount "${USBMS_HOME}"; then + logger -p "DAEMON.CRIT" -t "koreader.sh[$$]" "Couldn't unmount the USBMS tmpfs, shutting down in 30 sec!" + sleep 30 + poweroff -f + fi + rm -rf "${USBMS_HOME}" fi done