From 2058209aa832a660f8ffa5a9284e1fb5b4084644 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Sep 2015 16:53:24 +0200 Subject: [PATCH] More Kindle startup tweaks on legacy devices Don't try to setup iptables if it's not there (K2/DX/DXG). Note that we'll do it on the K3, but it'll be useless there (no wifi). --- platform/kindle/koreader.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index 3060ad6bf..be0d5c24e 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -121,12 +121,15 @@ export STARDICT_DATA_DIR="data/dict" # export external font directory export EXT_FONT_DIR="/mnt/us/fonts" -logmsg "Setting up IPTables rules . . ." -# accept input ports for zsync plugin -iptables -A INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT -iptables -A INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT -# accept input ports for calibre companion -iptables -A INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT +# Don't try to setup iptables on devices where it doesn't make sense to... +if [ -e "/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter/ip_tables.ko" ] ; then + logmsg "Setting up IPTables rules . . ." + # accept input ports for zsync plugin + iptables -A INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT + iptables -A INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT + # accept input ports for calibre companion + iptables -A INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT +fi # bind-mount system fonts if ! grep ${KOREADER_DIR}/fonts/host /proc/mounts > /dev/null 2>&1 ; then @@ -263,9 +266,11 @@ if [ "${STOP_FRAMEWORK}" == "no" -a "${INIT_TYPE}" == "upstart" ] ; then fi fi -logmsg "Restoring IPTables rules . . ." -# restore firewall rules -iptables -D INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT -iptables -D INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT -iptables -D INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT +if [ -e "/lib/modules/$(uname -r)/kernel/net/ipv4/netfilter/ip_tables.ko" ] ; then + logmsg "Restoring IPTables rules . . ." + # restore firewall rules + iptables -D INPUT -i wlan0 -p udp --dport 8134 -j ACCEPT + iptables -D INPUT -i wlan0 -p udp --dport 5670 -j ACCEPT + iptables -D INPUT -i wlan0 -p tcp --dport 49152:49162 -j ACCEPT +fi