package BEX::Config;
%machines = (
- 'albireo' => { 'Host' => 'albireo.burrow.ucw.cz' },
+ 'albireo' => { 'Host' => 'albireo.burrow.ucw.cz', 'User' => 'root' },
'localhost' => {},
'home' => ['albireo', 'localhost'],
);
if (!defined $pings{$mach}) {
if ($BEX::Config::ping_hosts) {
update_status($mach, '-', 'PING', undef);
- my $host = BEX::Config::host_name($mach);
+ my $host = BEX::Config::host_name($mach, 0);
`ping -c1 -n $host >/dev/null 2>/dev/null`;
$pings{$mach} = !$?;
} else {
my $jid = $job->id;
update_status($mach, $jid, 'PREP', $queue);
my $lf = $queue->log_file($mach, $jid);
- $ENV{'HOST'} = BEX::Config::host_name($mach);
+ $ENV{'HOST'} = BEX::Config::host_name($mach, 0);
system 'bash', '-o', 'pipefail', '-c', "( $prep ) 2>&1 | tee -a $lf";
delete $ENV{'HOST'};
if ($?) {
sub run_simple_job($$$$) {
my ($job, $queue, $mach, $body) = @_;
- my $host = BEX::Config::host_name($mach);
+ my $host = BEX::Config::host_name($mach, 1);
my $jid = $job->id;
update_status($mach, $jid, 'SEND', undef);
sub run_complex_job($$$$) {
my ($job, $queue, $mach, $body) = @_;
- my $host = BEX::Config::host_name($mach);
+ my $host = BEX::Config::host_name($mach, 1);
my $jid = $job->id;
update_status($mach, $jid, 'SEND', undef);
# How we run ssh (including options)
our $ssh_command = "ssh";
+# Which user we log in as (if any)
+our $ssh_user;
+
# How we run rsync to upload attachments (including options)
our $rsync_command = "rsync -a";
return sort grep { $set{$_} } keys %set;
}
-sub host_name($) {
- my ($mach) = @_;
- return $machines{$mach}->{'Host'} // $mach;
+sub host_name($$) {
+ my ($mach, $want_user) = @_;
+ my $host = $machines{$mach}->{'Host'} // $mach;
+ if ($want_user) {
+ my $user = $machines{$mach}->{'User'} // $ssh_user;
+ if (defined $user) {
+ return $user . '@' . $host;
+ }
+ }
+ return $host;
}
require $cf_dir . '/config';