[slbackup-commit] CVS update: slbackup-php/src functions.php index.php

finnarne-guest at alioth.debian.org finnarne-guest at alioth.debian.org
Fri Apr 13 22:12:22 UTC 2007


  User: finnarne-guest
  Date: 07/04/13 22:12:22

  Modified:    src      functions.php index.php
  Log:
  v0.0.2 is not released yet
  
  Revision  Changes    Path
  1.3       +3 -2      slbackup-php/src/functions.php
  
  Index: functions.php
  ===================================================================
  RCS file: /cvsroot/slbackup/slbackup-php/src/functions.php,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- functions.php	13 Apr 2007 06:07:38 -0000	1.2
  +++ functions.php	13 Apr 2007 22:12:22 -0000	1.3
  @@ -19,8 +19,8 @@
   */
   
   function loadConfig () {
  -    global $backuphost, $backupuser, $backupconf, $backupcron, $ssh_options,
  -           $smarty_templ, $smarty_compile ; 
  +    global $backuphost, $backupuser, $backupconf, $backupcron,
  +           $ssh_options, $logfile, $smarty_templ, $smarty_compile ; 
   
       @include_once ("/etc/slbackup/config.php") ; 
   
  @@ -32,6 +32,7 @@
       if (empty ($backupconf)) $backupconf="/etc/slbackup/slbackup.conf" ; 
       if (empty ($backupcron)) $backupcron="/etc/cron.d/slbackup" ; 
       if (empty ($ssh_options)) $ssh_options="-o StrictHostKeyChecking=no" ; 
  +    if (empty ($logfile)) $logfile="/var/log/slbackup/slbackup.log" ; 
   
   
       if (empty ($smarty_templ)) {
  
  
  
  1.11      +39 -0     slbackup-php/src/index.php
  
  Index: index.php
  ===================================================================
  RCS file: /cvsroot/slbackup/slbackup-php/src/index.php,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- index.php	13 Apr 2007 20:46:07 -0000	1.10
  +++ index.php	13 Apr 2007 22:12:22 -0000	1.11
  @@ -176,6 +176,42 @@
       return $config ; 
   }
   
  +function readlog ($passwd) {
  +global $backuphost, $backupuser, $logfile, $ssh_options, $ssh_askpass ;
  +
  +    $log = array () ; 
  +    $cmd = sprintf ("ssh %s %s@%s cat %s", 
  +   		     $ssh_options, $backupuser, 
  +		     $backuphost, $logfile) ; 
  +
  +    $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') ; 
  +    $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)) {
  +	    if (strpos ($line, "Starting slbackup") !== false)
  +		$log["start"] = $line ; 
  +	    if (strpos ($line, "Finished slbackup") !== false)
  +		$log["end"] = $line ; 
  +	    if (strpos ($line, "Starting backup of client") !== false)
  +		$log["clientstart"] = $line ; 
  +	    if (strpos ($line, "Failed backing up client") !== false)
  +		$log["clientfailed"] = $line ; 
  +	    if (strpos ($line, "Successfully finished backing up client") !== false)
  +		$log["clientok"] = $line ; 
  +        }
  +	fclose ($pipes[1]) ; 
  +	proc_close ($proc) ; 
  +    }
  +    return $log ; 
  +}
  +
   require_once ('functions.php') ; 
   loadConfig () ;
   require('/usr/share/php/smarty/libs/Smarty.class.php') ; 
  @@ -260,6 +296,9 @@
       sscanf ($array[1], "%d", $config["hours"]) ; 
   }
   switch ($submit) {
  +    case "status":
  +        debug (readlog ($passwd)) ; 
  +        break ; 
       case "scheduler": 
           $newsched = "" ; 
           foreach ($scheduler as $line) {
  
  
  



More information about the slbackup-commit mailing list