Skip to content

Instantly share code, notes, and snippets.

@trepmal
Created January 6, 2015 21:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trepmal/6c0bbc123ed44f8d9617 to your computer and use it in GitHub Desktop.
Save trepmal/6c0bbc123ed44f8d9617 to your computer and use it in GitHub Desktop.
regularly look for newly modified files, notify hipchat room on discovery
#!/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