1 |
dpavlin |
14 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use blib; |
5 |
|
|
use Fuse::DBI; |
6 |
|
|
|
7 |
dpavlin |
25 |
my $template_dir = '/data/WebGUI/cms.rot13.org/uploads/temp/templates'; |
8 |
|
|
|
9 |
dpavlin |
14 |
my $sql_filenames = q{ |
10 |
|
|
select |
11 |
|
|
concat(templateid,name) as id, |
12 |
|
|
concat(namespace,'/',name,'.html') as filename, |
13 |
|
|
length(template) as size, |
14 |
|
|
iseditable as writable |
15 |
|
|
from template ; |
16 |
|
|
}; |
17 |
|
|
|
18 |
|
|
my $sql_read = q{ |
19 |
|
|
select template |
20 |
|
|
from template |
21 |
|
|
where concat(templateid,name) = ?; |
22 |
|
|
}; |
23 |
|
|
|
24 |
|
|
my $sql_update = q{ |
25 |
|
|
update template |
26 |
|
|
set template = ? |
27 |
|
|
where concat(templateid,name) = ?; |
28 |
|
|
}; |
29 |
|
|
|
30 |
|
|
my $mount = shift || '/mnt2'; |
31 |
|
|
|
32 |
|
|
my $mnt = Fuse::DBI->mount({ |
33 |
|
|
filenames => $sql_filenames, |
34 |
|
|
read => $sql_read, |
35 |
|
|
update => $sql_update, |
36 |
|
|
dsn => 'DBI:mysql:dbname=webgui_knjiznice_ffzg_hr', |
37 |
|
|
user => 'webgui', |
38 |
|
|
password => 'webgui', |
39 |
|
|
mount => $mount, |
40 |
dpavlin |
25 |
invalidate => sub { |
41 |
|
|
print STDERR "invalidating content in $template_dir\n"; |
42 |
|
|
opendir(DIR, $template_dir) || die "can't opendir $template_dir: $!"; |
43 |
|
|
map { unlink "$template_dir/$_" || warn "can't remove $template_dir/$_: $!" } grep { !/^\./ && -f "$template_dir/$_" } readdir(DIR); |
44 |
|
|
closedir DIR; |
45 |
|
|
} |
46 |
|
|
|
47 |
dpavlin |
14 |
}); |
48 |
|
|
|
49 |
|
|
print "Press enter to exit..."; |
50 |
|
|
my $foo = <STDIN>; |
51 |
|
|
|
52 |
|
|
$mnt->umount; |