Pure-FTP uploadscript

Vote 0 Votes

Pure-FTPd 在 configure 時加 --with-uploadscript 參數可以 enable uploadscript 的功能,
就是上傳檔案後可以呼叫外部程式或 script.

pure-ftpd 啟動參數加 -o, 有設定檔(pure-ftpd.conf)的系統就設 CallUploadScript yes

必需先啟動 pure-ftpd 後再啟動 pure-uploadscript, 不然無法運作.
pure-uploadscript -Br /usr/local/bin/uploadscript.sh

上傳檔案的絕對路徑會帶到第一個參數 $1
$UPLOAD_SIZE : the size of the file, in bytes.
$UPLOAD_PERMS : the permissions, as an octal value.
$UPLOAD_UID : the uid of the owner.
$UPLOAD_GID : the group the file belongs to.
$UPLOAD_USER : the name of the owner.
$UPLOAD_GROUP : the group name the file belongs to.
$UPLOAD_VUSER : the full user name, or the virtual user name. (127 chars max)

uploadscript 範例, 上傳的檔會移到 /tmp/日期 目錄下, 並記錄一筆 Log 到 /var/log/uploadscript.log
DIR=/tmp/`date +%Y%m%d`
[ -d $DIR ] || mkdir $DIR
mv "$1" $DIR
echo `date` size $UPLOAD_SIZE by $UPLOAD_USER >> /var/log/uploadscript.log

Pure-FTPd 1.0.29 released on 2010-03-15, 最近改版還滿勤的.

另一套 ProFTPD 在 1.3.3 版(2010-02-24 Released)也加入了 mod_exec,
比起 Pure-FTPd uploadscript 更為強大, 各種 FTP 的 event 都能呼叫外部程式或 script.

Leave a comment

About this Entry

This page contains a single entry by Pank published on March 23, 2010 10:28 PM.

Enable syslog server was the previous entry in this blog.

UTF-8 CSV for Excel is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives