| 1 | #!/usr/local/bin/perl | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | use English '-no_match_vars'; | ||
| 6 | use Getopt::Long; | ||
| 7 | use Pod::Usage; | ||
| 8 | |||
| 9 | $OUTPUT_AUTOFLUSH++; | ||
| 10 | GetOptions ( 'section=s' => \my $section, 'verbose' => \my $verbose ); | ||
| 11 | $verbose = 0 unless defined $verbose; | ||
| 12 | |||
| 13 | use lib 'lib'; | ||
| 14 | use Mail::Toaster 5.42; | ||
| 15 | my $toaster = Mail::Toaster->new; | ||
| 16 | $toaster->verbose($verbose); | ||
| 17 | |||
| 18 | print "verbose mode enabled\n\n" if $verbose; | ||
| 19 | |||
| 20 | if ( ! $section ) { | ||
| 21 | pod2usage( { -verbose=>0, }); | ||
| 22 | die "You must choose a section!\n"; | ||
| 23 | }; | ||
| 24 | |||
| 25 | # these sections do not require root privs to run | ||
| 26 | my $root_agnostic = { help => 1, docs => 1, test2 => 1, }; | ||
| 27 | |||
| 28 | # everything else requires root | ||
| 29 | if ( $UID != 0 && !$root_agnostic->{$section} ) { | ||
| 30 | die "Thou shalt have root to proceed!\n"; | ||
| 31 | }; | ||
| 32 | |||
| 33 | if ( $verbose ) { | ||
| 34 | $toaster->conf->{'toaster_verbose'} = 1; | ||
| 35 | $toaster->{verbose} = 1; | ||
| 36 | } | ||
| 37 | else { | ||
| 38 | $toaster->{verbose} = 0; | ||
| 39 | }; | ||
| 40 | |||
| 41 | my $setup = $toaster->setup; | ||
| 42 | my $qmail = $toaster->qmail; | ||
| 43 | |||
| 44 | $section eq 'pre' ? $setup->dependencies | ||
| 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 | $setup->config->config; | ||
| 134 | |||
| 135 | # re-initialize $conf with new settings. | ||
| 136 | $setup->util->parse_config( "toaster-watcher.conf"); | ||
| 137 | $toaster->{'verbose'} = 1 if $verbose; | ||
| 138 | $toaster->conf->{'toaster_verbose'} = 1 if $verbose; | ||
| 139 | |||
| 140 | $setup->dependencies ; | ||
| 141 | $setup->openssl_conf ; | ||
| 142 | $setup->ports ; | ||
| 143 | $toaster->mysql->install; | ||
| 144 | $setup->ucspi_tcp ; | ||
| 145 | $setup->ezmlm ; | ||
| 146 | $setup->vpopmail->install; | ||
| 147 | $qmail->netqmail ; | ||
| 148 | $setup->maildrop->install; | ||
| 149 | $setup->dovecot ; | ||
| 150 | $setup->apache ; | ||
| 151 | $setup->lighttpd ; | ||
| 152 | $setup->webmail (fatal=>0); | ||
| 153 | $setup->vqadmin ; | ||
| 154 | $setup->qmailadmin ; | ||
| 155 | $setup->sqwebmail ; | ||
| 156 | $setup->squirrelmail ; | ||
| 157 | $setup->roundcube ; | ||
| 158 | $setup->clamav ; | ||
| 159 | $setup->filtering ; | ||
| 160 | # $setup->spamassassin ; # included with filtering | ||
| 161 | # $setup->simscan ; # included " | ||
| 162 | $setup->maillogs ; | ||
| 163 | $setup->supervise ; | ||
| 164 | $setup->test->run_all ; | ||
| 165 | } | ||
| 166 | |||
| 167 | print "\n$0 script execution complete.\n"; | ||
| 168 | |||
| 169 | 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 |