View Single Post
Old 03-05-2024, 04:29 PM   #29
elinkser
Groupie
elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.
 
Posts: 187
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
***
I guess frostschutz is no longer supporting it. I did manage to get uploads working if it is of help to anyone.

Uploads gave me a "seg error" so I tried rebuilding httpd_preload.so and multipart_pipe in /usr/local/WebPortal/ .


$ source ~/koxtoolchain/refs/x-compile.sh kobo env bare
(e.g. see https://www.mobileread.com/forums/sh...16&postcount=4)

iafonov/multipart-parser-c
https://github.com/iafonov/multipart-parser-c

$ wget https://github.com/iafonov/multipart...ads/master.zip

$ mv master.zip multipart-parser-c-master.zip

$ unzip multipart-parser-c-master.zip

$ cd multipart-parser-c-master/

$ nano -l Makefile
Code:
 1 CFLAGS?=-std=c89 -ansi -pedantic -O4 -Wall -fPIC 
 2 CC = arm-kobo-linux-gnueabihf-gcc
 3 AR = arm-kobo-linux-gnueabihf-ar
 4 default: multipart_parser.o
 5 
 6 multipart_parser.o: multipart_parser.c multipart_parser.h
 7 
 8 solib: multipart_parser.o
 9         $(CC) -shared -Wl,-soname,libmultipart.so -o libmultipart.so multipart_parser.o
10 
11 static: multipart_parser.o
12         $(AR) rcs libmultipart_parser.a multipart_parser.o
13 
14 clean:
15         rm -f *.o *.so *.a
$ make static

$ ls -l
-rw-r--r-- 13258 libmultipart_parser.a
-rw-r--r-- 1353 multipart_parser.h

cd ..


***

$ source ~/koxtoolchain/refs/x-compile.sh kobo env bare


frostschutz/Kobo
https://github.com/frostschutz/Kobo

$ wget https://github.com/frostschutz/Kobo/...ads/master.zip

$ mv master.zip frostschutz-master.zip

$ unzip frostschutz-master.zip

$ cd Kobo-master/WebPortal/

$ cd usr/local/WebPortal/

$ cp ../../../../../multipart-parser-c-master/libmultipart_parser.a .

$ cp ../../../../../multipart-parser-c-master/multipart_parser.h .

$ arm-kobo-linux-gnueabihf-gcc -Wall -O2 -s -fPIC -shared -ldl httpd_preload.c -o httpd_preload.so

$ arm-kobo-linux-gnueabihf-gcc -Wall -O2 -s -o multipart_pipe multipart_pipe.c libmultipart_parser.a

$ ls -l
-rwxr-xr-x 5392 httpd_preload.so
-rwxr-xr-x 9672 multipart_pipe

On your kobo, replace the httpd_preload.so multipart_pipe and in /usr/local/WebPortal/ with the above versions.

Edit /mnt/onboard/.addons/webportal/httpd.conf to allow access to your cellphone, e.g.:
# allow LAN (to access from PC - only enable in networks you trust)
A:192.168.43.1/24

If that doesn't work, try commenting out the line (insecure):
# disallow everyone else
# D:*

(Have to restart the server,and wait a few seconds.)

From a ssh shelll to the kobo run:

# LD_PRELOAD="/usr/local/WebPortal/httpd_preload.so" httpd -f -c /mnt/onboard/.addons/w
ebportal/httpd.conf

From your cellphone, browse to the kobo webportal, e.g. http://192.168.43.5/

Downloads (by clicking on the kobo file) and Uploads (by browsing to the cellphone file) should work from the File Manager.


Append a nice gif animation to the welcome page:

$ nano -l /mnt/onboard/.addons/webportal/index.html
Code:
...
  <p><img SRC="sample.gif" ALT="sample"></p>
...
Copy a gif named sample.gif to /mnt/onboard/.addons/webportal/

A gif animation appears on the welcome page:

***

I commented out /etc/udev/rules.d/webportal.rules
# KERNEL=="loop0", RUN+="/usr/local/WebPortal/webportal.sh"
because it isn't guaranteed to start at boot, and may not even be secure to always start anyway, if you are using relaxed access rules like in httpd.conf above.

So I just made a NickelMenu entry like:

menu_item :main :WebPortal :cmd_spawn :quiet:/usr/local/WebPortal/webportal.sh
chain_success :dbg_toast :Started WebPortal
chain_failure :dbg_toast :Error

menu_item :main :Stop WebPortal :cmd_spawn :quiet:usr/bin/pkill httpd && /bin/rm -R /tmp/WebPortal/ && /bin/rm /tmp/webportal_hosts
chain_success :dbg_toast :Stopped WebPortal
chain_failure :dbg_toast :Error

(You have to wait a few seconds for it to start.)

* To run the portal directly from NickelMenu you can add this entry:

menu_item :main :Run WebPortal :nickel_browser :modal :http://webportal/

(As the README states, it "won't work if no wifi network is available, since the Kobo refuses to start the webbrowser".
However, if just WiFi is on. without even connecting to a hotspot, elinks in an fbpad terminal will still run WebPortal - just have to hit Ctrl-R on the fbkeyboard/oskansi keyboard to refresh the note.)


***

A few mods...

Set permissions:

$ nano /mnt/onboard/.addons/webportal/httpd.conf
Code:
...
# allow USB and cell connection
A:192.168.2.1
A:192.168.43.

# disallow everyone else
D:*
...

Remove 10-second delay if you decide to start only from NickelMenu:

$ nano -l /usr/local/WebPortal/webportal.sh
Code:
...
 13 # sleep 10
...

Correct mobileread link and add link to a gif:

$ nano /mnt/onboard/.addons/webportal/index.html
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <title>Kobo Web Portal Mod</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>

<body style="font-size: 2em; -webkit-text-size-adjust: none; text-align: center; align: center;" onload="showOriginalLocation();">
  <h1>Web Portal</h1>

  <p><a style="text-decoration: none;" href="http://www.google.com">Google Search</a></p>

  <p><a style="text-decoration: none;" href="http://en.m.wikipedia.org">Wikipedia</a></p>

  <p><a style="text-decoration: none;" href="http://pda.leo.org">LEO Dictionary</a></p>

  <p><a style="text-decoration: none;" href="https://www.mobileread.com/forums/forumdisplay.php?f=247">Mobileread</a></p>

  <p><a href="cgi-bin/notes">Notes</a></p>

  <p><a href="cgi-bin/servicemenu">Service Menu</a></p>

  <p><a href="cgi-bin/filemanager">File Manager</a></p>

  <p><a href="anim.html">anim.gif</a></p>

</body>
</html>
$ nano /mnt/onboard/.addons/webportal/anim.html
Code:
<html>
<img SRC="anim.gif" ALT="anim">
</html>
(Put anim.gif in /mnt/onboard/.addons/webportal/).



Correct error "notes: line 1: syntax error: unterminated quoted string":

$ nano -l /mnt/onboard/.addons/webportal/cgi-bin/notes
Code:
...
 35         value="`echo "$FIELD" | cut -s -d '=' -f 2-`"
...


Correct error "servicemenu: line 1: syntax error: unterminated quoted string":

$ nano -l /mnt/onboard/.addons/webportal/cgi-bin/servicemenu
Code:
...
 53         value="`echo "$FIELD" | cut -s -d '=' -f 2-`"
...

***
Attached Files
File Type: zip WebPortalBuild.zip (22.2 KB, 85 views)

Last edited by elinkser; 03-09-2024 at 07:52 AM. Reason: mods,elinks
elinkser is offline   Reply With Quote