File Coverage

blib/lib/App/Spoor.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 11 11 100.0


line stmt bran cond sub pod time code
1             package App::Spoor;
2              
3 1     1   161507 use v5.10;
  1         5  
4 1     1   6 use strict;
  1         2  
  1         22  
5 1     1   5 use warnings;
  1         2  
  1         73  
6              
7             =head1 NAME
8              
9             App::Spoor - A CPanel client for the Spoor service
10              
11             =head1 VERSION
12              
13             Version 0.06
14              
15             =cut
16              
17             our $VERSION = '0.06';
18              
19             =head1 SYNOPSIS
20              
21             This module (for now) only contains code to provide a naive implementation of a client for the
22             Spoor API that plays nicely with CPanel.
23              
24             It is built with the following principles in mind:
25              
26             =over
27              
28             =item * Minimise the impact of the code on the existing CPanel instance
29              
30             =item * Minimise the footprint on the host, by keeping the dependencies to a bare minimum
31              
32             =item * Be as transparent as possible about the data that is being submitted
33              
34             =back
35              
36             Within the above context, App::Spoor consists of 3 main parts:
37              
38             =over
39              
40             =item * Scripts running under systemd that tail the CPanel access, error and login logs
41              
42             =item * A transmitter script (also running under systemd) that communicates with the Spoor API
43              
44             =item * A module that registers functionality for tracking changes to mail forwarding within the CPanel standardised hook framework
45              
46             =back
47              
48             =head2 Installing
49              
50             Before installing the module, you will need to enable the logging of successful logins via WHM. At the time of writing,
51             this can be found by navigating to Server Configuration -> Tweak Settings -> Logging.
52              
53             Once you have installed the module run the following from the commandline:
54              
55             spoor_installer
56              
57             It will setup a config file, some persistence directories, a number of systemd unit files and it will also create the
58             file that will register functionality against CPanel's standardised hooks.
59              
60             Once it has completed, it will list a number of actions that must be performed (as root)before the installation is complete:
61              
62             systemctl enable spoor-access-follower.service
63             systemctl enable spoor-error-follower.service
64             systemctl enable spoor-login-follower.service
65             systemctl enable spoor-transmitter.service
66             systemctl start spoor-access-follower.service
67             systemctl start spoor-error-follower.service
68             systemctl start spoor-login-follower.service
69             systemctl start spoor-transmitter.service
70             cd /usr/local/cpanel/bin/
71             ./manage_hooks add module SpoorForwardHook
72              
73             The install script will create a number of directories, a config file for Spoor as well as several systemd unit files.
74              
75             =head2 Operation
76              
77             App::Spoor operates on a simple principe of tailing CPanel's access, error and login log files. The follower services
78             monitor the log files and if they come across an item of interest, they create a JSON-representation of the event and
79             write it to /var/lib/spoor/parsed.
80              
81             The transmitter service monitors /var/lib/spoor/parsed for any changes and sends these to the Spoor API. If a transmission
82             recives a response of HTTP 202, the JSON file is moved to /var/lib/spoor/transmitted, otherwise it remains in /var/lib/spoor/parsed and
83             the transmitter will keep on retrying, pretty much until the end of time.
84              
85             =head2 Uninstalling
86              
87             To uninstall,do the following (the below assumes that you are using cpanminus):
88              
89             cd /usr/local/cpanel/bin/
90             ./manage_hooks delete module SpoorForwardHook
91              
92             systemctl stop spoor-access-follower.service
93             systemctl stop spoor-error-follower.service
94             systemctl stop spoor-login-follower.service
95             systemctl stop spoor-transmitter.service
96             systemctl disable spoor-access-follower.service
97             systemctl disable spoor-error-follower.service
98             systemctl disable spoor-login-follower.service
99             systemctl disable spoor-transmitter.service
100              
101             rm -rf /etc/spoor
102             rm -rf /var/lib/spoor
103              
104             cpanm --uninstall App::Spoor
105              
106             =head2 Windows
107              
108             For now, App::Spoor does not support Windows installations.
109              
110             =cut
111              
112             =head1 AUTHOR
113              
114             Rory McKinley, C<< <rorymckinley at capefox.co> >>
115              
116             =head1 BUGS
117              
118             Please report any bugs or feature requests to C<bug-app-spoor at rt.cpan.org>, or through
119             the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-Spoor>. I will be notified, and then you'll
120             automatically be notified of progress on your bug as I make changes.
121              
122             =head1 SUPPORT
123              
124             You can find documentation for this module with the perldoc command.
125              
126             perldoc App::Spoor
127              
128              
129             You can also look for information at:
130              
131             =over 4
132              
133             =item * RT: CPAN's request tracker (report bugs here)
134              
135             L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Spoor>
136              
137             =item * AnnoCPAN: Annotated CPAN documentation
138              
139             L<http://annocpan.org/dist/App-Spoor>
140              
141             =item * CPAN Ratings
142              
143             L<https://cpanratings.perl.org/d/App-Spoor>
144              
145             =item * Search CPAN
146              
147             L<https://metacpan.org/release/App-Spoor>
148              
149             =back
150              
151             =head1 LICENSE AND COPYRIGHT
152              
153             Copyright 2019 Rory McKinley.
154              
155             This program is free software; you can redistribute it and/or modify it
156             under the terms of the the Artistic License (2.0). You may obtain a
157             copy of the full license at:
158              
159             L<http://www.perlfoundation.org/artistic_license_2_0>
160              
161             Any use, modification, and distribution of the Standard or Modified
162             Versions is governed by this Artistic License. By using, modifying or
163             distributing the Package, you accept this license. Do not use, modify,
164             or distribute the Package, if you do not accept this license.
165              
166             If your Modified Version has been derived from a Modified Version made
167             by someone other than you, you are nevertheless required to ensure that
168             your Modified Version complies with the requirements of this license.
169              
170             This license does not grant you the right to use any trademark, service
171             mark, tradename, or logo of the Copyright Holder.
172              
173             This license includes the non-exclusive, worldwide, free-of-charge
174             patent license to make, have made, use, offer to sell, sell, import and
175             otherwise transfer the Package with respect to any patent claims
176             licensable by the Copyright Holder that are necessarily infringed by the
177             Package. If you institute patent litigation (including a cross-claim or
178             counterclaim) against any party alleging that the Package constitutes
179             direct or contributory patent infringement, then this Artistic License
180             to you shall terminate on the date that such litigation is filed.
181              
182             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
183             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
184             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
185             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
186             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
187             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
188             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
189             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
190              
191              
192             =cut
193              
194             1; # End of App::Spoor