#!/usr/local/bin/perl
$mysql_host = "xdaq.jlab.org";
$mysql_user = "gluex";
$mysql_pass = "qcd!confine";
$mysql_db   = "gluex_online";

# Get the current run number from the database
$sql = "SELECT Run_Number FROM RunID ORDER BY Run_Number DESC LIMIT 1";
$runnumber = `echo \"$sql\" | mysql -h $mysql_host -u $mysql_user -p$mysql_pass $mysql_db | grep -v Run_Number`;
chomp $runnumber;

# Update RunID table with the current Begin_Run_Time time.
$sql = "UPDATE RunID SET Begin_Run_Time=Now() WHERE Run_Number=$runnumber";
print `echo \"$sql\" | mysql -h $mysql_host -u $mysql_user -p$mysql_pass $mysql_db`;

# Start up epics2et
`killall -9 epics2et`;
`/usr/local/halld/bin/Linux/epics2et >& /dev/null &`;
