diff options
Diffstat (limited to 'setup.pl')
-rwxr-xr-x | setup.pl | 41 |
1 files changed, 34 insertions, 7 deletions
@@ -11,6 +11,19 @@ use File::Copy; use LWP::Simple qw(getstore); use Data::Dumper; +sub prompt($$) { + my ($question, $default) = @_; + $|++; + print "${question} \[${default}\] "; + $_ = <>; + chomp; + if ($_) { + return $_; + } else { + return $default; + } +} + sub printspec($$) { my ($outfile, $key) = @_; my ($n, $e, @stuff) = $key->get_key_parameters; @@ -23,13 +36,24 @@ sub printspec($$) { my $conffile = "www/config.pl"; # Generate configuration file. -our $MULKONF = { }; +$::MULKONF = { }; if (stat($conffile)) { say "Found existing configuration ($conffile)."; do $conffile; } -my $configpath = $MULKONF->{configpath} // "etc/mulkyid"; -my $pemfile = $MULKONF->{pemfile} // "$configpath/rsa2048.pem"; + +my $configpath = $::MULKONF->{configpath} // "/etc/mulkyid"; +$configpath = prompt("Where shall I put configuration files?", $configpath); +my $pemfile = $::MULKONF->{pemfile} // "$configpath/rsa2048.pem"; +$pemfile = prompt("Where shall I put the private key?", $pemfile); +my $aliases_file = $::MULKONF->{aliases_file} // "/etc/aliases"; +$aliases_file = prompt("Where is the aliases file? Type a single dot for none.", $aliases_file); +my $imap_server = $::MULKONF->{imap_server} // "localhost"; +$imap_server = prompt("What is the IMAP server's address?", $imap_server); +my $imap_port = $::MULKONF->{imap_port} // 143; +$imap_port = int(prompt("What is the IMAP server's port?", $imap_port)); + +say "OK."; # Download jQuery. make_path("www/jquery"); @@ -67,16 +91,19 @@ close($specfile); say "Persona spec file saved to: browserid.json"; # Generate configuration file. -$MULKONF = { - configpath => $configpath, - pemfile => $pemfile +$::MULKONF = { + configpath => $configpath, + pemfile => $pemfile, + aliases_file => $aliases_file, + imap_server => $imap_server, + imap_port => $imap_port }; open(my $conffd, ">", $conffile) or die "Cannot open $conffile for writing: $!"; print $conffd <<EOF; #! /usr/bin/env perl # NB. Do not edit this file directly. It is overwritten with each run of setup.pl. -@{[Data::Dumper->Dump([$MULKONF], ["MULKONF"])]} +@{[Data::Dumper->Dump([$::MULKONF], ["::MULKONF"])]} 1; EOF close $conffd; |