From: Todd Lyons Date: Mon, 5 May 2014 16:10:17 +0000 (-0700) Subject: Scripts to show secret and delete a host X-Git-Url: https://git.exim.org/buildfarm-server.git/commitdiff_plain/a3ab3a38e416ffb9d0e9d2069bba209d283a07cb Scripts to show secret and delete a host --- diff --git a/scripts/delete_host.pl b/scripts/delete_host.pl new file mode 100755 index 0000000..1c1baad --- /dev/null +++ b/scripts/delete_host.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use DBI; +use Data::Dumper; + +die "Must pass one and only one sysname to delete\n" + unless scalar @ARGV == 1; + +use vars qw($dbhost $dbname $dbuser $dbpass $dbport +); +require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +die "no dbname" unless $dbname; +die "no dbuser" unless $dbuser; + +my $dsn="dbi:Pg:dbname=$dbname"; +$dsn .= ";host=$dbhost" if $dbhost; +$dsn .= ";port=$dbport" if $dbport; + +my $db = DBI->connect($dsn,$dbuser,$dbpass); + +die $DBI::errstr unless $db; + +my @tables = qw/alerts buildsystems build_status build_status_log + build_status_recent_500 dashboard_mat latest_snapshot + nrecent_failures personality/; +my $sth; +for my $loop (0 .. (scalar @tables - 1) ) { + my $field = ($tables[$loop] eq 'personality') ? 'name' : + ($tables[$loop] eq 'buildsystems') ? 'name': + 'sysname'; + printf "Deleting from %s with field %s\n", $tables[$loop], $field; + $sth = $db->prepare(" + DELETE FROM $tables[$loop] + WHERE $field = ? + "); + $sth->execute($ARGV[0]); +} +$db->disconnect(); diff --git a/scripts/show_passwords.pl b/scripts/show_passwords.pl new file mode 100755 index 0000000..687896f --- /dev/null +++ b/scripts/show_passwords.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use DBI; +use Data::Dumper; + +use vars qw($dbhost $dbname $dbuser $dbpass $dbport + $user_list_format +); +require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +die "no dbname" unless $dbname; +die "no dbuser" unless $dbuser; + +my $dsn="dbi:Pg:dbname=$dbname"; +$dsn .= ";host=$dbhost" if $dbhost; +$dsn .= ";port=$dbport" if $dbport; + +my $db = DBI->connect($dsn,$dbuser,$dbpass); + +die $DBI::errstr unless $db; + +my $sth = $db->prepare(q[ + SELECT name, secret + FROM buildsystems AS b + ORDER BY name ASC + ]); +$sth->execute(); + +$user_list_format = "%-20s %s\n"; +printf $user_list_format, "SysName", "Secret"; +while (my $row = $sth->fetchrow_hashref) +{ + printf $user_list_format, $row->{name}, $row->{secret}; +} +$db->disconnect();