3

I have a Debian Squeeze Machine with PureFTP installed.
PureFTP has a subtool called Upload-Script. This tool can be configured to be called after an upload was done via FTP. However, I can't find a way to get this script-thing running...

I want PureFTP to execute a PHP-Script after each upload.
I have configured PureFTP as follows:

  • To enable the UploadScript-Functionality I have a file in /etc/pure-ftpd/conf called CallUploadScript with content "yes".
  • In /etc/default/pure-ftpd-common I've made the following settings:
    • UPLOADUID and UPLOADGID I'v tried setting it to the UID's/GID's of root and the ftpuser - neither of both worked.
    • Set the path to the UPLOADSCRIPT to be called after each upload.

When I restart the ftp-server with /etc/init.d/pure-ftpd restart - the output is as follows:

Restarting ftp server: Running: /usr/sbin/pure-ftpd -l puredb:/etc/pure-ftpd/pureftpd.pdb -l pam -E -8 UTF-8 -O clf:/var/log/pure-ftpd/transfer.log -P *IP-REMOVED-FOR-PRIVACY* -A -Y 2 -o -u 1000 -p *PORT-RANGE-REMOVED-FOR-PRIVACY* -c 60 -d -X -B
Restarting ftp upload handler: pure-uploadscript.

So the PureFTP is compiled with the whole upload-script-stuff...

Here a few steps/things I've already tried:

  • I thought that maybe it's because of PHP that it doesn't work. So I defined a Shell-Script to make a test-output to a file in /tmp-folder. But nothing happened after an upload - the script wasn't executed.

  • Originally, the script to be called resided in /opt/uploadscript/script.php
    So I thought, maybe if I put the script within the same webfolder where the ftpuser is uploading something, it might work (maybe because of some chroot-restrictions). So I put the uploadscript-folder into /var/www/vhost/domain.com/httpdocs/ which is the home-directory of the ftp-user. But still - nothing happenend after an upload.

  • To ensure that it is not a bug in my php-script, I replaced the original php-script by a testscript which just outputs a testfile created with touch() with the current date as filename. A shell-script doing the same didn't work either. Both scripts called from command line directly work perfectly.

Do you have any suggestions, what else I could try or am I even missing something essential?

Stefan
  • 337
  • 6
  • 20

1 Answers1

0

I have had it working by starting the pure-uploadscript manually. Debian Squeeze with a standard apt-get install.

The documentation is very specific about the order of execution (but you seem to have that right): "YOU MUST START PURE-FTPD FIRST and THEN START PURE-UPLOADSCRIPT. THE REVERSE ORDER WON'T WORK."

I have uid:1004 and gid: 1005 then I start the upload script like this (after the pure-ftp server is running):

pure-uploadscript -u 1004 -g 1005 -B -r testToSyslog.sh

However I have had another issues after starting to use an upload script - It seems that there is a problem with the /etc/init.d script not genrating pids correctly when utilizing the upload script. I have not found the root cause yet. But indications are here:

http://forums.gentoo.org/viewtopic-t-884904-start-0.html

Baxter
  • 3,035
  • 3
  • 20
  • 15
  • I actually start mine in the reverse order, otherwise it doesn't work, pure-ftpd just hangs until authd is started. – radtek May 06 '19 at 17:16