Skip to content

stef/putbag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

putbag

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

publish

A tool that publishes files and directories to a webserver via ssh, supports alimit/tlimit for a clean putbag.

Parameters

  • [-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.png

The result url is not only displayed, but also automatically copied to the clipboard.

alimit.sh

… 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.

Limitations

Only handles HTTP 200 responses, continuation, redirects, etc are not covered

example

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.sh

Execute 4 times:

# curl localhost/limited; curl localhost/.limited.alimit

Check out the log

# cat alimit.log

tlimit.sh

A 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/

nginx

You might want to limit access to the .alimit files themselves. Do so using:

location ~ \..*\.[at]limit$ {
        deny all;
}

About

provides expiration of access to files served by webservers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages