Tuesday, August 24, 2010

PHP script for SVN auto exporting new commited files

 /var/www/svn.status');
 $x = file('/var/www/svn.status', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
 if (count($x) > 1) {
  for ($i = 0; $i < count($x) - 1; $i++) {
   $changed = explode('/var/www/test/', $x[$i]);
   system('rm -f /var/www/test/'.$changed[1]);
   system('cp -f /var/www/test/'.$changed[1].' /var/www/html/'.$changed[1]);
  }
 } else {
  system('cat /var/www/svn.status > /var/www/html/rev.txt');
  system('chown -R apache.apache /var/www/html/'); //option, not require always.
 }
 
 sleep(5);
}

?>

Legend:
/var/www/test/ : the svn folder.
/var/www/html/ : the pubic web folder.
apache.apache : the user and group of apache.

No comments:

Post a Comment