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