MCPcopy Index your code
hub / github.com/Myzel394/destroyerr

github.com/Myzel394/destroyerr @0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.2.0 ↗ · + Follow
11 symbols 24 edges 6 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Destroyerr

Keeping integrity for mission-critical systems.

Destroyerr is a tool that allows you to automatically run commands when a device has not contacted your server for a specified amount of time. Using ntfy.sh, you can send keep-alive messages from any device to the server. Once the device stops sending these messages, Destroyerr will execute a command to shut down the device, or destroy it, or any other action you specify.

This ensures the integrity of your systems by preventing devices from being left in an unknown state.

This readme contains a whole tutorial on how to set up Destroyerr using Docker, ntfy, and Automate on Android

To keep your server alive, you need to send a ntfy message with title: destroyerr and message: keep-alive to the ntfy server.

Tutorial

Set up Docker

Set up destroyerr using Docker. This tutorial assumes you have Docker installed on your system. Pass the following environment variables to the Docker container:

  • NTFY_URL: The URL of your ntfy server, including the topic, and a /sse suffix. For example, https://ntfy.sh/your-topic/sse.
  • SH_COMMAND: What command to run once the timeout is reached. Here's how you can shut down your server from within a Docker container
  • DESTROY_TIMEOUT: The timeout in seconds after which the command will be executed. For example, 3600 for one hour.
  • CHECK_INTERVAL (advanced): The interval in seconds at which the server will check for devices that have not sent a keep-alive message. For example, 60 for one minute.
  • NTFY_SERVER_UNREACHABLE (advanced): What to do if the ntfy server is unreachable. destroyerr will automatically reconnect once the server is back online. However, you can specify what to do in the meantime:
  • continue: Continue the timeout as if the ntfy server is reachable. This is the default behavior.
  • pause: Pause the timeout until the ntfy server is reachable again. This means that the command will not be executed until the server is back online.
  • run_command: Run the SH_COMMAND immediately if the ntfy server is unreachable. This is useful if you want to take immediate action when the server is down.

Here's an example docker-compose.yaml file to get you started:

```yaml services: destroyerr: container_name: destroyerr image: myzel394/destroyerr environment: NTFY_URL: https://ntfy.sh/I5rzgNidrnKngf/sse CHECK_INTERVAL: 10 DESTROY_TIMEOUT: 60 SH_COMMAND: "curl -d '[DESTROYERR] Device has not sent a ping for over 60 seconds!' https://ntfy.sh/ojuzhnHdzudfn"


This will send a notification to the topic `ojuzhnHdzudfn` when the device has not pinged for 60 seconds, checking every 10 seconds.

### Set up your Android phone as a pinger

This setup uses [Automate](https://play.google.com/store/apps/details?id=com.llamalab.automate) to send the keep-alive messages. This app is free, but not open-source.

1. Install [Automate](https://play.google.com/store/apps/details?id=com.llamalab.automate)
2. Create a new flow with the following blocks:
  - **HTTP Request**: Set the URL to your ntfy server URL, including the topic and `/sse` suffix. For example, `https://ntfy.sh/your-topic/sse`.
    - Method: POST
    - Headers: `title: destroyerr`
    - Body: `keep-alive`
  - **Delay**: Set the delay to the interval you want to send the keep-alive message (e.g., 60 seconds).
  - **Loop**: Connect the output of the Delay block to the input of the HTTP Request block to create a loop that sends the keep-alive message at the specified interval.
3. Save and run the flow.

Your flow should look something like this:





    <img src="https://github.com/Myzel394/destroyerr/raw/0.2.0/assets/automate_workflow.png" align="center" width="350" alt="Automate Workflow example" />




4. Start the workflow, and your phone will now send keep-alive messages to the ntfy server at the specified interval

## Shut down your server from within Docker

Inside a Docker container, you cannot run `shutdown`, or `reboot`.
What you can do instead, is to mount the host's `/proc/sysrq-trigger` into the container and then write to it to trigger a shutdown or reboot.

It's recommended to first send a "sync disks" command to ensure all data is written to disk before shutting down, and then send a reboot command.

Here's a sample `docker-compose.yaml` file that does this:

```yaml
services:
  destroyerr:
    container_name: destroyerr
    image: myzel394/destroyerr
    volumes:
      - /proc/sysrq-trigger:/sysrq
    environment:
      NTFY_URL: https://ntfy.sh/I5rzgNidrnKngf/sse
      CHECK_INTERVAL: 10
      DESTROY_TIMEOUT: 60
      # This will sync the disks, wait 30 seconds, and then reboot the system
      SH_COMMAND: "echo s > /sysrq && sleep 30 && echo b > /sysrq"

See https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html#what-are-the-command-keys for more information on the sysrq commands.

Core symbols most depended-on inside this repo

writeCurrentTime
called by 4
src/db.ts
stop
called by 4
src/main.ts
getDiff
called by 2
src/db.ts
loadEnv
called by 1
src/envs.ts
resetDiff
called by 1
src/db.ts
getLastTime
called by 1
src/db.ts
addDiff
called by 1
src/db.ts
main
called by 1
src/main.ts

Shape

Method 6
Function 3
Class 2

Languages

TypeScript100%

Modules by API surface

src/db.ts8 symbols
src/main.ts2 symbols
src/envs.ts1 symbols

For agents

$ claude mcp add destroyerr \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact