#!/usr/bin/env perl # Host Update # # Douglas Thrift # # $Id$ use strict; use warnings; use File::Basename; use LWP::UserAgent; use MIME::Base64; use POSIX; $ENV{HTTPS_CA_FILE} = "$ENV{HOME}/cacert.pem"; my $url = new URI("https://topsecret.douglasthrift.net/auth/hosts/"); my ($sysname, $nodename, $release, $version, $machine) = uname(); my $agent = new LWP::UserAgent(agent => "HostUpdate/1.1 ($sysname $release $machine) "); { my $user = getpwuid $<; open PASS, "$ENV{HOME}/.HostUpdate.pass" or die "$0: $!\n"; my $pass = ; chomp $pass; close PASS; $pass =~ tr/A-Za-z/N-ZA-Mn-za-m/; $agent->credentials($url->host_port, 'Top Secret', $user, decode_base64($pass)); } $nodename .= ".douglasthrift.net" if ($nodename !~ /\./); my $response = $agent->post($url, [host => $nodename]); $response->is_success or die basename($0) . ': ' . $response->status_line;