Skip to content

Instantly share code, notes, and snippets.

@shi-yan
Last active May 2, 2018 16:57
Show Gist options
  • Select an option

  • Save shi-yan/5e198ecf10b15de8e95fe8be7a0f4ffc to your computer and use it in GitHub Desktop.

Select an option

Save shi-yan/5e198ecf10b15de8e95fe8be7a0f4ffc to your computer and use it in GitHub Desktop.

Revisions

  1. shi-yan renamed this gist May 2, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. shi-yan created this gist Oct 5, 2017.
    17 changes: 17 additions & 0 deletions shiReportIp.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/bin/bash

    touch oldIp.txt

    md1=$(cat "oldIp.txt");
    md2=$(hostname -I);

    if [ "$md1" = "$md2" ]; then
    echo The same
    else
    echo Different
    hostname -I
    cat oldIp.txt
    hostname=$(hostname);
    echo "{\"text\":\"ip of ${hostname} is ${md2}\"}" | curl -X POST -H 'Content-type: application/json' --data @- https://hooks.slack.com/services/xxx/xxx/xxx
    hostname -I > oldIp.txt
    fi