<?php /** * * CRONJOB * cache all git branches * */ // http://iml:deployment@ci.iml.unibe.ch/deployment/?prj=ci&action=deploy&par3=preview&confirm=1 $iStart=date('U'); $sDocroot = (dirname(__dir__)) . "/public_html"; $processUser = posix_getpwuid(posix_geteuid()); if ($processUser['name']=="root"){ die("Do not start the script as user root\n"); }; echo "\n<h1>===== IMLDEPLOYMENT - cache git branches :: ".(date("Y-m-d H:i:s"))." =====</h1>\n\n"; $sLockfile="/tmp/cache-gitbranches.lock"; if (file_exists($sLockfile)){ $iAge=date('U')-filemtime($sLockfile); $iMagAge=60*60 * 3; if ($iAge < 60*60 * 3){ die("ABORT: lock file exists: $sLockfile (age: $iAge sec ... needs to wait up to $iMagAge sec or the running script is finished)\n"); } echo "INFO: ignoring existing lock file $sLockfile (age: $iAge sec is older $iMagAge sec)\n"; } require_once("$sDocroot/deployment/classes/logger.class.php"); global $oCLog; $oCLog = new logger(); require_once("$sDocroot/../config/inc_projects_config.php"); require_once("$sDocroot/deployment/inc_functions.php"); require_once("$sDocroot/deployment/classes/project.class.php"); $oPrj1 = new project(); echo "creating lock file $sLockfile\n"; file_put_contents($sLockfile, "started ".date("Y-m-d H:i:s")); foreach ($oPrj1->getProjects() as $sPrj) { $oPrj = new project($sPrj); echo "----- $sPrj:\n"; foreach($oPrj->getRemoteBranches() as $aBranch){ echo $aBranch['revision']." ".$aBranch['label'] . "<br>\n"; } echo "<br>\n"; } echo "\n\n---------- done\n"; echo "removing lock file $sLockfile\n"; unlink($sLockfile); echo "Script needed ".(date('U')-$iStart) . " s\n\n"; // echo $oCLog->renderCli();