~sotirisp/kindle-hacks

3f166c43fb43094ffc834a8f261c66beb5fac06d — Sotiris Papatheodorou 6 months ago 8fa9da3 master
Update the host blocking script to work on the Kindle 3 WiFi
2 files changed, 15 insertions(+), 6 deletions(-)

M README.md
R scripts/{kindle4_hosts_blocking.sh => kindle_hosts_blocking.sh}
M README.md => README.md +1 -1
@@ 64,7 64,7 @@ domains mentioned in some file in the Kindle's root filesystem to localhost.
Connect the Kindle with USB networking enabled and run:

``` sh
./scripts/kindle4_hosts_blocking.sh
./scripts/kindle_hosts_blocking.sh
```



R scripts/kindle4_hosts_blocking.sh => scripts/kindle_hosts_blocking.sh +14 -5
@@ 1,16 1,25 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2021 Sotiris Papatheodorou
# SPDX-License-Identifier: CC0-1.0
# Usage: kindle4_hosts_blocking.sh
#
# Usage: kindle_hosts_blocking.sh [KINDLE_IP]
# KINDLE_IP defaults to 192.168.15.244 (the IP used by the Kindle 4 non-touch).

set -eu

if ! ssh -T -o ConnectTimeout=2 -i ~/.ssh/kindle.key root@192.168.15.244 ls > /dev/null 2>&1; then
if [ "$#" -eq 0 ]; then
	kindle_ip='192.168.15.244'
else
	kindle_ip="$1"
fi

if ! ssh -T -o ConnectTimeout=2 -i ~/.ssh/kindle.key root@"$kindle_ip" ls > /dev/null 2>&1; then
	printf 'Error: The Kindle must be connected and USB networking must be enabled\n'
	exit 1
fi

# Generate the setup script
setup_script=${TMPDIR:-/tmp}/kindle4_setup.sh
setup_script=${TMPDIR:-/tmp}/kindle_setup.sh
cat << 'EOF' > "$setup_script"
#!/bin/sh
set -eu


@@ 55,10 64,10 @@ FEO
EOF

# rsync it to the Kindle
rsync --rsh "ssh -i ~/.ssh/kindle.key" "$setup_script" root@192.168.15.244:~/ > /dev/null 2>&1
rsync --rsh "ssh -i ~/.ssh/kindle.key" "$setup_script" root@"$kindle_ip":~/ > /dev/null 2>&1

# Run the script and then delete it
ssh -i ~/.ssh/kindle.key root@192.168.15.244 'sh ~/kindle4_setup.sh && rm ~/kindle4_setup.sh'
ssh -i ~/.ssh/kindle.key root@"$kindle_ip" 'sh ~/kindle_setup.sh && rm ~/kindle_setup.sh'

printf 'Host blocking finished\n'