/usr/sbin/octo_tool is in octopussy 1.0.6-0ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | #!/usr/bin/perl
=head1 NAME
octo_tool - Octopussy tool to do simple tasks
=head1 DESCRIPTION
octo_tool backup - Backups Octopussy configuration
octo_tool cache_clear - Clears Cache (msgid_stats or taxonomy_stats)
octo_tool message_copy - Copies Message from a Service to another Service
octo_tool message_move - Moves Message from a Service to another Service
octo_tool service_clone - Clones a Service
octo_tool table_clone - Clones a Table
=head1 SYNOPSIS
octo_tool <task> [options]
octo_tool backup <filename>
octo_tool cache_clear msgid_stats|taxonomy_stats
octo_tool message_copy <msgid_src> <msg_dst>
octo_tool message_move <msgid_src> <msg_dst>
octo_tool service_clone <servicename> <cloned_servicename>
octo_tool table_clone <tablename> <cloned_tablename>
=head1 OPTIONS
=over 4
=item B<-h,--help>
Prints this help.
=item B<-v,--version>
Prints version.
=back
=cut
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use POSIX qw(strftime);
use Octopussy::Cache;
use Octopussy::Configuration;
use Octopussy::Service;
use Octopussy::Table;
my $VERSION = '0.6';
my %option = ();
my %task = (
backup => \&Backup,
cache_clear => \&Cache_Clear,
message_copy => \&Message_Copy,
message_move => \&Message_Move,
service_clone => \&Service_Clone,
table_clone => \&Table_Clone,
);
my $status = GetOptions(
'h|help|?' => \$option{help},
'v|version' => sub { printf "octo_tool $VERSION\n"; exit; }
);
=head1 FUNCTIONS
=head2 Usage($msg)
Prints Script Usage
=cut
sub Usage
{
my $msg = shift;
if (defined $msg)
{
pod2usage(-verbose => 99, -sections => [ qw(SYNOPSIS OPTIONS) ],
-message => "\n$msg\n");
}
else
{
pod2usage(-verbose => 99, -sections => [ qw(SYNOPSIS OPTIONS) ]);
}
}
=head2 Backup($filename)
Backups Octopussy configuration
=cut
sub Backup
{
my $filename = shift;
my $timestamp = strftime("%Y%m%d%H%M%S", localtime);
$filename .= ($filename !~ /\.tgz$/ ? "_${timestamp}.tgz" : '');
Octopussy::Configuration::Backup($filename);
}
=head2 Cache_Clear($cache_name)
Clears Cache 'msgid_stats' or 'taxonomy_stats'
=cut
sub Cache_Clear
{
my $cache_name = shift;
Usage('[ERROR] Invalid number of args.') if (!defined $cache_name);
if ($cache_name eq 'msgid_stats')
{
Octopussy::Cache::Clear_MsgID_Stats();
}
elsif ($cache_name eq 'taxonomy_stats')
{
Octopussy::Cache::Clear_Taxonomy_Stats();
}
}
=head2 Message_Copy($msgid_src, $msgid_dst)
Copies Message 'msgid_src' to Message 'msgid_dst'
=cut
sub Message_Copy
{
my ($msgid_src, $msgid_dst) = @_;
Usage('[ERROR] Invalid number of args.') if (!defined $msgid_dst);
Octopussy::Service::Copy_Message($msgid_src, $msgid_dst);
}
=head2 Message_Move($msgid_src, $msgid_dst)
Moves Message 'msgid_src' to Message 'msgid_dst'
=cut
sub Message_Move
{
my ($msgid_src, $msgid_dst) = @_;
Usage('[ERROR] Invalid number of args.') if (!defined $msgid_dst);
my $nb_errors = Octopussy::Service::Copy_Message($msgid_src, $msgid_dst);
if ($nb_errors == 0)
{
my ($serv_src) = $msgid_src =~ /^(.+):.+$/;
Octopussy::Service::Remove_Message($serv_src, $msgid_src);
}
}
=head2 Service_Clone($service_orig, $service_clone)
Clones Service '$service_orig' in '$service_clone'
=cut
sub Service_Clone
{
my ($service_orig, $service_clone) = @_;
Usage('[ERROR] Invalid number of args.') if (!defined $service_clone);
my $service_orig_filename = Octopussy::Service::Filename($service_orig);
my $service_clone_filename = Octopussy::Service::Filename($service_clone);
Usage("[ERROR] Service '$service_orig' doesn't exist !")
if (!-f $service_orig_filename);
Usage("[ERROR] Service '$service_clone' already exists !")
if ((defined $service_clone_filename) && (-f $service_clone_filename));
Octopussy::Service::Clone($service_orig, $service_clone);
}
=head2 Table_Clone($table_orig, $table_clone)
Clones Table '$table_orig' in '$table_clone'
=cut
sub Table_Clone
{
my ($table_orig, $table_clone) = @_;
Usage('[ERROR] Invalid number of args.') if (!defined $table_clone);
my $table_orig_filename = Octopussy::Table::Filename($table_orig);
my $table_clone_filename = Octopussy::Table::Filename($table_clone);
Usage("[ERROR] Table '$table_orig' doesn't exist !")
if (!-f $table_orig_filename);
Usage("[ERROR] Table '$table_clone' already exists !")
if ((defined $table_clone_filename) && (-f $table_clone_filename));
Octopussy::Table::Clone($table_orig, $table_clone);
}
Usage() if ($option{help});
Usage('[ERROR] No task specified.') if (@ARGV < 1);
my $t = $ARGV[0];
my @args = @ARGV;
shift @args;
$task{$t}(@args) if (defined $task{$t});
|