File: [local] / openbsd / update_openbsd / post_dmesg_to_nycbug (download)
Revision 1.3, Mon Feb 23 16:10:07 2015 UTC (9 years, 4 months ago) by andrew
Branch: MAIN
Changes since 1.2: +13 -10 lines
Accept a description on the command-line
Because some hosts don't have good info in sysctl.
|
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use HTTP::Tiny;
# This script posts your OpenBSD dmesg to the NYC*BUG dmesg archive.
my @sysctls = (
[qw( hw.vendor hw.product hw.version )],
[qw( hw.model )],
);
my $description = "@ARGV";
while ( @sysctls and not $description ) {
my @s = @{ 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 $!;
}
open my $dm, '<', '/var/run/dmesg.boot' or die $!;
my $dmesg = do { local $/ = undef; readline $dm };
close $dm;
# Remove leftover cruft from previous boots
$dmesg =~ s/^.*\n(OpenBSD )/$1/s;
my $res = HTTP::Tiny->new->post_form(
'http://www.nycbug.org/index.cgi',
{ action => 'dmesgd',
do => 'addd',
nickname => 'afresh1',
email => 'andrew+dmesgd@afresh1.com',
description => $description,
dmesg => $dmesg,
}
);
say $res->{success}
? 'Sent dmesg'
: "Unable to send dmesg: $res->{status} $res->{reason}";