Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Suggest HOWTO

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 20th November 2009, 07:08
almeister9 almeister9 is offline
Member
 
Join Date: Sep 2008
Posts: 36
Thanks: 6
Thanked 3 Times in 3 Posts
Default [RESOLVED] PureFTP that send email notification on Upload

Hi All,

I am trying to piece together little snippets from all over the place to get this to work and I just cant get it to work.

What I want is a stand alone FTP server that sends an email to me when a file is uploaded.

I have started by building an Ubuntu 9.04 server as per Falkos:
http://www.howtoforge.com/perfect-se...04-ispconfig-2
up to step 10 and then adding postfix

Then installing Pure-FTP as per Falkos:
http://www.howtoforge.com/virtual-ho...on-ubuntu-9.04

I then try to enable the pure-uploadscript by donig this (found on the net):
Step 1:
vi /etc/default/pure-ftpd-common
Run Pure-FTPd in standalone mode (not inetd mode).
Change the option "STANDALONE_OR_INETD" to "STANDALONE" in

Step 2: Tell Pure-FTPd the user ID under which the script should be run. Pure doesn't like usernames, so you have to provide the numeric UID. In case of www-data it is UID 33.
# if set, pure-uploadscript will spawn $UPLOADSCRIPT running as the # given uid and gid UPLOADUID=2001
UPLOADGID=2001
Step 3: Tell pure-ftpd where the script is located: Change the option UPLOADSCRIPT in /etc/default/pure-ftpd.
# example: UPLOADSCRIPT=/usr/local/sbin/uploadhandler.pl UPLOADSCRIPT=/usr/local/sbin/uploadhandler.pl

Step 4: Enable the option itself:
echo "yes" > /etc/pure-ftpd/conf/CallUploadScript
Step 5: Start or Restart Pure-ftpd
/etc/init.d/pure-ftpd-mysql restart

And then I made my first ever shell script which went like this:
#!/bin/bash
#
echo "$1 uploaded" | mail -s "New Upload : $1" test@mydomain.com

but It doesn't work.

FTP Server part of things works fine.

The only function that the mailer side of this needs to be able to do is send me an email when a file is uploaded. It needs no incoming mailboxes or anything like that.
The Server is a FTP server and nothing else.
It sits in our office so it could even send me a message across the network if that is possible, but I use a windows machine(Windows 7) and a mac (OSX 10.4) as a pair of work stations.

If someone could show me a concise way of istalling Pure-FTP on an Ubuntu 9.04 server with upload notification, I would be very appreciative.

Cheers AL.

Last edited by almeister9; 24th November 2009 at 07:10. Reason: RESOLVED
Reply With Quote
Sponsored Links
  #2  
Old 21st November 2009, 09:46
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,739 Times in 2,574 Posts
Default

Quote:
Originally Posted by almeister9 View Post
And then I made my first ever shell script which went like this:
#!/bin/bash
#
echo "$1 uploaded" | mail -s "New Upload : $1" test@mydomain.com

but It doesn't work.
Have you tried to use the full path for the mail command?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
The Following User Says Thank You to falko For This Useful Post:
feeninuoumn (16th January 2014)
  #3  
Old 22nd November 2009, 15:10
almeister9 almeister9 is offline
Member
 
Join Date: Sep 2008
Posts: 36
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Quote:
Have you tried to use the full path for the mail command?
I'm sorry Falko, but I don't know what the full path for the mail command is.

I am trying to learn about the linux world but I find man pages especially unhelpful for newbs and information on this topic, I have found particulary difficult to find.

I am about to start trying the snail program or ssmtp. As far as I can tell, these don't need a mail server installed on the system, they just use an external mail server and account. (It will also make me feel safer not having a mail server on the system to worry about being compromised. I don't know enough to make it secure.)

I am hoping that I can find an example of a script that uses one of these programs that will work for me or that I can some how work it out by gathering clues.
Reply With Quote
  #4  
Old 23rd November 2009, 06:19
almeister9 almeister9 is offline
Member
 
Join Date: Sep 2008
Posts: 36
Thanks: 6
Thanked 3 Times in 3 Posts
Default The Ultra Elusive pure-uploadscript(8)

I have now started again from scratch.
I have an Ubuntu 9.04 32-bit server as Falko's:
http://www.howtoforge.com/perfect-se...ispconfig-2-p4
up to stage 10.
with a working Pure-ftpd server as per Falkos:
http://www.howtoforge.com/virtual-ho...ubuntu-9.04-p2

I then installed ssmtp:
sudo apt-get install ssmtp

and configured:
sudo vi /etc/ssmtp/ssmtp.conf

