Skip to content

Commit

Permalink
Merge branch 'cgi'
Browse files Browse the repository at this point in the history
* cgi:
  web/Makefile: Generate cgi script replacing make variables
  Makefile: Add generic sed rules to generate scripts and manpages
  web/Makefile: Install cgi to CGIDIR (defaults to LIBEXECDIR/mxq/cgi)
  web: Show date_end instead of mtime in finished groups view
  web: Remove columns running and inq in finished groups view
  • Loading branch information
mariux committed Aug 11, 2015
2 parents bc2ceb4 + 334821a commit 637db83
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ test_mx_util
test_mx_log
test_mx_mysql

/web/pages/mxq/mxq

*~

gmon.out
Expand Down
33 changes: 32 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ ifeq ($(notdir ${LIBEXECDIR}),mxq)
override LIBEXECDIR := $(patsubst %/,%,$(dir ${LIBEXECDIR}))
endif

CGIDIR = ${LIBEXECDIR}/mxq/cgi

##############################################################################

MXQ_MYSQL_DEFAULT_FILE = ${SYSCONFDIR}/mxq/mysql.cnf
Expand Down Expand Up @@ -101,6 +103,22 @@ quiet-install = $(call quiet-command,install -m ${1} ${2} ${3},"INSTALL ${3} [mo
quiet-installdir = $(call quiet-command,install -m ${1} -d ${2}," MKDIR ${2} [mode=${1}]")
quiet-installforuser = $(call quiet-command,install -m ${1} -o ${2} -g ${3} ${4} ${5},"INSTALL ${5} (user=${2} group=${3}) [mode=${1}]")

########################################################################

sed-rules = -e 's,@PREFIX@,${PREFIX},g' \
-e 's,@EPREFIX@,${EPREFIX},g' \
-e 's,@BINDIR@,${BINDIR},g' \
-e 's,@SBINDIR@,${SBINDIR},g' \
-e 's,@LIBDIR@,${LIBDIR},g' \
-e 's,@SYSCONFDIR@,${SYSCONFDIR},g' \
-e 's,@DEFCONFDIR@,${DEFCONFDIR},g' \
-e 's,@LIBEXECDIR@,${LIBEXECDIR},g' \
-e 's,@BEE_VERSION@,${BEE_VERSION},g' \
-e 's,@DATADIR@,${DATADIR},g' \
-e 's,@MXQ_VERSION@,${MXQ_VERSION},g' \
-e 's,@MXQ_MYSQL_DEFAULT_FILE@,${MXQ_MYSQL_DEFAULT_FILE},g' \


########################################################################

%.o: %.c Makefile
Expand All @@ -111,6 +129,9 @@ quiet-installforuser = $(call quiet-command,install -m ${1} -o ${2} -g ${3} ${4}
%: %.o
$(call quiet-command,${CC} -o $@ $^ $(LDFLAGS) $(LDLIBS), " LINK $@")

%: %.in Makefile
$(call quiet-command,sed ${sed-rules} $< >$@, " GEN $@")

########################################################################

.SECONDARY:
Expand All @@ -121,7 +142,7 @@ manpages/%: manpages/%.xml
$(call quiet-command,xmlto --stringparam man.output.quietly=1 man $^ -o manpages, " XMLTO $@")

%: manpages/% Makefile
$(call quiet-command,sed -e "s/@MXQ_VERSION@/${MXQ_VERSION}/" $< >$@, " GEN $@")
$(call quiet-command,sed ${sed-rules} $< >$@, " GEN $@")

########################################################################

Expand Down Expand Up @@ -179,6 +200,7 @@ install::
$(call quiet-installdir,0755,${DESTDIR}${SBINDIR})
$(call quiet-installdir,0755,${DESTDIR}${SYSCONFDIR}/mxq)
$(call quiet-installdir,0755,${DESTDIR}${MAN1DIR})
$(call quiet-installdir,0755,${DESTDIR}${CGIDIR})

########################################################################

Expand Down Expand Up @@ -419,6 +441,15 @@ clean: CLEAN += mxqsub.1

########################################################################

build: web/pages/mxq/mxq

clean: CLEAN += web/pages/mxq/mxq

install:: web/pages/mxq/mxq
$(call quiet-install,0755,$^,${DESTDIR}${CGIDIR}/mxq)

########################################################################

test_mx_util.o: $(mx_util.h)
clean: CLEAN += test_mx_util.o

Expand Down
28 changes: 27 additions & 1 deletion web/pages/mxq/mxq → web/pages/mxq/mxq.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ EOF

sub db_init {

$dbh= DBI->connect('DBI:mysql:mysql_read_default_file=/etc/mxq/mysql.cnf',undef,undef, { RaiseError => 1, AutoCommit => 1 });
$dbh= DBI->connect('DBI:mysql:mysql_read_default_file=@MXQ_MYSQL_DEFAULT_FILE@',undef,undef, { RaiseError => 1, AutoCommit => 1 });
# mxq_group.h
register_group_status(
OK => 0,
Expand Down Expand Up @@ -445,6 +445,32 @@ sub group_table {
$sth->execute(@bind_args);
$out.=group_table_rows($sth,\@head);

@cols=qw(
group_id
group_name
user_name
group_date_emd
group_status
group_jobs
group_jobs_finished
group_jobs_failed
group_jobs_cancelled
group_jobs_unknown
);

@head=qw(
group_id
group_name
user_name
date_end
group_status
jobs
finished
failed
cancelled
unknown
);

$out .= '<h2>Finished Groups</h2>';

my $sth=$dbh->prepare('SELECT '.join(',',@cols).' FROM mxq_group WHERE '.$sql_clause.' AND (group_jobs_running=0 AND group_jobs_inq=0) ORDER BY group_id DESC');
Expand Down

0 comments on commit 637db83

Please sign in to comment.