+ update README for config options + cron jobs
This commit is contained in:
Luc Didry
2014-02-20 01:14:26 +01:00
parent 96072d0a2a
commit 2c9eca80e3
3 changed files with 64 additions and 2 deletions

View File

@@ -43,7 +43,9 @@ vi lutim.conf
* hosted\_by: if someone hosts your LUTIm instance, you can add some HTML (a logo for example) to make it appear on index page ;
* tweet\_card\_via: a twitter account which will appear on twitter cards ;
* max\_file\_size: well, this is explicit (default is 10Mio = 10485760 octets) ;
* https: 1 if you want to provide secure images URLs.
* https: 1 if you want to provide secure images URLs (default is 0) ;
* stats\_day\_num: when you generate statistics with `script/lutim cron stats`, you will have stats for the last `stats_day_num` days (default is 365) ;
* keep\_ip\_during: when you delete IP addresses of image's senders with `script/lutim cron cleanbdd`, the IP addresses of images older than `keep_ip_during` days will be deleted (default is 365) ;
##Usage
```
@@ -81,6 +83,27 @@ sub vcl_recv {
}
```
##Cron jobs
LUTIm have commands which can be used in cron jobs.
To see what commands are available:
```shell
carton exec script/lutim cron
```
###Statistics
To generate statistics which can be viewed at the address `/stats`:
```shell
carton exec script/lutim cron stats
```
###Delete IP adresses from database
To automatically delete the IP addresses of image's senders after a configurable delay:
```shell
carton exec script/lutim cron cleanbdd
```
##Shutter integration
See where Shutter (<http://en.wikipedia.org/wiki/Shutter_%28software%29>) keeps its plugins on your computer.
On my computer, it's in `/usr/share/shutter/resources/system/upload_plugins/upload`.

View File

@@ -0,0 +1,38 @@
package Mojolicious::Command::cron::cleanbdd;
use Mojo::Base 'Mojolicious::Command';
use LutimModel;
use Mojo::Util qw(slurp decode);
use Mojolicious::Plugin::Config;
has description => 'Delete IP addresses from database after configured delay.';
has usage => sub { shift->extract_usage };
sub run {
my $c = shift;
my $config = Mojolicious::Plugin::Config->parse(decode('UTF-8', slurp 'lutim.conf'), 'lutim.conf');
$config->{keep_ip_during} = (defined($config->{keep_ip_during})) ? $config->{keep_ip_during} : 365;
my $separation = time() - $config->{keep_ip_during} * 86400;
LutimModel->do(
'UPDATE lutim SET created_by = "" WHERE path IS NOT NULL AND created_at < ?',
{},
$separation
);
}
=encoding utf8
=head1 NAME
Mojolicious::Command::cron::cleanbdd - Delete IP addresses from database after configured delay
=head1 SYNOPSIS
Usage: script/lutim cron cleanbdd
=cut
1;

View File

@@ -16,5 +16,6 @@
max_file_size => 10485760, # optional, size in octets, you can write it 10*1024*1024
#hosted_by => 'My super hoster <img src="http://hoster.example.com" alt="Hoster logo">', # optional
#https => 0, # optional, set to 1 if you use Lutim behind a secure web server
#stats_day_num => 365, # optional, number of days shown in /stats page
#stats_day_num => 365, # optional, number of days shown in /stats page (used with script/lutim cron stats)
#keep_ip_during => 365, # optional, number of days, after that delay, the IP addresses of image creators will be deleted (used with script/lutim cron cleanbdd)
};