Large amounts of code cleanup.
This commit is contained in:
1 parent
f2deae219d
commit
3e1e2e98be
18 files changed
+286
-243
No files matched your search
@@ -218,13 +218,13 @@ our ($APID, %TIMERS);
|
||||
Lib::Auto::checkver();
|
||||
|
||||
# Include IPv6 if Auto was built for it.
|
||||
if ($ENFEAT =~ /ipv6/) { require IO::Socket::INET6; }
|
||||
if ($ENFEAT =~ /ipv6/) { require IO::Socket::INET6 }
|
||||
# Include SSL if Auto was built for it.
|
||||
if ($ENFEAT =~ /ssl/) { require IO::Socket::SSL; }
|
||||
if ($ENFEAT =~ /ssl/) { require IO::Socket::SSL }
|
||||
|
||||
# Parse configuration file.
|
||||
my $configfile = 'auto.conf';
|
||||
if ($USECONFIG) { $configfile = $USECONFIG; }
|
||||
if ($USECONFIG) { $configfile = $USECONFIG }
|
||||
say "* Parsing configuration file $configfile...";
|
||||
our $CONF = Parser::Config->new($configfile) or err(1, 'Failed to parse configuration file!', 1);
|
||||
our %SETTINGS = $CONF->parse or err(1, 'Failed to parse configuration file!', 1);
|
||||
@@ -269,8 +269,8 @@ our $DB;
|
||||
given (lc((conf_get('database:format'))[0][0])) {
|
||||
when ('sqlite') {
|
||||
# SQLite.
|
||||
if ($ENFEAT !~ /sqlite/) { err(2, 'Auto not built with SQLite support. Aborting.', 1); }
|
||||
if (!conf_get('database:filename')) { err(2, 'Missing required configuration value database:filename. Aborting.', 1); }
|
||||
if ($ENFEAT !~ /sqlite/) { err(2, 'Auto not built with SQLite support. Aborting.', 1) }
|
||||
if (!conf_get('database:filename')) { err(2, 'Missing required configuration value database:filename. Aborting.', 1) }
|
||||
|
||||
# Import DBD::SQLite.
|
||||
require DBD::SQLite;
|
||||
@@ -286,9 +286,9 @@ given (lc((conf_get('database:format'))[0][0])) {
|
||||
}
|
||||
when ('mysql') {
|
||||
# MySQL.
|
||||
if ($ENFEAT !~ /mysql/) { err(2, 'Auto not built with MySQL support. Aborting.', 1); }
|
||||
if ($ENFEAT !~ /mysql/) { err(2, 'Auto not built with MySQL support. Aborting.', 1) }
|
||||
my @reqcval = qw(database:host database:name database:username database:password);
|
||||
foreach (@reqcval) { if (!conf_get($_)) { err(2, "Missing required configuration value $_. Aborting.", 1); } }
|
||||
foreach (@reqcval) { if (!conf_get($_)) { err(2, "Missing required configuration value $_. Aborting.", 1) } }
|
||||
undef @reqcval;
|
||||
|
||||
# Import DBD::mysql.
|
||||
@@ -309,8 +309,8 @@ given (lc((conf_get('database:format'))[0][0])) {
|
||||
# CSV no work. :(
|
||||
#when ('csv') {
|
||||
# # CSV.
|
||||
# if ($ENFEAT !~ /csv/) { err(2, 'Auto not built with CSV support.', 1); }
|
||||
# if (!conf_get('database:dir')) { err(2, 'Missing required configuration value database:dir. Aborting.', 1); }
|
||||
# if ($ENFEAT !~ /csv/) { err(2, 'Auto not built with CSV support.', 1) }
|
||||
# if (!conf_get('database:dir')) { err(2, 'Missing required configuration value database:dir. Aborting.', 1) }
|
||||
#
|
||||
# # Import DBD::CSV.
|
||||
# require DBD::CSV;
|
||||
@@ -320,9 +320,9 @@ given (lc((conf_get('database:format'))[0][0])) {
|
||||
#}
|
||||
when ('pgsql') {
|
||||
# PostgreSQL.
|
||||
if ($ENFEAT !~ /pgsql/) { err(2, 'Auto not built with PostgreSQL support. Aborting.', 1); }
|
||||
if ($ENFEAT !~ /pgsql/) { err(2, 'Auto not built with PostgreSQL support. Aborting.', 1) }
|
||||
my @reqcval = qw(database:name database:host database:username database:password);
|
||||
foreach (@reqcval) { if (!conf_get($_)) { err(2, "Missing required configuration value $_. Aborting.", 1); } }
|
||||
foreach (@reqcval) { if (!conf_get($_)) { err(2, "Missing required configuration value $_. Aborting.", 1) } }
|
||||
undef @reqcval;
|
||||
|
||||
# Import DBD::Pg.
|
||||
@@ -341,7 +341,7 @@ given (lc((conf_get('database:format'))[0][0])) {
|
||||
}
|
||||
}
|
||||
# Unknown database format.
|
||||
default { err(2, 'Unknown database format \''.lc((conf_get('database:format'))[0][0]).'\'. Aborting.', 1); }
|
||||
default { err(2, 'Unknown database format \''.lc((conf_get('database:format'))[0][0]).'\'. Aborting.', 1) }
|
||||
}
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ while (1) {
|
||||
# Figure out what network is sending us data.
|
||||
my $sockid;
|
||||
foreach (keys %SOCKET) {
|
||||
if ($SOCKET{$_} eq $sock) { $sockid = $_; }
|
||||
if ($SOCKET{$_} eq $sock) { $sockid = $_ }
|
||||
}
|
||||
# Read the data.
|
||||
my $idata;
|
||||
|
||||
+48
-5
@@ -8,10 +8,53 @@ use strict;
|
||||
use warnings;
|
||||
use English qw(-no_match_vars);
|
||||
use FindBin qw($Bin);
|
||||
use Cwd;
|
||||
use Pod::Html;
|
||||
use Pod::Man;
|
||||
our $Bin = $Bin;
|
||||
|
||||
my ($UPREFIX, %bin);
|
||||
$bin{cwd} = getcwd;
|
||||
if (!-e "$Bin/../build/syswide") {
|
||||
# Must be a custom PREFIX install.
|
||||
$bin{etc} = "$bin{cwd}/etc";
|
||||
$bin{var} = "$bin{cwd}/var";
|
||||
if (!-e "$Bin/lib/Lib/Auto.pm") {
|
||||
# Must be a system wide install.
|
||||
$bin{lib} = "$Bin/../lib/autobot/3.0.0";
|
||||
$bin{bld} = "$bin{lib}/build";
|
||||
$bin{lng} = "$bin{lib}/lang";
|
||||
$bin{mod} = "$bin{lib}/modules";
|
||||
}
|
||||
else {
|
||||
# Or not.
|
||||
$bin{lib} = "$Bin/../lib";
|
||||
$bin{bld} = "$Bin/../build";
|
||||
$bin{lng} = "$Bin/../lang";
|
||||
$bin{mod} = "$Bin/../modules";
|
||||
}
|
||||
$UPREFIX = 1;
|
||||
}
|
||||
else {
|
||||
# Must be a standard install.
|
||||
$bin{etc} = "$Bin/../etc";
|
||||
$bin{var} = "$Bin/../var";
|
||||
$bin{lib} = "$Bin/../lib";
|
||||
$bin{bld} = "$Bin/../build";
|
||||
$bin{lng} = "$Bin/../lang";
|
||||
$bin{mod} = "$Bin/../modules";
|
||||
$UPREFIX = 0;
|
||||
}
|
||||
|
||||
# Get the name of the network this cert is for.
|
||||
print 'Network Name: ';
|
||||
my $net = <STDIN>;
|
||||
$net =~ s/(\r|\n)//gxsm;
|
||||
say q{};
|
||||
|
||||
# Make sure etc/certs/ exists.
|
||||
if (!-d "$bin{etc}") { mkdir "$bin{etc}", 0755 }
|
||||
|
||||
our $VERSION = 1.00;
|
||||
|
||||
# Get module parameter.
|
||||
@@ -95,17 +138,17 @@ foreach (@pars) {
|
||||
foreach my $cpanmod (@vals) {
|
||||
$res = eval('require '.$cpanmod.'; 1;');
|
||||
say ' '.$cpanmod.': '.(($res) ? 'Found' : 'Not Found');
|
||||
if (!$res) { $die = 1; }
|
||||
if (!$res) { $die = 1 }
|
||||
}
|
||||
print $RS;
|
||||
|
||||
if ($die) { say 'Failed to build '.$module.'.'; exit; }
|
||||
if ($die) { say 'Failed to build '.$module.'.'; exit }
|
||||
}
|
||||
when ('perl') {
|
||||
print 'Checking Perl version..... '.$PERL_VERSION.' - ';
|
||||
if ($] < $val) { $die = 1; }
|
||||
if ($] < $val) { $die = 1 }
|
||||
say (($die) ? 'Not OK' : 'OK');
|
||||
if ($die) { say 'Failed to build '.$module.'.'; exit; }
|
||||
if ($die) { say 'Failed to build '.$module.'.'; exit }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +162,7 @@ close $FMPH;
|
||||
say 'Generating documentation.....';
|
||||
my $podbuf;
|
||||
foreach my $line (@MPBUF) {
|
||||
if (!defined $line) { $line = ' '; }
|
||||
if (!defined $line) { $line = ' ' }
|
||||
$line =~ s/(\r|\n)//g;
|
||||
|
||||
if ($line eq '__END__') {
|
||||
|
||||
+2
-2
@@ -53,8 +53,8 @@ $net =~ s/(\r|\n)//gxsm;
|
||||
say q{};
|
||||
|
||||
# Make sure etc/certs/ exists.
|
||||
if (!-d "$bin{etc}") { mkdir "$bin{etc}", 0755; }
|
||||
if (!-d "$bin{etc}/certs") { mkdir "$bin{etc}/certs", 0755; }
|
||||
if (!-d "$bin{etc}") { mkdir "$bin{etc}", 0755 }
|
||||
if (!-d "$bin{etc}/certs") { mkdir "$bin{etc}/certs", 0755 }
|
||||
|
||||
# Generate key and cert.
|
||||
system "openssl req -nodes -newkey rsa:2048 -keyout $bin{etc}/certs/$net.key -x509 -days 3650 -out $bin{etc}/certs/$net.cert";
|
||||
|
||||
Reference in new issue
Block a user