How to run a script at boot? Tested on Fedora, CentOS and Raspbian.

You can use cron via @reboot directive.

@reboot /path/to/script

But, as far as I can see, if you need the network, it seems that this way is not suitable.
Then, instead, you can use oneshot type in a systemd service. Let’s create a systemd service file:

vi /etc/systemd/system/bootbotto.service

[Unit]
Description=bootbotto
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/bootbotto

[Install]
WantedBy=multi-user.target

Then create the script.

vi /usr/local/bin/bootbotto

#!/bin/bash
TOKEN="skjhfddfashfasdhfkdjsfhakjshfakdshak"
CHAT_ID="-7676767676"
URL="https://api.telegram.org/bot$TOKEN/sendMessage"

TEXT="script executed at boot"

curl -s -X POST ${URL} -d chat_id=${CHAT_ID} -d text="${TEXT}" 2>&1>/dev/null

Set it as executable.

chmod 700 /usr/local/bin/bootbotto

Then enable the service and execute it immediately (with –now).

systemctl daemon-reload; systemctl enable bootbotto --now

This script will be executed at boot, once the networking service will be started.
As you can see, this script will send a message on a Telegram group.