This script is intended to be scheduled to run on the Web server to periodically let Dreamweaver users know which files they have checked out.
I set up my server to run the script every weekday morning by creating a directory (/etc/cron.weekdays) with a symlink to the 'notify' script. Adding this entry to my /etc/crontab makes the script execute every weekday morning at 4:52 AM:
Code:
52 4 * * 1-5 root run-parts /etc/cron.weekdays
Here's the script:
Code:
#!/bin/bash
# where do we want to look for files?
webRoot=/home/web
# search through all of the .LCK files and
# create a list of email addresses contained in them
# then, sort the list and remove any duplicates
emailAddrList=$(find $webRoot -name '*.LCK' \
-exec grep -o '[0-9a-zA-Z]*\@[0-9a-zA-Z\.]*\.[a-zA-Z]*' {} \; | \
sort | uniq);
# main loop
for email in $emailAddrList
do
# for each e-mail address, get a list of .LCK files
# that person is responsible for.
# then use sed to indent the lines and remove extraneous info
filelist=$(grep -H $email $(find $webRoot -name "*.LCK") | \
sed 's/^/ /; s/.LCK:.*$//');
# send the user a message:
mail -s "Dreamweaver file status report" $email << END_MAIL
Dear Gentle Dreamweaver User (a.k.a $email),
It seems that you have the following files checked out on the www.example.com server:
$filelist
If you're not actively using these files, please check them back in so that others may work on them.
This automated message will be sent out each weekday morning to anyone who has files checked out. If you don't want to commit your changes to any of the files listed, use Dreamweaver's "undo check out" function for those files.
Thank you.
END_MAIL
done