#!/bin/bash
P=`dirname $0`
. ${P}/dutils.sh

# can be run any time after linux dependencies installation
# current directory (pwd) MUST be the target webob's CONF/ directory

echo "Creating jobs tables ..."
sqlite3 WEBOBSJOBS.db <<EOF
BEGIN TRANSACTION;
drop table if exists jobs;
create table jobs (
	JID            text NOT NULL primary key,
	VALIDITY       text not null default 'Y',
	RES            text not null default '',
	XEQ1           text not null default '',
	XEQ2           text not null default '',
	XEQ3           text not null default '',
	RUNINTERVAL    integer NOT NULL,
	MAXSYSLOAD     real NOT NULL default 0.7,
	LOGPATH        text,
	LASTSTRTS      integer not null default 0
	);
drop table if exists runs;
create table runs (
	JID            text NOT NULL,
	KID            integer,
	ORG            text,
	STARTTS        integer NOT NULL default 0,
	ENDTS          integer NOT NULL default 0,
	CMD            text,
	STDPATH        text,
	RC             integer,
	RCMSG          text
	);
COMMIT;
INSERT INTO JOBS VALUES('cleanreq','Y','cleanreq','find \$WEBOBS{ROOT_OUTR} -mtime +30 -exec rm -rf {} \;','','',86400,0.8,'cleanreq',0);
INSERT INTO JOBS VALUES('locastat','Y','locastat','\$WEBOBS{JOB_MCC} locastat','','',3600,0.8,'locastat',0);
INSERT INTO JOBS VALUES('gridmaps','Y','gridmaps','\$WEBOBS{JOB_MCC} gridmaps','','',3600,0.8,'gridmaps',0);
INSERT INTO JOBS VALUES('sefran','N','sefran3','\$WEBOBS{JOB_MCC} sefran3','','',600,0.8,'sefran3',0);
INSERT INTO JOBS VALUES('geoscope','N','geoscope','\$WEBOBS{JOB_MCC} genplot','GEOSCOPE','',600,0.8,'geoscope',0);
INSERT INTO JOBS VALUES('hypoindo','N','hypoindo','\$WEBOBS{JOB_MCC} hypomap','HYPOINDO','"01y"',3600,0.8,'hypoindo',0);
INSERT INTO JOBS VALUES('hypoindo_all','N','hypoindo','\$WEBOBS{JOB_MCC} hypomap','HYPOINDO','"10y,all"',86400,0.8,'hypoindo',0);
INSERT INTO JOBS VALUES('hypowi','N','hypowi','\$WEBOBS{JOB_MCC} hypomap','HYPOWI','',3600,0.8,'hypowi',0);
--INSERT INTO JOBS VALUES('sefran3','N','','\$WEBOBS{JOB_MLXVFB} ','-r "sefran3;exit(0)"','',600,0.7,'sefran3',0);
--INSERT INTO JOBS VALUES('CGPSWI','N','gamit','\$WEBOBS{JOB_MLNODISPLAY} ','-r "gamit(''CGPSWI'');exit(0)"','',86400,0.7,'gamit',0);
--INSERT INTO JOBS VALUES('test-10-300','N','','\$WEBOBS{ROOT_CODE}/cgi-bin/jobtester.pl ','10','',300,0.7,'tester',0);
EOF

echo "Done."
exit 0

