Created
January 6, 2015 21:18
-
-
Save trepmal/6c0bbc123ed44f8d9617 to your computer and use it in GitHub Desktop.
regularly look for newly modified files, notify hipchat room on discovery
This file contains 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/sh | |
# | |
# ./find-new-files [path(.)] [minutes(360)] | |
# | |
if [ -z $1 ] | |
then | |
dir='.' | |
else | |
dir=$1 | |
fi | |
if [ -z $2 ] | |
then | |
min='360' | |
else | |
min=$2 | |
fi | |
from='Monitor' | |
room_id='HipChat Room Name' | |
api_key='HipChat API key' | |
find=`find $dir -type f -mmin -$min` | |
if [ "$find" = "" ] | |
then | |
count=0 | |
else | |
count=`echo "$find" | wc -l` | |
fi | |
if [[ $count -gt 0 ]] | |
then | |
message="$count files modified in the last $min minutes in $dir" | |
curl -d room_id="$room_id" -d from="$from" -d message="$message" -d color='gray' "https://api.hipchat.com/v1/rooms/message?format=json&auth_token=${api_key}" | |
#echo $message | |
#echo "$find" | |
else | |
message='no modified files' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment