version 1.3, 2015/02/23 16:10:07 |
version 1.11, 2018/12/16 23:49:03 |
|
|
use strict; |
use strict; |
use warnings; |
use warnings; |
use feature 'say'; |
use feature 'say'; |
|
use feature 'signatures'; |
|
no warnings 'experimental::signatures'; |
|
|
|
use Sys::Hostname; |
use HTTP::Tiny; |
use HTTP::Tiny; |
|
|
# This script posts your OpenBSD dmesg to the NYC*BUG dmesg archive. |
# 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 = ( |
my @sysctls = ( |
[qw( hw.vendor hw.product hw.version )], |
[qw( hw.vendor hw.product hw.version )], |
[qw( hw.model )], |
[qw( hw.model )], |
|
|
|
|
my $description = "@ARGV"; |
my $description = "@ARGV"; |
|
|
while ( @sysctls and not $description ) { |
unless ($description) { |
my @s = @{ shift @sysctls }; |
while ( @sysctls and not $description ) { |
|
$description = sysctl @{ shift @sysctls }; |
|
} |
|
|
open my $de, '-|', qw( sysctl -n ), @s or die $!; |
if (my $version = sysctl qw( kern.version )) { |
$description = join ' ', split /\s+/s, |
my $machine = sysctl qw( hw.machine ); |
do { local $/ = undef; readline $de }; |
$version =~ s/\)\K.*/ $machine/; |
close $de or die $!; |
$description = "$version on $description"; |
|
} |
} |
} |
|
|
|
print "'$description'\nAbout to post as $email ($nickname), OK? "; |
|
readline STDIN; |
|
|
open my $dm, '<', '/var/run/dmesg.boot' or die $!; |
open my $dm, '<', '/var/run/dmesg.boot' or die $!; |
my $dmesg = do { local $/ = undef; readline $dm }; |
my $dmesg = do { local $/ = undef; readline $dm }; |
close $dm; |
close $dm; |
|
|
$dmesg =~ s/^.*\n(OpenBSD )/$1/s; |
$dmesg =~ s/^.*\n(OpenBSD )/$1/s; |
|
|
my $res = HTTP::Tiny->new->post_form( |
my $res = HTTP::Tiny->new->post_form( |
'http://www.nycbug.org/index.cgi', |
'http://dmesgd.nycbug.org/index.cgi', |
{ action => 'dmesgd', |
{ action => 'dmesgd', |
do => 'addd', |
do => 'addd', |
nickname => 'afresh1', |
nickname => $nickname, |
email => 'andrew+dmesgd@afresh1.com', |
email => $email, |
description => $description, |
description => $description, |
dmesg => $dmesg, |
dmesg => $dmesg, |
} |
} |
|
|
say $res->{success} |
say $res->{success} |
? 'Sent dmesg' |
? 'Sent dmesg' |
: "Unable to send dmesg: $res->{status} $res->{reason}"; |
: "Unable to send dmesg: $res->{status} $res->{reason}"; |
|
|
|
say $res->{content}; |