Changeset 8929

Show
Ignore:
Timestamp:
02/25/10 11:36:27 (2 years ago)
Author:
mbrevda
Message:

(should) close #4081; run proper cron function on install

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.7/backup/install.php

    r8891 r8929  
    187187} 
    188188 
    189 require_once dirname(__FILE__)."/functions.inc.php"; 
    190 backup_retrieve_backup_cron(); 
    191  
     189backup_install_retrieve_backup_cron(); 
     190 
     191function backup_install_retrieve_backup_cron(){ 
     192  global $amp_conf,$db; 
     193 
     194  $sql = "SELECT command, id from backup WHERE method NOT LIKE 'now%'"; 
     195  $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     196 
     197  if(empty($results)){ 
     198    // grab any other cronjobs that are running as asterisk and NOT associated with backups 
     199    // and issue the schedule to the cron scheduler 
     200    exec("/usr/bin/crontab -l|grep -v '^# DO NOT'|grep -v ^'# ('|grep -v ampbackup.pl|grep -v ampbackup.php",$cron_out,$ret1); 
     201    $cron_out_string = implode("\n",$cron_out); 
     202    exec("/bin/echo '$cron_out_string' | /usr/bin/crontab -",$out_arr,$ret2); 
     203    return ($ret1 == 0 && $ret2 == 0); 
     204  } 
     205 
     206  $backup_string = ""; 
     207  foreach($results as $result){$backup_string.=$result['command'].' '.$result['id']."\n";} 
     208 
     209  // grab any other cronjobs that are running as asterisk and NOT associated with backups, 
     210  // combine with above and re-issue the schedule to the cron scheduler 
     211  exec("/usr/bin/crontab -l|grep -v '^# DO NOT'|grep -v ^'# ('|grep -v ampbackup.pl|grep -v ampbackup.php",$cron_out,$ret1); 
     212  $cron_out_string = implode("\n",$cron_out); 
     213  $backup_string .= $cron_out_string; 
     214 
     215  exec("/bin/echo '$backup_string' | /usr/bin/crontab -",$out_arr,$ret2); 
     216 
     217  return ($ret1 == 0 && $ret2 == 0); 
     218
    192219?>