https://github.com/stef/putbag
provides expiration of access to files served by webservers
https://github.com/stef/putbag
Last synced: over 1 year ago
JSON representation
provides expiration of access to files served by webservers
- Host: GitHub
- URL: https://github.com/stef/putbag
- Owner: stef
- Created: 2012-08-22T19:17:51.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2012-08-27T12:18:53.000Z (almost 14 years ago)
- Last Synced: 2025-02-01T23:17:19.260Z (over 1 year ago)
- Language: Shell
- Homepage:
- Size: 168 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* 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 ]
- [-t
These parameters can also be set in /etc/putbagrc, ~/.putbagrc and ./.putbagrc
#+BEGIN_SRC sh
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
#+END_SRC
#+BEGIN_SRC sh
# publish -a 10 -t "2 weeks" funnyimage.png
http://my.server.org/putbag/funnyimage.png
#+END_SRC
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 ..alimit file containing the
number of allowed (and successful) downloads.
assuming you are publishing your files under an aliased directory to
/putbag/ run:
#+BEGIN_SRC sh
alimit.sh -r ~/share/ -l /var/log/nginx/access.log -a /putbag/
#+END_SRC
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):
#+BEGIN_SRC sh
sudo sh -c 'rm alimit.log; echo 'asdf' >/var/www/limited; echo 3 >/var/www/.limited.alimit'
#+END_SRC
Run alimit
#+BEGIN_SRC sh
sudo ./alimit.sh
#+END_SRC
Execute 4 times:
#+BEGIN_SRC sh
# curl localhost/limited; curl localhost/.limited.alimit
#+END_SRC
Check out the log
#+BEGIN_SRC sh
# cat alimit.log
#+END_SRC
** tlimit.sh
A small cronjob that weeds out expired files from the monitored directory structure.
use something similar in your crontab:
#+BEGIN_SRC
*/3 * * * * /home/user/putbag/tlimit.sh /home/user/public/
#+END_SRC
* nginx
You might want to limit access to the .alimit files themselves. Do so using:
#+BEGIN_SRC
location ~ \..*\.[at]limit$ {
deny all;
}
#+END_SRC