[slbackup-commit] CVS update: slbackup-php/src index.php
finnarne-guest at alioth.debian.org
finnarne-guest at alioth.debian.org
Wed Apr 18 05:15:18 UTC 2007
User: finnarne-guest
Date: 07/04/18 05:15:18
Modified: src index.php
Log:
Report if keys are working or if rdiff-backup versions differ
Revision Changes Path
1.27 +53 -0 slbackup-php/src/index.php
Index: index.php
===================================================================
RCS file: /cvsroot/slbackup/slbackup-php/src/index.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- index.php 17 Apr 2007 09:24:37 -0000 1.26
+++ index.php 18 Apr 2007 05:15:18 -0000 1.27
@@ -19,6 +19,55 @@
*/
+function checkkeysandversions ($passwd, $config) {
+global $backuphost, $backupuser, $ssh_options, $ssh_askpass ;
+
+ $out = array () ;
+ $desc[0] = array ("pipe", "r") ;
+ $desc[1] = array ("pipe", "w") ;
+ $desc[2] = array ("file", "/tmp/error.log", "a") ;
+
+ $env = array ('SSH_ASKPASS' => $ssh_askpass,
+ 'DISPLAY' => ':nowhere') ;
+
+ $cmd = sprintf ("ssh %s %s@%s 'rdiff-backup --version'",
+ $ssh_options, $backupuser,
+ $backuphost) ;
+
+ $proc = proc_open ($cmd, $desc, $pipes, '/tmp', $env) ;
+ if (is_resource ($proc)) {
+ fprintf ($pipes[0], "%s\n", $passwd) ;
+ fclose ($pipes[0]) ;
+ while ($line = fgets ($pipes[1], 1024)) {
+ $out["version"] = trim($line) ;
+ }
+ fclose ($pipes[1]) ;
+ proc_close ($proc) ;
+ }
+ foreach ($config["clients"] as $key => $value) {
+ if ($key["type"] <> "local") {
+ $out["clients"][$key]["ssh"] = "failed" ;
+ $cmd = sprintf ("ssh %s %s@%s 'ssh %s echo ssh ok \; rdiff-backup --version'",
+ $ssh_options, $backupuser,
+ $backuphost, $value["address"]) ;
+
+ $proc = proc_open ($cmd, $desc, $pipes, '/tmp', $env) ;
+ if (is_resource ($proc)) {
+ fprintf ($pipes[0], "%s\n", $passwd) ;
+ fclose ($pipes[0]) ;
+ while ($line = fgets ($pipes[1], 1024)) {
+ list ($test, $result) = explode (" ", trim($line)) ;
+ $out["clients"][$key][$test] = $result ;
+ }
+ fclose ($pipes[1]) ;
+ proc_close ($proc) ;
+ }
+ }
+
+ }
+ return ($out) ;
+}
+
function removesnapshots ($passwd, $clientdir, $snapshot) {
global $backuphost, $backupuser, $ssh_options, $ssh_askpass ;
@@ -599,12 +648,16 @@
$smarty->assign ('snapshots', listsnapshots ($passwd, sprintf ("%s/%s", $config["server_destdir"], $client))) ;
}
break ;
+ case "config":
+ break ;
default:
$log = array ('start' => '', 'end' => '') ;
foreach ($config["clients"] as $key => $value)
$log["clients"][$key] =
array ('start' => '', 'failed' => '', 'ok' => '') ;
$log = readlog ($passwd, $log) ;
+ $smarty->assign ('checkkeysandversions',
+ checkkeysandversions ($passwd, $config)) ;
break ;
}
More information about the slbackup-commit
mailing list