aboutsummaryrefslogtreecommitdiff
path: root/setup.pl
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-10-03 18:59:16 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-10-03 18:59:16 +0200
commit08b9ee11fe5e5a54af866a061c9e8d7782cac3c7 (patch)
tree5715109aa14dee38c368118abec0495d8d3e91fd /setup.pl
parent72abba77573c3583dc373526f6ce86b895eacc6d (diff)
Make /etc/aliases optional. Add configurability through setup.pl.
Diffstat (limited to 'setup.pl')
-rwxr-xr-xsetup.pl41
1 files changed, 34 insertions, 7 deletions
diff --git a/setup.pl b/setup.pl
index 1b25259..b4fb9e4 100755
--- a/setup.pl
+++ b/setup.pl
@@ -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;