9 die "Must pass current sysname and new sysname\n" unless scalar @ARGV == 2;
11 use vars qw($dbhost $dbname $dbuser $dbpass $dbport
13 $default_host $mail_from
16 use FindBin qw($RealBin);
17 require "$RealBin/../BuildFarmWeb.pl";
19 die "no dbname" unless $dbname;
20 die "no dbuser" unless $dbuser;
22 my $dsn="dbi:Pg:dbname=$dbname";
23 $dsn .= ";host=$dbhost" if $dbhost;
24 $dsn .= ";port=$dbport" if $dbport;
26 my $db = DBI->connect($dsn,$dbuser,$dbpass);
28 die $DBI::errstr unless $db;
30 $db->do('SELECT approve(?, ?)', undef, @ARGV);
32 my $sth = $db->prepare(q[
33 SELECT name, status, operating_system, os_version, sys_owner, owner_email,
34 secret, compiler, compiler_version, architecture
35 FROM buildsystems AS b
40 sub send_welcome_email
42 my $row = shift() or return;
43 my $msg = new Mail::Send;
44 my $me = `id -un`; chomp($me);
45 my $host = `hostname`; chomp($host);
46 $host = $default_host unless ($host =~ m/[.]/ || !defined($default_host));
47 my $from_addr = $mail_from ?
48 "Exim BuildFarm <$mail_from>" :
49 "Exim BuildFarm <$me\@$host>" ;
50 $from_addr =~ tr /\r\n//d;
51 $msg->set('From',$from_addr);
52 $msg->to($row->{owner_email});
53 $msg->subject('Exim BuildFarm Application Approved');
55 print $fh "\n\nCongratulations $row->{sys_owner},\n",
56 "Your application for the Exim BuildFarm has been accepted.\n\n",
57 "Please set the following in your build-farm.conf:\n",
58 "Animal: $row->{name}\n",
59 "Secret: $row->{secret}\n\n",
60 "BuildFarm machine details:\n",
61 "Distro : $row->{operating_system}\n",
62 "+Version: $row->{os_version}\n",
63 "Arch : $row->{architecture}\n",
64 "Compiler: $row->{compiler}\n",
65 "+Version: $row->{compiler_version}\n\n",
66 "If you update your system, either the Distro or compiler version\n",
67 "you can use the update_personality.pl script to update the\n",
68 "version stored in the BuildFarm database.\n\n",
69 "-- The Exim BuildFarm Maintainers";
73 printf $user_list_format,
74 "SysName", "Status", "Owner", "Email", "Distro", "Version";
75 while (my $row = $sth->fetchrow_hashref)
77 printf $user_list_format,
78 $row->{name}, $row->{status}, $row->{sys_owner},
79 $row->{owner_email}, $row->{operating_system},
81 if ($row->{name} eq $ARGV[1])
83 &send_welcome_email($row);