|
|
@@ -11,9 +11,6 @@ use FindBin::libs;
|
|
|
|
|
|
use TPSGI;
|
|
|
|
|
|
-use Getopt::Long qw{GetOptionsFromArray};
|
|
|
-use Config::Simple;
|
|
|
-
|
|
|
my %options = main(@ARGV);
|
|
|
|
|
|
=head1 USAGE
|
|
|
@@ -28,6 +25,7 @@ tpsgi obeys a config file, ~/.tpsgi.ini which is in Config::Simple (key=value) f
|
|
|
indices # Dirindex files. In addition to index.html, index.htm, index.cgi
|
|
|
loggers # Logger module(s), separate with comma
|
|
|
auth # Authentication module
|
|
|
+ domain # Domain name of the application, used by things like service files
|
|
|
|
|
|
The idea is that this application is going to be run in a chroot with the user's homedir being the application dir.
|
|
|
|
|
|
@@ -36,35 +34,7 @@ The idea is that this application is going to be run in a chroot with the user's
|
|
|
sub main {
|
|
|
my (@args) = @_;
|
|
|
|
|
|
- my %options = _get_from_config();
|
|
|
- return %options;
|
|
|
-}
|
|
|
-
|
|
|
-sub _get_from_config {
|
|
|
- my %options = (
|
|
|
- verbose => 0,
|
|
|
- custom_log => undef,
|
|
|
- routers => [],
|
|
|
- loggers => [],
|
|
|
- auth => undef,
|
|
|
- );
|
|
|
- my $config_file = "$ENV{HOME}/.tpsgi.ini";
|
|
|
- if (-f $config_file) {
|
|
|
- my $conf = Config::Simple->new($config_file);
|
|
|
- my %config;
|
|
|
- %config = %{$conf->param(-block => 'default')} if $conf;
|
|
|
-
|
|
|
- # Merge the configuration with the options
|
|
|
- foreach my $opt (keys(%options)) {
|
|
|
- if ( ref $options{$opt} eq 'ARRAY' ) {
|
|
|
- next unless exists $config{$opt};
|
|
|
- my @arrayed = ref $config{$opt} eq 'ARRAY' ? @{$config{$opt}} : ($config{$opt});
|
|
|
- push(@{$options{$opt}}, @arrayed);
|
|
|
- next;
|
|
|
- }
|
|
|
- $options{$opt} = $config{$opt} if exists $config{$opt};
|
|
|
- }
|
|
|
- }
|
|
|
+ my %options = TPSGI::get_config();
|
|
|
return %options;
|
|
|
}
|
|
|
|