Skip to content

Instantly share code, notes, and snippets.

@ianlini
Last active January 28, 2020 00:00
Show Gist options
  • Select an option

  • Save ianlini/648943f4d0d61c58ac8b166ff3c8acb2 to your computer and use it in GitHub Desktop.

Select an option

Save ianlini/648943f4d0d61c58ac8b166ff3c8acb2 to your computer and use it in GitHub Desktop.

Revisions

  1. ianlini revised this gist Jan 28, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion motion_slack.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/bin/bash
    set -ex
    set -e
    LOG_FILE='/var/log/motion/motion.log'
    WEBHOOK_URL='https://hooks.slack.com/services/...'
    USERNAME='motion'
  2. ianlini revised this gist Jan 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion motion_slack.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/bin/bash

    set -ex
    LOG_FILE='/var/log/motion/motion.log'
    WEBHOOK_URL='https://hooks.slack.com/services/...'
    USERNAME='motion'
  3. ianlini revised this gist Jun 9, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion motion_slack.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash

    LOG_FILE='/var/log/motion/motion.log'
    WEBHOOK_URL='https://hooks.slack.com/services/...
    WEBHOOK_URL='https://hooks.slack.com/services/...'
    USERNAME='motion'
    CHANNEL='camera'

  4. ianlini revised this gist Mar 17, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions motion_slack.sh
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,12 @@
    #!/bin/bash

    LOG_FILE='/var/log/motion/motion.log'
    WEBHOOK_URL='https://hooks.slack.com/services/...'
    WEBHOOK_URL='https://hooks.slack.com/services/...
    USERNAME='motion'
    CHANNEL='camera'
    function send_slack_message {
    DATA="payload={\"username\": \"${USERNAME}\", \"text\": \"$1\"}"
    DATA="payload={\"username\": \"${USERNAME}\", \"channel\": \"${CHANNEL}\", \"text\": \"$1\"}"
    echo "data: ${DATA}"
    curl -X POST --data-urlencode "${DATA}" "${WEBHOOK_URL}";
    echo ""
  5. ianlini created this gist Mar 3, 2018.
    18 changes: 18 additions & 0 deletions motion_slack.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash

    LOG_FILE='/var/log/motion/motion.log'
    WEBHOOK_URL='https://hooks.slack.com/services/...'
    USERNAME='motion'

    function send_slack_message {
    DATA="payload={\"username\": \"${USERNAME}\", \"text\": \"$1\"}"
    echo "data: ${DATA}"
    curl -X POST --data-urlencode "${DATA}" "${WEBHOOK_URL}";
    echo ""
    }

    send_slack_message 'motion alert started!'

    tail -n0 -F "${LOG_FILE}" | while read LINE; do
    send_slack_message "${LINE}"
    done