summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2018-02-12 16:01:00 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2018-02-12 16:01:00 +0100
commita4cc90817a4613654d0e477749c27b3d3cfcdb84 (patch)
treeba42ad60fda37466dabfc8f312bf9dfeef5a533f
parent0fbbb3374ee2ab2b75b994d1b132e6a4067f0f1a (diff)
downloadarch-mirror-tools-a4cc90817a4613654d0e477749c27b3d3cfcdb84.tar.gz
arch-mirror-tools-a4cc90817a4613654d0e477749c27b3d3cfcdb84.tar.xz
Fetch admin email from API if we have logged in
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
-rwxr-xr-xbin/archweb-login.pl24
-rwxr-xr-xbin/generate-mirror-mail.pl8
-rw-r--r--settings.conf3
3 files changed, 32 insertions, 3 deletions
diff --git a/bin/archweb-login.pl b/bin/archweb-login.pl
new file mode 100755
index 0000000..d66ecff
--- /dev/null
+++ b/bin/archweb-login.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use File::Basename;
+use Config::Tiny;
+use WWW::Mechanize;
+use HTTP::Cookies;
+
+my $Config = Config::Tiny->new();
+$Config = Config::Tiny->read(dirname($0) . "/../settings.conf");
+
+my $cookie_jar = HTTP::Cookies->new(file => dirname($0) . "/../cookie_jar", autosave => 1);
+my $mech = WWW::Mechanize->new(agent => "arch-mirror-tools", cookie_jar => $cookie_jar);
+
+$mech->get("https://www.archlinux.org/login/");
+my $res = $mech->submit_form(
+ form_id => "dev-login-form",
+ fields => {
+ username => $Config->{account}->{username},
+ password => $Config->{account}->{password}
+ }
+);
diff --git a/bin/generate-mirror-mail.pl b/bin/generate-mirror-mail.pl
index 302de25..f6efc44 100755
--- a/bin/generate-mirror-mail.pl
+++ b/bin/generate-mirror-mail.pl
@@ -1,7 +1,9 @@
#!/usr/bin/perl
use warnings;
use strict;
+use File::Basename;
use JSON;
+use HTTP::Cookies;
use WWW::Mechanize;
use Date::Parse;
use Date::Format;
@@ -64,7 +66,8 @@ Florian
},
);
-my $mech = WWW::Mechanize->new(cookie_jar => {});
+my $cookie_jar = HTTP::Cookies->new(file => dirname($0) . "/../cookie_jar", autosave => 1);
+my $mech = WWW::Mechanize->new(cookie_jar => $cookie_jar);
sub send_mail {
my $to = shift;
@@ -136,8 +139,7 @@ while (<STDIN>) {
my @last_sync = keys %{{ map { ${$_}{time} => 1 } @out_of_sync }};
my $sent_mail = 0;
- # TODO: set $to
- my $to = '';
+ my $to = $json->{admin_email};
if (@out_of_sync) {
my %values = (
diff --git a/settings.conf b/settings.conf
new file mode 100644
index 0000000..6367e1f
--- /dev/null
+++ b/settings.conf
@@ -0,0 +1,3 @@
+[account]
+username=foo
+password=bar