-
-
Save bsdimp/6656596fe119b6b781298726146f25ef to your computer and use it in GitHub Desktop.
This script posts an OpenBSD dmesg to the NYC*BUG archive at http://www.nycbug.org/index.cgi?action=dmesgd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
use Sys::Hostname; | |
use HTTP::Tiny; | |
# This script posts your OpenBSD dmesg to the NYC*BUG dmesg archive. | |
my $nickname = "$ENV{USER}"; | |
my $email = "$ENV{USER}\@" . hostname(); | |
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 $!; | |
} | |
print "About to post '$description', OK? "; | |
readline STDIN; | |
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://dmesgd.nycbug.org/index.cgi', | |
{ action => 'dmesgd', | |
do => 'addd', | |
nickname => $nickname, | |
email => $email, | |
description => $description, | |
dmesg => $dmesg, | |
} | |
); | |
say $res->{success} | |
? 'Sent dmesg' | |
: "Unable to send dmesg: $res->{status} $res->{reason}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment