Skip to content

Notify on boot

Sometimes its handy to send a notification on boot, for example to send the IP address that the server has.

This script uses discord to send a message.

  1. Install dependencies

    sudo apt install -y jq
  2. Install

    cd /usr/local/bin
    sudo curl -L -O
    sudo chmod +x
  3. Create a script to send a message

    IP=$(hostname -I | awk '{print $1}')
    WEBHOOK_URL=<<webhook-url>> \
    --webhook-url="$WEBHOOK_URL" \
    --username="server" \
    --text="server booted with IP $IP"
    sudo chmod u+x /opt/
  4. Create a boot-notify systemd task that runs after networking has started

    Description=Sends a message over discord at startup
    ExecStart=/bin/bash /opt/
  5. Test the systemd service

    sudo systemctl daemon-reload
    sudo systemctl start boot-notify

    Then verify the message is received

  6. Enable the systemd service

    sudo systemctl enable boot-notify

Last update: August 12, 2023
Created: May 27, 2023