Files
general-scripts-and-system-…/customscripts/webhook
T

31 lines
929 B
Bash

#!/bin/bash
# usage in cron
## @reboot bash /usr/share/customscripts/ifnet "/usr/share/customscripts/webhook bootup" 2>> /var/log/cron.error.log
# discord_webhook="https://discord.com/api/webhooks/yourwebhook"
discord_webhook=$(cat /usr/share/customscripts/webhook.txt)
ipaddr=$(hostname -I | grep -E -o "10.0.0.[0-9]{1,3}" | tail -1)
date=$(date "+%d/%m/%Y %H:%M:%S %Z (%s)")
# to tag role run \@rolename and copy the code that is like <@something>
# tag="<@tag>"
tag=$(cat /usr/share/customscripts/tag.txt)
hostname=$(hostname)
bootup_string="bootrred on $date\n\tip addr: $ipaddr\n\t$tag\n\n"
if [[ -z $1 ]]; then
content='Default Ping!'
elif [[ "$1" == "bootup" ]]; then
content="$bootup_string"
else
content="$1"
fi
post_data() {
cat <<EOF
{
"username":"$hostname",
"content":"$content"
}
EOF
}
curl -H "Content-Type: application/json" -X POST -d "$(post_data)" "$discord_webhook"