=================================================================== RCS file: /cvs/openbsd/update_openbsd/post_dmesg_to_nycbug,v retrieving revision 1.3 retrieving revision 1.10 diff -u -r1.3 -r1.10 --- openbsd/update_openbsd/post_dmesg_to_nycbug 2015/02/23 16:10:07 1.3 +++ openbsd/update_openbsd/post_dmesg_to_nycbug 2017/10/01 03:45:24 1.10 @@ -2,11 +2,25 @@ use strict; use warnings; use feature 'say'; +use feature 'signatures'; +no warnings 'experimental::signatures'; +use Sys::Hostname; use HTTP::Tiny; # This script posts your OpenBSD dmesg to the NYC*BUG dmesg archive. +sub sysctl (@s) { + open my $de, '-|', qw( sysctl -n ), @s or die $!; + my $s = join ' ', split /\s+/s, + do { local $/ = undef; readline $de }; + close $de or die $!; + return $s; +} + +my $nickname = "$ENV{USER}"; +my $email = "$ENV{USER}\@" . hostname(); + my @sysctls = ( [qw( hw.vendor hw.product hw.version )], [qw( hw.model )], @@ -14,15 +28,21 @@ my $description = "@ARGV"; -while ( @sysctls and not $description ) { - my @s = @{ shift @sysctls }; +unless ($description) { + while ( @sysctls and not $description ) { + $description = sysctl @{ shift @sysctls }; + } - open my $de, '-|', qw( sysctl -n ), @s or die $!; - $description = join ' ', split /\s+/s, - do { local $/ = undef; readline $de }; - close $de or die $!; + if (my $version = sysctl qw( kern.version )) { + my $machine = sysctl qw( hw.machine ); + $version =~ s/\)\K.*/ $machine/; + $description = "$version on $description"; + } } +print "'$description'\nAbout to post, OK? "; +readline STDIN; + open my $dm, '<', '/var/run/dmesg.boot' or die $!; my $dmesg = do { local $/ = undef; readline $dm }; close $dm; @@ -31,11 +51,11 @@ $dmesg =~ s/^.*\n(OpenBSD )/$1/s; my $res = HTTP::Tiny->new->post_form( - 'http://www.nycbug.org/index.cgi', + 'http://dmesgd.nycbug.org/index.cgi', { action => 'dmesgd', do => 'addd', - nickname => 'afresh1', - email => 'andrew+dmesgd@afresh1.com', + nickname => $nickname, + email => $email, description => $description, dmesg => $dmesg, } @@ -44,3 +64,5 @@ say $res->{success} ? 'Sent dmesg' : "Unable to send dmesg: $res->{status} $res->{reason}"; + +say $res->{content};