I had setup vsftp for SSL (FTPES), but needed a way to send an alert to customer support whenever a file had been uploaded. Otherwise the support staff would need to manually check each customer’s folders to see if anything new had arrived.
Install Dnotify
apt-get install dnotify
Create your startup script
nano /dnotify.sh
dnotify -b -p 1 -r -C /home/ -e /email.sh {}
This will run dnotify in the -b background, no more than one -p process, -r recursive folder (subfolders), -C for file creations only, -e execute the following script.
Create your email script
nano /email.sh
#!/bin/bash
DIR=”$1″
rm /upload.txt
echo “Dear User,”>>/upload.txt
echo “A new file has been uploaded to the $DIR directory”>>/upload.txt
cat /upload.txt | mailx -s “New FTP File Upload” customersupport@domain.tld
Make both scripts run-able
chmod +x email.sh
chmod +x dnotify.sh
Run the script and test
./dnotify.sh
Upload a file using FTP/WinSCP/WGET or another method to any of the folders you’re searching (my script searches all of /home and subfolders).
I added this as a startup script.
I got most of my help from nixcraft