5
octo_tool - Octopussy tool to do simple tasks
9
octo_tool backup - Backups Octopussy configuration
10
octo_tool cache_clear - Clears Cache (msgid_stats or taxonomy_stats)
11
octo_tool message_copy - Copies Message from a Service to another Service
12
octo_tool message_move - Moves Message from a Service to another Service
13
octo_tool service_clone - Clones a Service
14
octo_tool table_clone - Clones a Table
18
octo_tool <task> [options]
20
octo_tool backup <filename>
22
octo_tool cache_clear msgid_stats|taxonomy_stats
24
octo_tool message_copy <msgid_src> <msg_dst>
26
octo_tool message_move <msgid_src> <msg_dst>
28
octo_tool service_clone <servicename> <cloned_servicename>
30
octo_tool table_clone <tablename> <cloned_tablename>
53
use POSIX qw(strftime);
56
use Octopussy::Configuration;
57
use Octopussy::Service;
65
cache_clear => \&Cache_Clear,
66
message_copy => \&Message_Copy,
67
message_move => \&Message_Move,
68
service_clone => \&Service_Clone,
69
table_clone => \&Table_Clone,
72
my $status = GetOptions(
73
'h|help|?' => \$option{help},
74
'v|version' => sub { printf "octo_tool $VERSION\n"; exit; }
91
pod2usage(-verbose => 99, -sections => [ qw(SYNOPSIS OPTIONS) ],
92
-message => "\n$msg\n");
96
pod2usage(-verbose => 99, -sections => [ qw(SYNOPSIS OPTIONS) ]);
100
=head2 Backup($filename)
102
Backups Octopussy configuration
108
my $filename = shift;
110
my $timestamp = strftime("%Y%m%d%H%M%S", localtime);
111
$filename .= ($filename !~ /\.tgz$/ ? "_${timestamp}.tgz" : '');
112
Octopussy::Configuration::Backup($filename);
115
=head2 Cache_Clear($cache_name)
117
Clears Cache 'msgid_stats' or 'taxonomy_stats'
123
my $cache_name = shift;
125
Usage('[ERROR] Invalid number of args.') if (!defined $cache_name);
127
if ($cache_name eq 'msgid_stats')
129
Octopussy::Cache::Clear_MsgID_Stats();
131
elsif ($cache_name eq 'taxonomy_stats')
133
Octopussy::Cache::Clear_Taxonomy_Stats();
137
=head2 Message_Copy($msgid_src, $msgid_dst)
139
Copies Message 'msgid_src' to Message 'msgid_dst'
145
my ($msgid_src, $msgid_dst) = @_;
147
Usage('[ERROR] Invalid number of args.') if (!defined $msgid_dst);
149
Octopussy::Service::Copy_Message($msgid_src, $msgid_dst);
152
=head2 Message_Move($msgid_src, $msgid_dst)
154
Moves Message 'msgid_src' to Message 'msgid_dst'
160
my ($msgid_src, $msgid_dst) = @_;
162
Usage('[ERROR] Invalid number of args.') if (!defined $msgid_dst);
164
my $nb_errors = Octopussy::Service::Copy_Message($msgid_src, $msgid_dst);
167
my ($serv_src) = $msgid_src =~ /^(.+):.+$/;
168
Octopussy::Service::Remove_Message($serv_src, $msgid_src);
172
=head2 Service_Clone($service_orig, $service_clone)
174
Clones Service '$service_orig' in '$service_clone'
180
my ($service_orig, $service_clone) = @_;
182
Usage('[ERROR] Invalid number of args.') if (!defined $service_clone);
184
my $service_orig_filename = Octopussy::Service::Filename($service_orig);
185
my $service_clone_filename = Octopussy::Service::Filename($service_clone);
186
Usage("[ERROR] Service '$service_orig' doesn't exist !")
187
if (!-f $service_orig_filename);
188
Usage("[ERROR] Service '$service_clone' already exists !")
189
if ((defined $service_clone_filename) && (-f $service_clone_filename));
191
Octopussy::Service::Clone($service_orig, $service_clone);
194
=head2 Table_Clone($table_orig, $table_clone)
196
Clones Table '$table_orig' in '$table_clone'
202
my ($table_orig, $table_clone) = @_;
204
Usage('[ERROR] Invalid number of args.') if (!defined $table_clone);
206
my $table_orig_filename = Octopussy::Table::Filename($table_orig);
207
my $table_clone_filename = Octopussy::Table::Filename($table_clone);
208
Usage("[ERROR] Table '$table_orig' doesn't exist !")
209
if (!-f $table_orig_filename);
210
Usage("[ERROR] Table '$table_clone' already exists !")
211
if ((defined $table_clone_filename) && (-f $table_clone_filename));
212
Octopussy::Table::Clone($table_orig, $table_clone);
216
Usage() if ($option{help});
217
Usage('[ERROR] No task specified.') if (@ARGV < 1);
223
$task{$t}(@args) if (defined $task{$t});