Code:
root=myemailaddress@gmail.com
mailhub=smtp.gmail.com:587
AuthUser=mygmailusername
AuthPass=mypassword
UseSTARTTLS=YES
Then by typing into terminal:
ssmtp recipient_email@example.com and hitting enter, then
To: recipient_email@example.com
From: myemailaddress@gmail.com
Subject: test email

hello world!

and then crtl+D it successfully sends a mail via my gmail account.

Code:
I edit Pure-ftp conf file:
vi /etc/default/pure-ftpd-common

and make sure option "STANDALONE_OR_INETD" is "STANDALONE"
set
UPLOADUID=0 
UPLOADGID=0
(because it said to on the man page)
and:
UPLOADSCRIPT=/usr/local/sbin/uploadscript.sh
All that above I got from one of the very few sources I could find on the internet and it basically said "then create a script that does something useful and you are done.
This did not eaxctly help me.
I persisted:
vi /usr/local/sbin/uploadscript.sh
Code:
#! /bin/sh
echo "$1 uploaded" | ssmtp al@dvdindustry.com.au
To:al@dvdindustry.com.au
From: almeister9g@gmail.com
Subject: New File Uploaded

"$1 uploaded"
No Dice
I found another source that gave a small amount of help:http://blog.derjohn.de/space/start/2006-11-14/1
which said:
Step 6: Check if the daemon really run with the new options. (Doesn't say how)
Code:
root 18623 0.0 0.0 12120 868 ? Ss 19:39 0:00 pure-ftpd (SERVER) www-data 18671 0.0 0.0 11912 672 ? Ss 19:40 0:00 /usr/sbin/pure-uploadscript -r /usr/local/sbin/uploadhandler.pl -B -u 33 -g 33
Don't know what that means
Step 7: Create a test script. E.g. this one will write the filename to a file called /tmp/pure-was-here<datestamp>.
Code:
#!/bin/sh echo "$1" > /tmp/pure-was-here$(date +%Y%m%d%H%M%S)
Step 8: Test the script, log in via ftp and upload a file:
I tried that and uploaded a file but the file in /TEMP/ doesn't get created.


I have read the man page for pure-uploadscript over and over but it doesn't seem to tell me how to do anything, just what it can do.

I assume that what I need to do now is:
1). Learn how to create a shell script and then place it somewhere and tell the conf page where it is (UPLOADSCRIPT=)
2). Learn how to get said shell script to use ssmtp to send an email using the available things passed from uploadscript ($1 and others ???)
3). Prey that it works because if it doesn't I have no where to turn.

I feel I am so close now,

Any help that any kind soul could lend me would be greatly appreciated.

Cheers Al.
Reply With Quote
The Following User Says Thank You to almeister9 For This Useful Post:
rockstar9840 (5th November 2010)
  #5  
Old 23rd November 2009, 14:13
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,739 Times in 2,574 Posts
Default

What are the outputs of
Code:
which mail
and
Code:
which ssmtp
?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #6  
Old 23rd November 2009, 23:35
almeister9 almeister9 is offline
Member
 
Join Date: Sep 2008
Posts: 36
Thanks: 6
Thanked 3 Times in 3 Posts
Default Outputs

Hi Falko,
Thanks for looking at this for me.

The output of "which mail" is nothing.

The output of "which ssmtp" is:
/usr/sbin/ssmtp

When I started again from scratch, I built it with just the server and Pureftp, then installed ssmtp. Thats why "which mail" is empty.

Following your first advice
Quote:
Have you tried to use the full path for the mail command?
would that mean that the script should read:
Code:
#!/bin/bash
#
echo "$1 uploaded" | /usr/sbin/ssmtp test@mydomain.com
To: test@mydomain.com
From: originating@address
Subject: "New Upload : $1"

Body text with hopefully some of the other arguments passed from the pure-uploadscript
And also, does the script need to have a .sh file extension?

Thanks again for any help you can give me with this.
Cheers Al.

Last edited by almeister9; 23rd November 2009 at 23:42.
Reply With Quote
Reply

Bookmarks

Tags
falko, notification, pureftp, ubuntu, upload

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sender does not recieve mail delivery system email nor virus notification email. kameelperdza Installation/Configuration 1 2nd October 2009 16:48
hotmail rejects outgoing email nzimas Server Operation 3 1st May 2009 03:39
Impossible to send email with Icedove kdclaver Installation/Configuration 8 9th September 2007 00:02
how to configure postfix to send email out for a hosted domain nox171 Server Operation 24 13th July 2007 11:48
Can't send email with attachments to another email nysprite Installation/Configuration 2 29th June 2006 18:09


All times are GMT +2. The time now is 21:22.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.