1 |
mweinber |
1.1 |
--- smeserver-affa-0.9.0/root/sbin/e-smith/affa.debugsshquiet 2008-01-18 16:57:09.000000000 +0100 |
2 |
|
|
+++ smeserver-affa-0.9.0/root/sbin/e-smith/affa 2008-02-04 08:50:52.000000000 +0100 |
3 |
|
|
@@ -37,7 +37,7 @@ |
4 |
|
|
|
5 |
|
|
$ENV{LANG} = "en_US"; # Filesys::DiskFree only works with english LANG setting |
6 |
|
|
|
7 |
|
|
-my $VERSION='0.9.0'; |
8 |
|
|
+my $VERSION='_VERSIONSTRING_'; |
9 |
|
|
|
10 |
|
|
|
11 |
|
|
# sub prototypes |
12 |
|
|
@@ -122,6 +122,7 @@ |
13 |
|
|
my $rsyncLocal = '/usr/bin/rsync'; |
14 |
|
|
my $rsyncRemote = '/usr/bin/rsync'; |
15 |
|
|
my $rsyncd=0; |
16 |
|
|
+my $sshQuiet="-q"; |
17 |
|
|
my $config = esmith::ConfigDB->open or die "Error: Couldn't open config db."; |
18 |
|
|
my $LocalIP=$config->get("LocalIP")->value; |
19 |
|
|
my $SystemName=$config->get("SystemName")->value; |
20 |
|
|
@@ -645,6 +646,7 @@ |
21 |
|
|
$remoteOS = $opts{'remoteOS'} ? $opts{'remoteOS'} : $job{'remoteOS'}; # option overrides the db value |
22 |
|
|
$ENV{'RSYNC_PASSWORD'}=$job{'rsyncdPassword'}; |
23 |
|
|
$job{'rsyncdPassword'}='<not shown>'; |
24 |
|
|
+ $sshQuiet = $job{'Debug'} eq 'yes' ? '' : '-q'; |
25 |
|
|
|
26 |
|
|
dbg( "Job configuration:" ); |
27 |
|
|
foreach my $k ( sort keys %job ) |
28 |
|
|
@@ -759,7 +761,7 @@ |
29 |
|
|
else |
30 |
|
|
{ |
31 |
|
|
lg( "Checking SSH connection to " . $job{'remoteHostName'} ); |
32 |
|
|
- @cmd=('/usr/bin/ssh', '-p', $job{'sshPort'}, '-o', 'StrictHostKeyChecking=yes', '-o', "HostKeyAlias=$jobname", '-o', "ConnectTimeout=$job{'ConnectionCheckTimeout'}",'-o','PasswordAuthentication=no', '-q', $job{'remoteHostName'},'true'); |
33 |
|
|
+ @cmd=('/usr/bin/ssh', '-p', $job{'sshPort'}, '-o', 'StrictHostKeyChecking=yes', '-o', "HostKeyAlias=$jobname", '-o', "ConnectTimeout=$job{'ConnectionCheckTimeout'}",'-o','PasswordAuthentication=no', $sshQuiet, $job{'remoteHostName'},'true'); |
34 |
|
|
not ExecCmd( @cmd, 0 ) or affaErrorExit( 104, "SSH connection to ". $job{'remoteHostName'}. " failed. Did you send the public key?" ); |
35 |
|
|
} |
36 |
|
|
} |
37 |
|
|
@@ -776,7 +778,7 @@ |
38 |
|
|
else |
39 |
|
|
{ |
40 |
|
|
lg( "signaling pre-backup event on ". $job{'remoteHostName'} ); |
41 |
|
|
- @cmd=('/usr/bin/ssh', '-o', "HostKeyAlias=$jobname", '-p', $job{'sshPort'}, '-q', $job{'remoteHostName'},"/sbin/e-smith/signal-event pre-backup desktop"); |
42 |
|
|
+ @cmd=('/usr/bin/ssh', '-o', "HostKeyAlias=$jobname", '-p', $job{'sshPort'}, $sshQuiet, $job{'remoteHostName'},"/sbin/e-smith/signal-event pre-backup desktop"); |
43 |
|
|
} |
44 |
|
|
not ExecCmd( @cmd, 0 ) or affaErrorExit( 105, "signaling pre-backup event failed." ); |
45 |
|
|
} |
46 |
|
|
@@ -793,7 +795,7 @@ |
47 |
|
|
else |
48 |
|
|
{ |
49 |
|
|
lg( "signaling post-backup event on ". $job{'remoteHostName'} ); |
50 |
|
|
- @cmd=('/usr/bin/ssh', '-o', "HostKeyAlias=$jobname", '-p', $job{'sshPort'}, '-q', $job{'remoteHostName'},"/sbin/e-smith/signal-event post-backup desktop"); |
51 |
|
|
+ @cmd=('/usr/bin/ssh', '-o', "HostKeyAlias=$jobname", '-p', $job{'sshPort'}, $sshQuiet, $job{'remoteHostName'},"/sbin/e-smith/signal-event post-backup desktop"); |
52 |
|
|
} |
53 |
|
|
not ExecCmd( @cmd, 0 ) or lg( "Error: signaling post-backup event failed." ); |
54 |
|
|
} |
55 |
|
|
@@ -817,7 +819,7 @@ |
56 |
|
|
'/usr/bin/ssh', |
57 |
|
|
'-o', "HostKeyAlias=$jobname", |
58 |
|
|
'-p', $job{'sshPort'}, |
59 |
|
|
- '-q', |
60 |
|
|
+ $sshQuiet, |
61 |
|
|
$job{'remoteHostName'}, |
62 |
|
|
"'/sbin/e-smith/affa-rpmlist.sh>$rpmlist'" |
63 |
|
|
); |
64 |
|
|
@@ -1859,7 +1861,7 @@ |
65 |
|
|
print " Done.\n"; |
66 |
|
|
} |
67 |
|
|
print "deleting report database '$jobname' ..."; $|++; |
68 |
|
|
- removeDir("/home/e-smith/db/affa-report/$jobname"); |
69 |
|
|
+ unlink("/home/e-smith/db/affa-report/$jobname"); |
70 |
|
|
print " Done.\n"; |
71 |
|
|
print "deleting affa record '$jobname'..."; $|++; |
72 |
|
|
$affa->get($jobname)->delete; |
73 |
|
|
@@ -2301,7 +2303,7 @@ |
74 |
|
|
{ |
75 |
|
|
$s="Generating DSA keys..."; |
76 |
|
|
print "$s\n"; lg($s); |
77 |
|
|
- @cmd=("/usr/bin/ssh-keygen","-q","-t","dsa","-N ''","-f", "/root/.ssh/id_dsa" ); |
78 |
|
|
+ @cmd=("/usr/bin/ssh-keygen",$sshQuiet,"-t","dsa","-N ''","-f", "/root/.ssh/id_dsa" ); |
79 |
|
|
not ExecCmd( @cmd, 0 ) or affaErrorExit( 119, "Couldn't generate DSA keys" ); |
80 |
|
|
$s="Successfully created DSA key pair."; |
81 |
|
|
print "$s\n"; lg($s); |
82 |
|
|
@@ -2315,12 +2317,12 @@ |
83 |
|
|
my $ah="/home/Administrator"; |
84 |
|
|
my $akp="$ah/.ssh"; |
85 |
|
|
my $ak="$akp/authorized_keys2"; |
86 |
|
|
- $cmd="/bin/cat $kf | /usr/bin/ssh -q $HostKeyAliasOption -o StrictHostKeyChecking=no -p $port Administrator\@$remotehost '/bin/cat - > $ah/id_dsa.pub.$LocalIP.\$\$ && /bin/mkdir -p $akp && /bin/touch $ak && /bin/grep -v \"$pubk\" < $ak >> $ah/id_dsa.pub.$LocalIP.\$\$ ; /bin/mv -f $ah/id_dsa.pub.$LocalIP.\$\$ $ak'"; |
87 |
|
|
+ $cmd="/bin/cat $kf | /usr/bin/ssh $sshQuiet $HostKeyAliasOption -o StrictHostKeyChecking=no -p $port Administrator\@$remotehost '/bin/cat - > $ah/id_dsa.pub.$LocalIP.\$\$ && /bin/mkdir -p $akp && /bin/touch $ak && /bin/grep -v \"$pubk\" < $ak >> $ah/id_dsa.pub.$LocalIP.\$\$ ; /bin/mv -f $ah/id_dsa.pub.$LocalIP.\$\$ $ak'"; |
88 |
|
|
} |
89 |
|
|
else |
90 |
|
|
{ |
91 |
|
|
my $ak="/root/.ssh/authorized_keys2"; |
92 |
|
|
- $cmd="/bin/cat $kf | /usr/bin/ssh -q $HostKeyAliasOption -o StrictHostKeyChecking=no -p $port $remotehost '/bin/cat - > $ak.$LocalIP.\$\$ && /bin/touch $ak && /bin/grep -v \"$pubk\" < $ak >> $ak.$LocalIP.\$\$ ; /bin/mv -f $ak.$LocalIP.\$\$ $ak'"; |
93 |
|
|
+ $cmd="/bin/cat $kf | /usr/bin/ssh $sshQuiet $HostKeyAliasOption -o StrictHostKeyChecking=no -p $port $remotehost '/bin/cat - > $ak.$LocalIP.\$\$ && /bin/touch $ak && /bin/grep -v \"$pubk\" < $ak >> $ak.$LocalIP.\$\$ ; /bin/mv -f $ak.$LocalIP.\$\$ $ak'"; |
94 |
|
|
} |
95 |
|
|
dbg( "Exec Cmd: $cmd" ); |
96 |
|
|
my $err=system($cmd); |
97 |
|
|
@@ -2368,12 +2370,12 @@ |
98 |
|
|
my $ah="/home/Administrator"; |
99 |
|
|
my $akp="$ah/.ssh"; |
100 |
|
|
my $ak="$akp/authorized_keys2"; |
101 |
|
|
- $cmd="/usr/bin/ssh -q $HostKeyAliasOption -o PasswordAuthentication=no -o StrictHostKeyChecking=yes -p $port Administrator\@$remotehost '/bin/mkdir -p $akp && /bin/touch $ak && /bin/grep -v \"$pubk\" < $ak > $ak.$LocalIP.\$\$ ; /bin/mv -f $ak.$LocalIP.\$\$ $ak'"; |
102 |
|
|
+ $cmd="/usr/bin/ssh $sshQuiet $HostKeyAliasOption -o PasswordAuthentication=no -o StrictHostKeyChecking=yes -p $port Administrator\@$remotehost '/bin/mkdir -p $akp && /bin/touch $ak && /bin/grep -v \"$pubk\" < $ak > $ak.$LocalIP.\$\$ ; /bin/mv -f $ak.$LocalIP.\$\$ $ak'"; |
103 |
|
|
} |
104 |
|
|
else |
105 |
|
|
{ |
106 |
|
|
my $ak="/root/.ssh/authorized_keys2"; |
107 |
|
|
- $cmd="/usr/bin/ssh -q $HostKeyAliasOption -o PasswordAuthentication=no -o StrictHostKeyChecking=yes -p $port $remotehost '/bin/touch $ak && /bin/grep -v \"$pubk\" < $ak > $ak.$LocalIP.\$\$ ; /bin/mv -f $ak.$LocalIP.\$\$ $ak'"; |
108 |
|
|
+ $cmd="/usr/bin/ssh $sshQuiet $HostKeyAliasOption -o PasswordAuthentication=no -o StrictHostKeyChecking=yes -p $port $remotehost '/bin/touch $ak && /bin/grep -v \"$pubk\" < $ak > $ak.$LocalIP.\$\$ ; /bin/mv -f $ak.$LocalIP.\$\$ $ak'"; |
109 |
|
|
} |
110 |
|
|
dbg( "Exec Cmd: $cmd" ); |
111 |
|
|
my $err=system($cmd); |
112 |
|
|
@@ -2407,11 +2409,11 @@ |
113 |
|
|
print "SSH connection "; |
114 |
|
|
if( $remoteOS =~ /^cygwin$/i ) |
115 |
|
|
{ |
116 |
|
|
- @cmd=('/usr/bin/ssh', '-p', $job{'sshPort'}, '-o', "HostKeyAlias=$j", '-o', 'StrictHostKeyChecking=yes', '-o', "ConnectTimeout=$job{'ConnectionCheckTimeout'}",'-o','PasswordAuthentication=no', '-q', "Administrator\@$job{'remoteHostName'}",'true'); |
117 |
|
|
+ @cmd=('/usr/bin/ssh', '-p', $job{'sshPort'}, '-o', "HostKeyAlias=$j", '-o', 'StrictHostKeyChecking=yes', '-o', "ConnectTimeout=$job{'ConnectionCheckTimeout'}",'-o','PasswordAuthentication=no', $sshQuiet, "Administrator\@$job{'remoteHostName'}",'true'); |
118 |
|
|
} |
119 |
|
|
else |
120 |
|
|
{ |
121 |
|
|
- @cmd=('/usr/bin/ssh', '-p', $job{'sshPort'}, '-o', "HostKeyAlias=$j", '-o', 'StrictHostKeyChecking=yes', '-o', "ConnectTimeout=$job{'ConnectionCheckTimeout'}",'-o','PasswordAuthentication=no', '-q', $job{'remoteHostName'},'true'); |
122 |
|
|
+ @cmd=('/usr/bin/ssh', '-p', $job{'sshPort'}, '-o', "HostKeyAlias=$j", '-o', 'StrictHostKeyChecking=yes', '-o', "ConnectTimeout=$job{'ConnectionCheckTimeout'}",'-o','PasswordAuthentication=no', $sshQuiet, $job{'remoteHostName'},'true'); |
123 |
|
|
} |
124 |
|
|
print( ((ExecCmd( @cmd, 0 )==0) ? "ok" : "FAILED") . ".\n" ); |
125 |
|
|
} |
126 |
|
|
@@ -2547,7 +2549,7 @@ |
127 |
|
|
close( WD ); |
128 |
|
|
chmod( 0700, "/usr/lib/affa/$WDName" ); |
129 |
|
|
remoteCopy("/usr/lib/affa/$WDName", "/tmp/"); |
130 |
|
|
- my @cmd=('/usr/bin/ssh', '-p', $job{'sshPort'}, '-o', "HostKeyAlias=$jobname", '-q', $job{'remoteHostName'},"/tmp/$WDName"); |
131 |
|
|
+ my @cmd=('/usr/bin/ssh', '-p', $job{'sshPort'}, '-o', "HostKeyAlias=$jobname", $sshQuiet, $job{'remoteHostName'},"/tmp/$WDName"); |
132 |
|
|
not ExecCmd( @cmd, 0 ) or affaErrorExit( 152, "Couldn't run /usr/lib/affa/$WDName on remote host." ); |
133 |
|
|
} |
134 |
|
|
|