[BACK]Return to post_dmesg_to_nycbug CVS log [TXT][DIR] Up to [local] / openbsd / update_openbsd

Annotation of openbsd/update_openbsd/post_dmesg_to_nycbug, Revision 1.9

1.1       andrew      1: #!/usr/bin/perl
                      2: use strict;
                      3: use warnings;
                      4: use feature 'say';
1.6       andrew      5: use feature 'signatures';
                      6: no warnings 'experimental::signatures';
1.1       andrew      7:
1.5       andrew      8: use Sys::Hostname;
1.1       andrew      9: use HTTP::Tiny;
                     10:
                     11: # This script posts your OpenBSD dmesg to the NYC*BUG dmesg archive.
                     12:
1.6       andrew     13: sub sysctl (@s) {
                     14:     open my $de, '-|', qw( sysctl -n ), @s or die $!;
                     15:     my $s = join ' ', split /\s+/s,
                     16:         do { local $/ = undef; readline $de };
                     17:     close $de or die $!;
                     18:     return $s;
                     19: }
                     20:
1.5       andrew     21: my $nickname = "$ENV{USER}";
                     22: my $email    = "$ENV{USER}\@" . hostname();
                     23:
1.3       andrew     24: my @sysctls = (
                     25:     [qw( hw.vendor hw.product hw.version  )],
                     26:     [qw( hw.model )],
                     27: );
1.1       andrew     28:
1.3       andrew     29: my $description = "@ARGV";
                     30:
1.9     ! andrew     31: unless ($description) {
        !            32:     while ( @sysctls and not $description ) {
        !            33:         $description = sysctl @{ shift @sysctls };
        !            34:     }
1.3       andrew     35:
1.9     ! andrew     36:     if (my $version = sysctl qw( kern.version )) {
        !            37:         $version =~ s/\)\K.*//;
        !            38:         $description = "$version on $description";
        !            39:     }
1.2       andrew     40: }
                     41:
1.9     ! andrew     42: print "'$description'\nAbout to post, OK? ";
1.4       andrew     43: readline STDIN;
                     44:
1.1       andrew     45: open my $dm, '<', '/var/run/dmesg.boot' or die $!;
                     46: my $dmesg = do { local $/ = undef; readline $dm };
                     47: close $dm;
                     48:
                     49: # Remove leftover cruft from previous boots
                     50: $dmesg =~ s/^.*\n(OpenBSD )/$1/s;
                     51:
                     52: my $res = HTTP::Tiny->new->post_form(
1.7       andrew     53:     'http://dmesgd.nycbug.org/index.cgi',
1.1       andrew     54:     {   action      => 'dmesgd',
                     55:         do          => 'addd',
1.5       andrew     56:         nickname    => $nickname,
                     57:         email       => $email,
1.1       andrew     58:         description => $description,
                     59:         dmesg       => $dmesg,
                     60:     }
                     61: );
                     62:
                     63: say $res->{success}
                     64:     ? 'Sent dmesg'
                     65:     : "Unable to send dmesg: $res->{status} $res->{reason}";
1.8       andrew     66:
                     67: say $res->{content};

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>