another fix for refresh and report errors
[perl-cwmp.git] / bin / acs.pl
1 #!/usr/bin/perl -w
2
3 # acs.pl
4 #
5 # 06/18/07 09:19:54 CEST Dobrica Pavlinusic <dpavlin@rot13.org>
6
7 use strict;
8
9 use lib './lib';
10 use CWMP::Server;
11 use CWMP::Session;
12 use Getopt::Long;
13 use Data::Dump qw/dump/;
14 use File::Find;
15
16 #use Devel::LeakTrace::Fast;
17
18 my $port = 3333;
19 my $debug = 0;
20 my $store_path = './';
21 my $store_plugin = 'YAML';
22 my $create_dump = 1;
23
24 GetOptions(
25         'debug+' => \$debug,
26         'port=i' => \$port,
27         'store-path=s' => \$store_path,
28         'store-plugin=s' => \$store_plugin,
29         'create_dump!' => \$create_dump,
30 );
31
32 if ( $create_dump ) {
33         warn "## cleaning dump directory\n" if $debug;
34         find({
35                 wanted => sub {
36                         my $path = $File::Find::name;
37                         return if -d $path;
38                         unlink($path) || die "can't remove $path: $!";
39                         warn "## removed $path\n" if $debug;
40                 },
41                 no_chdir => 1,
42         }, 'dump/' );
43 }
44
45 my $server = CWMP::Server->new({
46         port => $port,
47         session => {
48                 store => {
49                         module => $store_plugin,
50                         path => $store_path,
51                         debug => $debug,
52                 },
53                 create_dump => $create_dump,
54         },
55         debug => $debug,
56 });
57
58 $server->run();
59