@ -1,6 +1,7 @@
local android = require ( " android " )
android.dl . library_path = android.dl . library_path .. " : " .. android.dir .. " /libs "
local lfs = require ( " libs/libkoreader-lfs " )
local ffi = require ( " ffi " )
local dummy = require ( " ffi/posix_h " )
local C = ffi.C
@ -15,6 +16,37 @@ end
-- path to primary external storage partition
local path = android.getExternalStoragePath ( )
-- run user shell scripts
local function runUserScripts ( dir )
for entry in lfs.dir ( dir ) do
if entry ~= " . " and entry ~= " .. " then
local fullpath = dir .. " / " .. entry
local mode = lfs.attributes ( fullpath ) . mode
if mode == " file " and fullpath : match ( " .sh$ " ) then
android.execute ( " sh " , fullpath , path .. " /koreader " , android.dir )
elseif mode == " directory " then
runUserScripts ( fullpath ) -- recurse into next directory
end
end
end
end
-- scripts executed once after an update of koreader
local run_once_scripts = path .. " /koreader/scripts.afterupdate "
if lfs.attributes ( run_once_scripts , " mode " ) == " directory " then
local afterupdate_marker = android.dir .. " /afterupdate.marker "
if lfs.attributes ( afterupdate_marker , " mode " ) ~= nil then
runUserScripts ( run_once_scripts )
android.execute ( " rm " , afterupdate_marker )
end
end
-- scripts executed every start of koreader
local run_always_scripts = path .. " /koreader/scripts.always "
if lfs.attributes ( run_always_scripts , " mode " ) == " directory " then
runUserScripts ( run_always_scripts )
end
-- run koreader patch before koreader startup
pcall ( dofile , path .. " /koreader/patch.lua " )