Skip to content

Instantly share code, notes, and snippets.

@sakakendo
Last active June 12, 2019 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakakendo/f634df4c2e9e20b64b4d9c9f898dfea1 to your computer and use it in GitHub Desktop.
Save sakakendo/f634df4c2e9e20b64b4d9c9f898dfea1 to your computer and use it in GitHub Desktop.

ip to slack

installation

curl https://gist.githubusercontent.com/sakakendo0321/f634df4c2e9e20b64b4d9c9f898dfea1/raw/581e4adba8a0a00fe4704abd486efabcc11f68c6/setup.sh |sh

# rewrite url and slack token
channnel= # enter channel name
message='hostname:'$(cat /etc/hostname)',ip:'$(ip addr|egrep -o 'inet\ 192\.168\.0\.[0-9]{1,3}' |sed s/inet\ //g )',ssid:'$(iwconfig wlan0 |grep -o ESSID:\"[^\"]*\")
function send(){
curl -s -XPOST "https://slack.com/api/chat.postMessage?token=$SLACK_TOKEN&channel=$channnel&username=raspi&text="+"$@" >>/dev/null
}
send $message
curl https://gist.githubusercontent.com/sakakendo0321/f634df4c2e9e20b64b4d9c9f898dfea1/raw/1346a7bd122cdf7e22b17589f462940c207c0c12/ip2slack.sh >~/.ip2slack.sh
echo "export SLACK_TOKEN=''" >>~/.bashrc
echo "source .ip2slack.sh" >>~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment