Skip to content

Commit

Permalink
Add support for Koreader's WiFi manager
Browse files Browse the repository at this point in the history
  • Loading branch information
lgeek committed Mar 25, 2017
1 parent 97b56e6 commit b8fcc58
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 10 deletions.
20 changes: 12 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,18 @@ compile_koreader() {
mkdir opt
cd opt
tar xf ../../koreader/koreader-kobo-arm-linux-gnueabihf*.targz

echo "#!/bin/bash" > koreader/okreader.sh
echo "cd /opt/koreader" >> koreader/okreader.sh
echo "while true; do" >> koreader/okreader.sh
echo " ./luajit ./reader.lua /mnt" >> koreader/okreader.sh
echo "done" >> koreader/okreader.sh
chmod +x koreader/okreader.sh


cp ../../../files/okreader.sh koreader/
cp ../../../files/disable-wifi.sh koreader/
cp ../../../files/enable-wifi.sh koreader/
cp ../../../files/obtain-ip.sh koreader/
cp ../../../files/release-ip.sh koreader/
chmod +x koreader/disable-wifi.sh
chmod +x koreader/enable-wifi.sh
chmod +x koreader/obtain-ip.sh
chmod +x koreader/release-ip.sh
chmod +x koreader/restore-wifi-async.sh

cp ../../../files/defaults.persistent.lua koreader/

cd ../../
Expand Down
2 changes: 1 addition & 1 deletion build_rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ config_rootfs() {
install_packages() {
cp src/linux-okreader-modules_2.6.35.3-1_armhf.deb rootfs/
cp src/firmware-okreader_1.0-1_armhf.deb rootfs/
cp src/koreader_2017.03-1_armhf.deb rootfs/
cp src/koreader_2017.03-2_armhf.deb rootfs/
cp src/kobo_hwconfig/kobo-hwconfig_1.0-1_armhf.deb rootfs/

chroot rootfs/ bash -c "dpkg -i /*.deb"
Expand Down
16 changes: 16 additions & 0 deletions files/disable-wifi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# Disable wifi, and remove all modules.

killall dhcpcd default.script wpa_supplicant 2>/dev/null

ifconfig wlan0 down

# Some sleep in between may avoid system getting hung
# (we test if a module is actually loaded to avoid unneeded sleeps)
if lsmod | grep -q $WIFI_MODULE ; then
rmmod $WIFI_MODULE
fi
if lsmod | grep -q sdio_wifi_pwr ; then
rmmod sdio_wifi_pwr
fi
12 changes: 12 additions & 0 deletions files/enable-wifi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

# Load wifi modules and enable wifi.
lsmod | grep -q $WIFI_MODULE || modprobe $WIFI_MODULE
lsmod | grep -q sdio_wifi_pwr || modprobe sdio_wifi_pwr
sleep 1

ifconfig wlan0 up

pidof wpa_supplicant >/dev/null || \
( wpa_supplicant -D wext -iwlan0 -C /var/run/wpa_supplicant -B; \
ln -s /var/run/wpa_supplicant/wlan0 /var/run/wpa_supplicant/eth0 )
5 changes: 5 additions & 0 deletions files/obtain-ip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

./release-ip.sh

dhcpcd wlan0
8 changes: 8 additions & 0 deletions files/okreader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

export WIFI_MODULE=brcmfmac

cd /opt/koreader
while true; do
./luajit ./reader.lua /mnt
done
3 changes: 3 additions & 0 deletions files/release-ip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

pkill -9 -f 'dhcpcd'
2 changes: 1 addition & 1 deletion src/koreader-pkg/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: koreader
Version: 2017.03-1
Version: 2017.03-2
Maintainer: Cosmin Gorgovan <okreader@linux-geek.org>
Architecture: armhf
Description: An ebook viewer application.

0 comments on commit b8fcc58

Please sign in to comment.