Skip to content

Commit

Permalink
port to bash, apply/revert hack for >= 2.15
Browse files Browse the repository at this point in the history
  • Loading branch information
rM-self-serve committed Apr 15, 2023
1 parent 81d068a commit be57df9
Show file tree
Hide file tree
Showing 8 changed files with 377 additions and 257 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
.vscode/
156 changes: 0 additions & 156 deletions Cargo.lock

This file was deleted.

14 changes: 0 additions & 14 deletions Cargo.toml

This file was deleted.

68 changes: 50 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,76 @@
# WebInterface-OnBoot

This simple program will convince the ReMarkable Tablet to start the web interface after booting without the usb cord being plugged in. It can then be reached internally at 10.11.99.1:80 without the usb cord.
> bash-hack branch
This could easily be emulated with a bash script.
This simple program will convince the ReMarkable Tablet to start the web interface after booting without the usb cord being plugged in. It can then be reached internally at 10.11.99.1:80 without the usb cord.

Type the following commands after ssh'ing into your ReMarkable Tablet.

## Xochitl Version Compatibility

- ✅ 1.9 - 2.14
- 🚫 >= 2.15
Tested from v1.9 to v3.3.2-beta on rM1

- ✅ <= v2.14
- ✅ >= v2.15 - Requires simple binary hack, see below

### Type the following commands after ssh'ing into the ReMarkable Tablet


## Install

`wget https://raw.githubusercontent.com/rM-self-serve/webinterface-onboot/master/install-webint-ob.sh && bash install-webint-ob.sh`
`wget https://raw.githubusercontent.com/rM-self-serve/webinterface-onboot/bash-hack/install-webint-ob.sh && bash install-webint-ob.sh`

## Remove

`wget https://raw.githubusercontent.com/rM-self-serve/webinterface-onboot/master/remove-webint-ob.sh && bash remove-webint-ob.sh`
`wget https://raw.githubusercontent.com/rM-self-serve/webinterface-onboot/bash-hack/remove-webint-ob.sh && bash remove-webint-ob.sh`

## Use

To auto start the application after restarting the device, run:
To use the application, run:

- `systemctl enable --now webinterface-onboot`

Next time you restart the web interface will be running and internally accessible on 10.11.99.1:80
Each time webinterface-onboot is enabled, the web-interface setting will need to be enabled within the settings menu via a cord sometime between when the device was turned on and before it is turned off. After that, the web interface will be running and internally accessible on 10.11.99.1:80 every time the device is started.


## Manual install
## How Does it Work?

You will need docker/podman, cargo, and the cargo crate named cross. There are surely other ways to cross compile for armv7-unknown-linux-gnueabihf as well.
If the field 'WebInterfaceEnabled' is set to 'true' in /etc/remarkable.conf, xochitl will see if the 'usb0' network interface has an ip address and run the web-interface website on that ip address if so.

`cross build --target armv7-unknown-linux-gnueabihf --release`
Thus, before xochitl starts:
- set WebInterfaceEnabled=true in /etc/remarkable.conf
- set the usb0 interface ip address to 10.11.99.1/32

Then copy the binary 'target/armv7-unknown-linux-gnueabihf/release/webinterface-onboot' to the device and enable/start it as a systemd service.
The actual web-interface website will continue running on 10.11.99.1:80 even if the usb0 interface does not have the 10.11.99.1 ip address. Disconnecting the usb cord will automatically remove the 10.11.99.1 ip from the usb0 interface, so this program runs in an infinite loop and will ensure the ip stays set.

## How Does it Work?

Before xochitl starts, trick it into thinking the web interface should be enabled by:
- setting WebInterfaceEnabled=true in /etc/remarkable.conf
- giving the usb0 interface the ip 10.11.99.1/32
## Binary Hack for >= 2.15

> :warning: Not tested on the Remarkable Tablet 2
The provided functions to apply/revert the hack will first create a backup of xochitl, then a temporary file in which the strings of the binary are changed. If the temporary file is successfully converted, it will replace the xochitl binary in /usr/bin/.

### Apply Hack

This will only need to be done once unless you upgrade.

- `webinterface-onboot --apply-hack`

### Revert Hack

Try to restore from backup or reverse hack.

- `webinterface-onboot --revert-hack`

### Info

All the hack does to the xochitl binary:

- change the string 'usb0' to 'usbF'
- change the string 'usb1' to 'usb0'

The strings 'usb0' and 'usb1' appear only to be used when deciding on which network interface the web-interface website will be started on.

Without the hack, xochitl will check to see that the 'usb0' interface has an ip address and is connected to a device in order to start the web-interface. If not it will fallback to the 'usb1' interface, but then only check for an ip address in order to start the web-interface.

If the interface name string, i.e. 'usb0', is changed in the binary, xochitl will look for a network interface with that new name instead. Since webinterface-onboot ensures that the 'usb0' interface always has an ip address, we can change the 'usb1' string to 'usb0' so that the 'usb0' interface is the fallback and only needs an ip for the web-interface to start on it. I am not quite sure of the function of the 'usb1' interface, so I changed the inital occurance of 'usb0' to 'usbF', so that xochitl can not find the network interface and will always fallback to 'usb0'. It may be wiser to leave the intial occurance of 'usb0' as 'usb0'.

The actual web-interface website will continue running on 10.11.99.1:80 even if the usb0 interface does not have the 10.11.99.1 ip address. Disconnecting the usb cord will automatically remove the 10.11.99.1 ip from the usb0 interface, so this program runs in an infinite loop and will ensure the ip stays set.
20 changes: 10 additions & 10 deletions install-webint-ob.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

webinterface_onboot_sha256sum='5072b216774f2ca24ac0933d4633a6e2d64e5b7426bcbcac48f74cc56f9c3ab0'
service_file_sha256sum='224fe11abdc0bd332c9946ffda3fe38687038dbf4bd65982b88815ab90f5a8cf'
# webinterface_onboot_sha256sum='5072b216774f2ca24ac0933d4633a6e2d64e5b7426bcbcac48f74cc56f9c3ab0'
# service_file_sha256sum='224fe11abdc0bd332c9946ffda3fe38687038dbf4bd65982b88815ab90f5a8cf'

installfile='./install-webint-ob.sh'
localbin='/home/root/.local/bin'
Expand Down Expand Up @@ -42,22 +42,22 @@ function sha_fail() {
}

[[ -f $binfile ]] && rm $binfile
wget https://github.com/rM-self-serve/webinterface-onboot/releases/download/v1.0.0/webinterface-onboot \
wget https://raw.githubusercontent.com/rM-self-serve/webinterface-onboot/bash-hack/webinterface-onboot \
-P $localbin

if ! sha256sum -c <(echo "$webinterface_onboot_sha256sum $binfile") >/dev/null 2>&1; then
sha_fail
fi
# if ! sha256sum -c <(echo "$webinterface_onboot_sha256sum $binfile") >/dev/null 2>&1; then
# sha_fail
# fi

chmod +x $localbin/webinterface-onboot

[[ -f $servicefile ]] && rm $servicefile
wget https://raw.githubusercontent.com/rM-self-serve/webinterface-onboot/master/webinterface-onboot.service \
wget https://raw.githubusercontent.com/rM-self-serve/webinterface-onboot/bash-hack/webinterface-onboot.service \
-P /lib/systemd/system

if ! sha256sum -c <(echo "$service_file_sha256sum $servicefile") >/dev/null 2>&1; then
sha_fail
fi
# if ! sha256sum -c <(echo "$service_file_sha256sum $servicefile") >/dev/null 2>&1; then
# sha_fail
# fi

systemctl daemon-reload

Expand Down
58 changes: 0 additions & 58 deletions src/main.rs

This file was deleted.

Loading

0 comments on commit be57df9

Please sign in to comment.