bin/toaster_setup.pl

filter: Statementstmt 50.7% 35 / 69 Branchbran 42.3% 61 / 144 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 46.0% 104 / 226 SCAR 15.1
CC
3
Cov
45%
all
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
« blib/script/toaster_setup.pl ↑ Summary blib/script/toaster-watcher.pl »
1 #!/usr/bin/perl
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use English '-no_match_vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 $OUTPUT_AUTOFLUSH++;
10 1 GetOptions ( 'section=s' => \my $section, 'verbose' => \my $verbose );
11 1 ▶$verbose = 0 unless defined $verbose;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $verbose 1 0 1
12  
13 1 ▶use lib 'lib';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Mail::Toaster 5.42;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 my $toaster = Mail::Toaster->new;
16 1 $toaster->verbose($verbose);
17  
18 1 ▶print "verbose mode enabled\n\n" if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 1 1
19  
20 1 ▶if ( ! $section ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($section) 0 1 1
21 0 pod2usage( { -verbose=>0, });
22 0 die "You must choose a section!\n";
23 };
24  
25 # these sections do not require root privs to run
26 1 my $root_agnostic = { help => 1, docs => 1, test2 => 1, };
27  
28 # everything else requires root
29 1 ▶if ( $UID != 0 && !$root_agnostic->{$section} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($main::UID != 0 and not $root_agnostic->{$section}) 0 1 1
Condition33%1/3
$main::UID != 0 and not $root_agnostic->{$section}
!ll&&!rl&&r
010
MC/DC0%0/2
$main::UID != 0 and not $root_agnostic->{$section}
$main::UID != 0 not $root_agnostic->{$section}
Truth table33%1/3
A and not(B)
A= $main::UID != 0B= not $root_agnostic->{$section}
ABresult
0X0
100
111
30 0 die "Thou shalt have root to proceed!\n";
31 };
32  
33 1 ▶if ( $verbose ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose) { } 0 1 1
34 0 $toaster->conf->{'toaster_verbose'} = 1;
35 0 $toaster->{verbose} = 1;
36 }
37 else {
38 1 $toaster->{verbose} = 0;
39 };
40  
41 1 my $setup = $toaster->setup;
42 1 my $qmail = $toaster->qmail;
43  
44 1 ▶ $section eq 'pre' ? $setup->dependencies
Branch: 65 branches
BranchTrueFalseTotal
$section eq 'pre' ? : 0 1 1
$section eq 'cpan' ? : 0 1 1
$section eq 'docs' ? : 0 1 1
$section eq 'help' ? : 0 1 1
$section eq 'config' ? : 0 1 1
$section eq 'ssl' ? : 0 1 1
$section eq 'ports' ? : 0 1 1
$section eq 'portmaster' ? : 0 1 1
$section eq 'mysql' ? : 0 1 1
$section eq 'lighttpd' ? : 0 1 1
$section eq 'apache' ? : 0 1 1
$section eq 'apachessl' ? : 0 1 1
$section eq 'cronolog' ? : 0 1 1
$section eq 'ucspi' ? : 0 1 1
$section eq 'daemontools' ? : 0 1 1
$section eq 'ezmlm' ? : 0 1 1
$section eq 'autorespond' ? : 0 1 1
$section eq 'vpopmail' ? : 0 1 1
$section eq 'vpeconfig' ? : 0 1 1
$section eq 'vpopmysql' ? : 0 1 1
$section eq 'vqadmin' ? : 0 1 1
$section eq 'qmail' ? : 0 1 1
$section eq 'qmailconf' ? : 0 1 1
$section eq 'netqmail' ? : 0 1 1
$section eq 'netqmailmac' ? : 0 1 1
$section eq 'djbdns' ? : 0 1 1
$section eq 'dovecot' ? : 0 1 1
$section eq 'courier' ? : 0 1 1
$section eq 'courierconf' ? : 0 1 1
$section eq 'qmailadmin' ? : 0 1 1
$section eq 'sqwebmail' ? : 0 1 1
$section eq 'squirrelmail' ? : 0 1 1
$section eq 'roundcube' ? : 0 1 1
$section eq 'filter' ? : 0 1 1
$section eq 'razor' ? : 0 1 1
$section eq 'maildrop' ? : 0 1 1
$section eq 'clamav' ? : 0 1 1
$section eq 'simscan' ? : 0 1 1
$section eq 'simconf' ? : 0 1 1
$section eq 'simtest' ? : 0 1 1
$section eq 'spamassassin' ? : 0 1 1
$section eq 'allspam' ? : 0 1 1
$section eq 'maillogs' ? : 0 1 1
$section eq 'socklog' ? : 0 1 1
$section eq 'isoqlog' ? : 0 1 1
$section eq 'supervise' ? : 0 1 1
$section eq 'munin' ? : 0 1 1
$section eq 'test' ? : 0 1 1
$section eq 'filtertest' ? : 0 1 1
$section eq 'authtest' ? : 0 1 1
$section eq 'proctest' ? : 0 1 1
$section eq 'imap' ? : 0 1 1
$section eq 'pop3' ? : 0 1 1
$section eq 'smtp' ? : 0 1 1
$section eq 'rbltest' ? : 0 1 1
$section eq 'test2' ? : 1 0 1
$section eq 'toaster' ? : 0 0 0
$section eq 'nictool' ? : 0 0 0
$section eq 'webmail' ? : 0 0 0
$section eq 'all' ? : 0 0 0
$section eq 'mattbundle' ? : 0 0 0
$section eq 'qss' ? : 0 0 0
$section eq 'logmonster' ? : 0 0 0
$section eq 'mrm' ? : 0 0 0
$section eq 'phpmyadmin' ? : 0 0 0
45 : $section eq 'cpan' ? $setup->cpan
46 : $section eq 'docs' ? $setup->docs
47 : $section eq 'help' ? pod2usage( {-verbose=>1 } )
48 : $section eq 'config' ? $setup->config->config
49 : $section eq 'ssl' ? $setup->openssl_conf
50  
51 # port management on FreeBSD and Darwin
52 : $section eq 'ports' ? $setup->ports
53 : $section eq 'portmaster' ? $setup->portmaster
54  
55 # Standard daemons & utilities
56 : $section eq 'mysql' ? $toaster->mysql->install
57 : $section eq 'lighttpd' ? $setup->lighttpd
58 : $section eq 'apache' ? $setup->apache
59 : $section eq 'apachessl' ? $setup->apache(ver=>'ssl')
60 : $section eq 'cronolog' ? $setup->cronolog
61  
62 # Qmail & related
63 : $section eq 'ucspi' ? $setup->ucspi_tcp
64 : $section eq 'daemontools'? $setup->daemontools
65 : $section eq 'ezmlm' ? $setup->ezmlm
66 : $section eq 'autorespond'? $setup->autorespond
67 : $section eq 'vpopmail' ? $setup->vpopmail->install
68 : $section eq 'vpeconfig' ? $setup->vpopmail->etc
69 : $section eq 'vpopmysql' ? $setup->vpopmail->mysql_privs
70 : $section eq 'vqadmin' ? $setup->vqadmin
71 : $section eq 'qmail' ? $qmail->install_qmail
72 : $section eq 'qmailconf' ? $qmail->config
73 : $section eq 'netqmail' ? $qmail->netqmail
74 : $section eq 'netqmailmac'? $qmail->netqmail_virgin
75 : $section eq 'djbdns' ? $setup->djbdns
76  
77 # mail servers
78 : $section eq 'dovecot' ? $setup->dovecot
79 : $section eq 'courier' ? $setup->courier_imap
80 : $section eq 'courierconf'? $setup->courier_config
81  
82 # Web Mail & Admin interfaces
83 : $section eq 'qmailadmin' ? $setup->qmailadmin
84 : $section eq 'sqwebmail' ? $setup->sqwebmail
85 : $section eq 'squirrelmail'? $setup->squirrelmail
86 : $section eq 'roundcube' ? $setup->roundcube
87  
88 # Mail Filtering
89 : $section eq 'filter' ? $setup->filtering
90 : $section eq 'razor' ? $setup->razor
91 : $section eq 'maildrop' ? $setup->maildrop->install
92 : $section eq 'clamav' ? $setup->clamav
93 : $section eq 'simscan' ? $setup->simscan->install
94 : $section eq 'simconf' ? $setup->simscan->config
95 : $section eq 'simtest' ? $setup->simscan->test
96 : $section eq 'spamassassin'? $setup->spamassassin
97 : $section eq 'allspam' ? $setup->enable_all_spam
98  
99 # Logs, Statistics & Monitoring
100 : $section eq 'maillogs' ? $setup->maillogs
101 : $section eq 'socklog' ? $setup->socklog
102 : $section eq 'isoqlog' ? $setup->isoqlog
103 : $section eq 'supervise' ? $setup->supervise
104 : $section eq 'munin' ? $setup->munin
105  
106 # test targets
107 : $section eq 'test' ? $setup->test->run_all
108 : $section eq 'filtertest' ? $setup->simscan->test
109 : $section eq 'authtest' ? $setup->test->auth
110 : $section eq 'proctest' ? $toaster->check_running_processes
111 : $section eq 'imap' ? $setup->test->imap_auth
112 : $section eq 'pop3' ? $setup->test->pop3_auth
113 : $section eq 'smtp' ? $setup->test->smtp_auth
114 : $section eq 'rbltest' ? $setup->test->rbls
115 : $section eq 'test2' ? exit 0
116  
117 # misc
118 : $section eq 'toaster' ? $setup->util->mail_toaster
119 : $section eq 'nictool' ? $setup->nictool
120 : $section eq 'webmail' ? $setup->webmail
121 : $section eq 'all' ? all()
122  
123 # deprecated
124 : $section eq 'mattbundle' ? $setup->mattbundle
125 : $section eq 'qss' ? $setup->qs_stats
126 : $section eq 'logmonster' ? $setup->logmonster
127 : $section eq 'mrm' ? $setup->mrm
128 : $section eq 'phpmyadmin' ? $setup->phpmyadmin
129  
130 : pod2usage( {-verbose=>1} );
131  
132 sub all {
133 0 ▶ $setup->config->config;
Subroutine all: not called CC=3 SCAR=24.8
134  
135 # re-initialize $conf with new settings.
136 0 $setup->util->parse_config( "toaster-watcher.conf");
137 0 ▶ $toaster->{'verbose'} = 1 if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 0 0
138 0 ▶ $toaster->conf->{'toaster_verbose'} = 1 if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 0 0
139  
140 0 $setup->dependencies ;
141 0 $setup->openssl_conf ;
142 0 $setup->ports ;
143 0 $toaster->mysql->install;
144 0 $setup->ucspi_tcp ;
145 0 $setup->ezmlm ;
146 0 $setup->vpopmail->install;
147 0 $qmail->netqmail ;
148 0 $setup->maildrop->install;
149 0 $setup->dovecot ;
150 0 $setup->apache ;
151 0 $setup->lighttpd ;
152 0 $setup->webmail (fatal=>0);
153 0 $setup->vqadmin ;
154 0 $setup->qmailadmin ;
155 0 $setup->sqwebmail ;
156 0 $setup->squirrelmail ;
157 0 $setup->roundcube ;
158 0 $setup->clamav ;
159 0 $setup->filtering ;
160 # $setup->spamassassin ; # included with filtering
161 # $setup->simscan ; # included "
162 0 $setup->maillogs ;
163 0 $setup->supervise ;
164 0 $setup->test->run_all ;
165 }
166  
167 0 print "\n$0 script execution complete.\n";
168  
169 0 exit 1;
170 __END__
171  
172  
173 =head1 NAME
174  
175 toaster_setup.pl - runs various build and testing functions for Mail::Toaster
176  
177  
178 =head1 SYNOPSIS
179  
180 toaster_setupl.pl is the front end to everything you need to turn a computer into a secure, full-featured, high-performance mail server.
181  
182 toaster_setup.pl -s <help> [-d]
183  
184 -s[ection] - see OPTIONS AND ARGUMENTS section for choices
185 -v[erbose] - enable verbose output
186  
187  
188 A really good place to start is:
189  
190 toaster_setupl.pl -s help | less
191  
192  
193 =head1 DESCRIPTION
194  
195 The mail toaster is a collection of open-source software which provides a full-featured mail server running on FreeBSD, Mac OS X, and Linux. The system is built around the qmail mail transport agent, with many additions and modifications. Matt Simerson is the primary author and maintainer of the toaster. There is an active and friendly community of toaster owners which supports the toaster on a mailing list and web forum.
196  
197 The toaster is built around qmail, a robust mail transfer agent by Daniel J. Bernstein, and vpopmail, a virtual domain manager by Inter7 systems. Matt keeps up with releases of the core software, evaluates them, decides when they are stable, and then integrates them into the toaster. Matt has also added several patches which add functionality to these core programs.
198  
199 A complete set of instructions for building a mail toaster are on the toaster install page. There is a substantial amount of documentation available for the "Mail::Toaster" toaster. Much of it is also readable via "perldoc Mail::Toaster", and the subsequent pages. Don't forget to read the Install, Configure, and FAQ pages on the web site. If you still have questions, there is a Web Forum and mailing list. Both are browseable and searchable for your convenience.
200  
201  
202 =head2 URLs
203  
204 http://mail-toaster.org/
205 http://www.tnpi.net/internet/mail/toaster/
206  
207  
208 =head1 OPTIONS AND ARGUMENTS
209  
210 toaster_setup.pl -s <section> [-verbose]
211  
212 help - print this usage screen
213 config - initial configuration of toaster*.conf files
214 pre - installs a list of programs and libraries other toaster components need
215  
216 Standard Daemons & Utilities
217 mysql - installs MySQL
218 phpmyadmin - installs phpMyAdmin
219 apache - installs Apache
220 apachessl - installs self signed SSL certs for Apache
221  
222 Qmail and related tools
223 ucspi - install ucspi-tcp w/MySQL patch
224 daemontools - install daemontools
225 ezmlm - install EzMLM idx
226 vpopmail - installs vpopmail
227 vpeconfig - configure ~vpopmail/etc/tcp.smtp
228 vpopmysql - run the vpopmail MySQL grant and db create commands
229 vqadmin - install vqadmin
230 qmail - installs qmail with toaster patches
231 qmailconf - configure various qmail control files
232 netqmail - installs netqmail
233 netqmailmac - installs netqmail with no patches
234 djbdns - install the djbdns program
235  
236 courier - installs courier imap & pop3 daemons
237 courierconf - post install configure for courier
238  
239 Web Mail and Admin interfaces
240 qmailadmin - installs qmailadmin
241 sqwebmail - installs sqwebmail (webmail app)
242 squirrelmail - installs squirrelmail (webmail app)
243 roundcube - installs Roundcube (webmail app)
244  
245 Mail Filtering
246 filter - installs SpamAssassin, ClamAV, DCC, razor, and more
247 razor - installs the razor2 agents
248 maildrop - installs maildrop and mailfilter
249 clamav - installs just ClamAV
250 simscan - install simscan
251 simconf - configure simscan
252 simtest - run email tests to verify that simscan is working
253 spamassassin - install and configure spamassassin
254 allspam - activate spam filtering for all users
255  
256 Logs, Statistics, and Monitoring
257 maillogs - creates the mail logging directories
258 socklog - installs socklog
259 isoqlog - installs and configured isoqlog
260 supervise - creates the directories to be used by svscan
261  
262 test - runs a complete test suite against your server
263 filtertest - runs the simscan and qmail-scanner email scanner tests
264 authtest - authenticates against pop, imap, and smtp servers
265 proctest - check for processes that *should* be running
266 imap|pop3|smtp - do authentication test for imap, pop3, or smtp-auth
267  
268 toaster - install Mail::Toaster
269 logmonster - install Apache::Logmonster
270 nictool - install nictool (http://www.nictool.com/)
271 all - installs everything shown on the toaster INSTALL page
272  
273 =head1 METHODS
274  
275 =over 8
276  
277 =item all
278  
279 toaster_setup.pl -s all
280  
281  
282 a special target that tries to build the entire Mail::Toaster without any interaction from you. Unlike other targets, it will keep right on going when it encounters an error, getting as much built as it possibly can. It is presumed that the administrator is logging the output for later review. I use this target primarily in testing.
283  
284 =back
285  
286 =head1 AUTHOR
287  
288 Matt Simerson (matt@tnpi.net)
289  
290  
291 =head1 BUGS
292  
293 None known. Report any to author, preferably via RT http://rt.cpan.org/Public/Bug/Report.html?Queue=Mail-Toaster
294  
295 Patches welcome in "diff -u" format.
296  
297  
298 =head1 TODO
299  
300 Add -s dnscache section to install a DNS stub resolver
301 Check if daemons are running before installs. - mostly done
302 Turn entire process into a ./install_it_all script - done
303  
304  
305 =head1 SEE ALSO
306  
307 The following are all man/perldoc pages:
308  
309 Mail::Toaster::Conf
310 toaster.conf
311 toaster-watcher.conf
312  
313 Mail::Toaster
314 Mail::Toaster::Apache
315 Mail::Toaster::CGI
316 Mail::Toaster::DNS
317 Mail::Toaster::Darwin
318 Mail::Toaster::Ezmlm
319 Mail::Toaster::FreeBSD
320 Mail::Toaster::Logs
321 Mail::Toaster::Mysql
322 Mail::Toaster::Qmail
323 Mail::Toaster::Setup
324 Mail::Toaster::Utility
325  
326 http://mail-toaster.org/
327 http://mail-toaster.org/docs/
328 http://mail-toaster.org/faq.shtml
329 http://mail-toaster.org/changes.shtml
330  
331 =cut
« blib/script/toaster_setup.pl ↑ Summary blib/script/toaster-watcher.pl »