https://github.com/ryanj/poweroverinternet
a poorly-named container that monitors net accessibility, attempts to reboot your router when unresponsive
https://github.com/ryanj/poweroverinternet
Last synced: 5 months ago
JSON representation
a poorly-named container that monitors net accessibility, attempts to reboot your router when unresponsive
- Host: GitHub
- URL: https://github.com/ryanj/poweroverinternet
- Owner: ryanj
- License: gpl-3.0
- Created: 2019-08-30T21:31:38.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2020-07-22T19:56:58.000Z (almost 6 years ago)
- Last Synced: 2025-04-02T10:44:33.206Z (about 1 year ago)
- Language: Shell
- Size: 257 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# β‘POWERπOVERπΆINTERNETπ
a poorly-named service that uses GPIO signaling to restore failed network connections
Inspired by:
* https://fedoramagazine.org/turnon-led-fedora-iot/
Requirements:
* an unreliable Internet connection
* a Raspberry Pi or similar (ARM64 with GPIO)
* an AC/DC Control Relay, available from http://iotrelay.com
* two spare wires
## Disclaimers
1. **WARNING: this container attempts to drop your internet connection via GPIO!**
2. *USE AT YOUR OWN RISK!!! (see LICENCE for additional detils)*
3. for additional support - call your internet service provider (or consider finding a new one)!
## Basics
Basic usage with `docker` or `podman`:
```bash
sudo podman run -it --name rerouter -e DEBUG_OUT=enabled --device=/dev/gpiochip0 ryanj/poweroverinternet:v1
```
Example output:
```
β‘POWERπOVERπΆINTERNETπ
1. πΆπ€ Check google.com:443 for availability...
2. β‘π Send net restart trigger events via gpiochip0 pin 21
πΆπ‘ checking uplink...
πΆπ net uplink active
π€π€ sleeping for 60s...
πΆπ‘ checking uplink...
β οΈ βͺοΈ lookup failed - trying again...
πΆβ network uplink is unavailable!
β‘π restarting network uplink...
ππ« net restart trigger issued via gpiochip0 pin 21
πΆβ¨ waiting 60s for network uplink to restart...
β³β³ waiting...
β³ waiting...
β waiting...
πΆπ‘ testing uplink...
π€ testing uplink...
π€ testing uplink...
π€ testing uplink...
πΆβ
network uplink restored!
πΆπ net connection recovered after 77 seconds of downtime
πΆπ‘ checking uplink...
πΆπ net uplink active
π€π€ sleeping for 60s...
```
### Configuration
By default, this service will attempt to contact `google.com` on port `443`. Env keys can be used to configure the service with `REMOTE_SERVER` and `REMOTE_PORT` settings:
```bash
sudo podman run -d -it --rm --name rerouter -e REMOTE_SERVER=192.168.1.1 -e REMOTE_PORT=80 --device=/dev/gpiochip0 ryanj/poweroverinternet:v1
```
These settings assume that you have a router or cable modem configured to respond on `192.168.1.1:80`.
In the event that the service is unable to make a connection to the configured host and port address, a trigger signal will be sent to the configured GPIO headers, which (when configured correctly) will activate the AC/DC control relay to restart any connected hardware devices.
### Installation
This service can be installed and managed via Kubernetes or systemd.
Example systemd unit: [poweroverinternet.service](https://raw.githubusercontent.com/ryanj/poweroverinternet/master/poweroverinternet.service)
To install this systemd unit on Fedora30 IoT, try:
```bash
sudo curl -o /etc/systemd/system/poweroverinternet.service https://raw.githubusercontent.com/ryanj/poweroverinternet/master/poweroverinternet.service
```
Fix permissions, and review the new service configuration:
```bash
sudo chmod 664 /etc/systemd/system/poweroverinternet.service
cat /etc/systemd/system/poweroverinternet.service
```
Update the environment keys as needed. See [#configuration](#Configuration) for details.
When ready, load the systemd unit and mark it active:
```bash
sudo systemctl daemon-reload
sudo systemctl enable poweroverinternet
```
Check the status of the service with:
```bash
sudo systemctl status poweroverinternet
```
### Development
Tested and developed on Fedora 30 IoT
local:
```bash
sudo IDLE_SECONDS=2 DEBUG_OUT=enabled REMOTE_SERVER=192.168.1.1 REMOTE_PORT=80 ./poweroverinternet.sh
```
build:
```bash
sudo podman build --tag fedora:poweroverinternet -f ./Dockerfile
```
test:
```bash
sudo podman run -it --name rerouter_test --device=/dev/gpiochip0 localhost/fedora:poweroverinternet
```
share:
```bash
sudo podman tag
sudo podman push
```