a set of small scripts allowing to share files easily using a remote server which handles ssh and http. putbag consists of 2 components
- publish for uploading files to the share
- alimit and tlimit for cleaning the files after specified number of successful access or expiration of a timelimit
depends on: srm
A tool that publishes files and directories to a webserver via ssh, supports alimit/tlimit for a clean putbag.
- [-a <access ttl>]
- [-t <time expiry>] - can handle input like “2 weeks”
- [-d <ssh path> ] - where to upload to
- [-u <publishing url>] - the url prepended to the published content
These parameters can also be set in etc/putbagrc, ~.putbagrc and ./.putbagrc
sshpath=my.server.org:share
desturl=http://my.server.org/putbag/
alimit=10 # default always to 10 downloads
tlimit=1 week # default to share only briefly# publish -a 10 -t "2 weeks" funnyimage.png
http://my.server.org/putbag/funnyimage.pngThe result url is not only displayed, but also automatically copied to the clipboard.
… monitors ncsa logfiles for requests to limited files which after exceeding their TTL are deleted from the disk. This is useful for sharing files for a limited amount of downloads.
To alimit a file create a .<filename>.alimit file containing the number of allowed (and successful) downloads.
assuming you are publishing your files under an aliased directory to putbag run:
alimit.sh -r ~/share/ -l /var/log/nginx/access.log -a /putbag/alimit will log to stdout its activities.
Only handles HTTP 200 responses, continuation, redirects, etc are not covered
Create a file and set the limit to 3 downloads (assuming you have a webserver running on localhost):
sudo sh -c 'rm alimit.log; echo 'asdf' >/var/www/limited; echo 3 >/var/www/.limited.alimit'Run alimit
sudo ./alimit.shExecute 4 times:
# curl localhost/limited; curl localhost/.limited.alimitCheck out the log
# cat alimit.logA small cronjob that weeds out expired files from the monitored directory structure. use something similar in your crontab:
*/3 * * * * /home/user/putbag/tlimit.sh /home/user/public/
You might want to limit access to the .alimit files themselves. Do so using:
location ~ \..*\.[at]limit$ {
deny all;
}