Created
February 19, 2019 11:56
-
-
Save Luismcplopes/e8272ecb23bfd4f70328838de270a630 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
######################################## | |
# | |
# This script notifies slack | |
# when this machine starts up | |
# | |
######################################## | |
#This reads in the webhook URL from a file | |
#just replace it with you actual webhook URL | |
slack_url=`cat //usr/bin/slack_url` | |
start_text="Power is UP " | |
start_text+="Name : `hostname`" | |
start_text+="\n Internal-IP : `ip route get 8.8.8.8 | awk '{print $NF; exit}'`" | |
start_text+="\n External-IP : `curl ifconfig.co` \n" | |
start_text+="\n [+] for OK : `service --status-all | grep openvpn`" | |
start_text+="\n [+] for OK : `service --status-all | grep ssh` \n " | |
start_text+="\n `grep MemTotal /proc/meminfo` \n" | |
start_text+="\n Espaço nas Drives" | |
start_text+="\n `df -h | grep /dev/mmc | sed ':a;N;$!ba;s/\n/\\\n/g'`" | |
start_text+="\n `df -h | grep /dev/sd | sed ':a;N;$!ba;s/\n/\\\n/g'`" | |
curl -H "Content-type:application/json" \ | |
-X POST -d \ | |
'{ | |
"channel":"#ll-osmc", | |
"username" : "RaspBerryPi", | |
"icon_emoji" : ":raspberrypi:", | |
"attachments" : [ | |
{ | |
"fallback": "OSMC is up and running!", | |
"color" : "good", | |
"fields" : [ | |
{ | |
"title" : "OSMC Starting Up!", | |
"value" : "'"$start_text"'", | |
"short" : "true" | |
} | |
] | |
} | |
] | |
} | |
' $slack_url | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this to work it is necessary to create a file
slack_url
on/usr/bin/
with slack-Hook in it or