Index: /branches/1.2/Makefile
===================================================================
--- /branches/1.2/Makefile	(revision 954)
+++ /branches/1.2/Makefile	(revision 955)
@@ -27,5 +27,5 @@
 FAKEROOT = fakeroot
 
-VERSION = 1.1.1
+VERSION = 1.2.0
 RELEASE = 1
 
@@ -55,4 +55,5 @@
 	@mv -f ${TMPDIR}/ganglia_jobmonarch-${VERSION}.tar.gz .. 2> /dev/null || true
 	@echo "Wrote: ../ganglia_jobmonarch-${VERSION}.tar.gz"
+	@rm -rf $(TMPDIR)/.monarch_buildroot
 
 tarball-bzip:	$(TMPDIR)/.monarch_buildroot ${REQUIRED}
@@ -60,8 +61,9 @@
 	@mv -f ${TMPDIR}/ganglia_jobmonarch-${VERSION}.tar.bz2 .. 2> /dev/null || true
 	@echo "Wrote: ../ganglia_jobmonarch-${VERSION}.tar.bz2"
+	@rm -rf $(TMPDIR)/.monarch_buildroot
 
 rpm: tarball-bzip
 	# Binary package will reflect most distro where ganglia default location is /usr/share/ganglia
-	@LC_ALL=C rpmbuild -tb --define '%custom_web_prefixdir /usr/share/ganglia' ../ganglia_jobmonarch-${VERSION}.tar.bz2|grep "Wrote: "
+	@LC_ALL=C rpmbuild -tb --with web_prefixdir=/usr/share/ganglia-webfrontend ../ganglia_jobmonarch-${VERSION}.tar.bz2|grep "Wrote: "
 
 srpm: tarball-bzip
@@ -112,14 +114,22 @@
 	@if test -r /etc/redhat-release; then \
 		echo; \
-		echo "Red Hat detected: installing RPM service files in /etc"; \
-		sed -i -e 's|DAEMON=.*|DAEMON=$(JOBMOND)|g' pkg/rpm/init.d/jobmond; \
-		sed -i -e 's|DAEMON=.*|DAEMON=$(JOBARCHIVED)|g' pkg/rpm/init.d/jobarchived; \
-		install -m 0755 -d $(DESTDIR)/etc/rc.d/init.d; \
-		install -m 0755 pkg/rpm/init.d/jobmond $(DESTDIR)/etc/rc.d/init.d/; \
-		install -m 0755 pkg/rpm/init.d/jobarchived $(DESTDIR)/etc/rc.d/init.d/; \
+		echo "Red Hat detected: installing RPM service files."; \
+		if test -d /usr/lib/systemd/system; then \
+			echo "Using systemd service files."; \
+			install -m 0755 -d $(DESTDIR)/usr/lib/systemd/system; \
+			install -m 0755 pkg/rpm/systemd/jobmond.service $(DESTDIR)/usr/lib/systemd/system/; \
+			install -m 0755 pkg/rpm/systemd/jobarchived.service $(DESTDIR)/usr/lib/systemd/system/; \
+		else \
+			echo "Using initscripts service files."; \
+			sed -i -e 's|DAEMON=.*|DAEMON=$(JOBMOND)|g' pkg/rpm/init.d/jobmond; \
+			sed -i -e 's|DAEMON=.*|DAEMON=$(JOBARCHIVED)|g' pkg/rpm/init.d/jobarchived; \
+			install -m 0755 -d $(DESTDIR)/etc/rc.d/init.d; \
+			install -m 0755 pkg/rpm/init.d/jobmond $(DESTDIR)/etc/rc.d/init.d/; \
+			install -m 0755 pkg/rpm/init.d/jobarchived $(DESTDIR)/etc/rc.d/init.d/; \
+		fi; \
 		install -m 0755 -d $(DESTDIR)/etc/sysconfig; \
 		install -m 0755 pkg/rpm/sysconfig/jobmond $(DESTDIR)/etc/sysconfig; \
 		install -m 0755 pkg/rpm/sysconfig/jobarchived $(DESTDIR)/etc/sysconfig; \
-    else \
+	else \
 		sed -i -e 's|DAEMON=.*|DAEMON=$(JOBMOND)|g' debian/jobmonarch-jobmond.init; \
 		sed -i -e 's|DAEMON=.*|DAEMON=$(JOBARCHIVED)|g' debian/jobmonarch-jobarchived.init; \
Index: /branches/1.2/pkg/rpm/jobmonarch.spec
===================================================================
--- /branches/1.2/pkg/rpm/jobmonarch.spec	(revision 954)
+++ /branches/1.2/pkg/rpm/jobmonarch.spec	(revision 955)
@@ -1,20 +1,39 @@
+
+# The following options are supported:
+#   --with httpd_user=<username>       # defaults to: apache
+#   --with httpd_group=<group>         # defaults to: apache
+#   --with ganglia_user=<username>     # defaults to: ganglia
+#   --with ganglia_group=<group>       # defaults to: ganglia
+#   --with web_prefixdir=<path>        # defaults to: /usr/share/ganglia-webfrontend
+
+# example: rpmbuild -tb jobmonarch-1.1.2.tar.gz --with httpd_user=www-data --with httpd_group=www-data --with web_prefixdir=/srv/www/ganglia
+
+# Default value for web_prefixdir depending on distro.
+%if 0%{?suse_version}
+%define web_prefixdir /srv/www/htdocs/ganglia
+%else
+%define web_prefixdir /usr/share/ganglia-webfrontend
+%endif
+
+# Default value for httpd user and group used by ganglia.
+%define httpd_user apache
+%define httpd_group apache
+%define ganglia_user ganglia
+%define ganglia_group ganglia
+
+# Read the provided --with tags if any (overriding default values).
+%{?_with_httpd_user:%define httpd_user %(set -- %{_with_httpd_user}; echo $1 | grep -v with | sed 's/=//')}
+%{?_with_httpd_group:%define httpd_group %(set -- %{_with_httpd_group}; echo $1 | grep -v with | sed 's/=//')}
+%{?_with_httpd_user:%define ganglia_user %(set -- %{_with_ganglia_user}; echo $1 | grep -v with | sed 's/=//')}
+%{?_with_httpd_group:%define ganglia_group %(set -- %{_with_ganglia_group}; echo $1 | grep -v with | sed 's/=//')}
+%{?_with_web_prefixdir:%define web_prefixdir %(set -- %{_with_web_prefixdir}; echo $1 | grep -v with | sed 's/=//')}
+
 # Don't need debuginfo RPM
 %define debug_package %{nil}
 %define __check_files %{nil}
 
-%if 0%{?suse_version}
-%define web_prefixdir /srv/www/htdocs/ganglia
-%else
-%define web_prefixdir %{custom_web_prefixdir}
-%endif
-
-%{!?custom_web_prefixdir: %define web_prefixdir /usr/share/ganglia}
-
 %define gangliaroot        %{web_prefixdir}
 %define gangliatemplatedir %{gangliaroot}/templates
 %define gangliaaddonsdir   %{gangliaroot}/addons
-
-%define gangliauser        %{custom_gangliauser}
-%{!?custom_gangliauser: %define gangliauser ganglia.ganglia}
 
 Summary: Tools and addons to Ganglia to monitor and archive batch job info
@@ -130,6 +149,6 @@
         PREFIX=/usr \
         GANGLIA_ROOT=%{gangliaroot} \
-        GANGLIA_USER=%{gangliauser} \
-        HTTPD_USER=apache.apache \
+        GANGLIA_USER=%{ganglia_user}.%{ganglia_group} \
+        HTTPD_USER=%{httpd_user}.%{httpd_group} \
         JOBARCHIVE_RRDS=%{_sharedstatedir}/jobarchive \
         DESTDIR=$RPM_BUILD_ROOT
@@ -142,5 +161,9 @@
 if [ "$1" = 1 ]; then
     # Enable the service
+%if 0%{?_unitdir:1}
+    /usr/bin/systemctl enable jobmond.service
+%else
     /sbin/chkconfig --add jobmond
+%endif
     echo ""
     echo "Additional manual changes are required to setup jobmond:"
@@ -154,5 +177,11 @@
     echo ""
 elif [ "$1" = 2 ]; then
+    echo "Restarting jobmond if needed..."
+%if 0%{?_unitdir:1}
+    /usr/bin/systemctl --system daemon-reload
+    /usr/bin/systemctl reload-or-try-restart jobmond.service
+%else
     /sbin/service jobmond condrestart
+%endif
 fi
 
@@ -161,5 +190,9 @@
 if [ "$1" = 1 ]; then
     # Enable the service
+%if 0%{?_unitdir:1}
+    /usr/bin/systemctl enable jobarchived.service
+%else
     /sbin/chkconfig --add jobarchived
+%endif
     echo "Generating random password and updating apropriate files"
     # Generate a 8 char password for the database:
@@ -188,5 +221,10 @@
 elif [ "$1" = 2 ]; then
     echo "Restarting jobarchived if needed..."
+%if 0%{?_unitdir:1}
+    /usr/bin/systemctl --system daemon-reload
+    /usr/bin/systemctl reload-or-try-restart jobarchived.service
+%else
     /sbin/service jobarchived condrestart
+%endif
     exit 0
 fi
@@ -202,16 +240,26 @@
 %preun -n jobmonarch-jobmond
 if [ "$1" = 0 ]; then
+%if 0%{?_unitdir:1}
+    /usr/bin/systemctl --no-reload disable jobmond.service
+    /usr/bin/systemctl stop jobmond.service
+%else
     if [ -x /sbin/chkconfig ]; then
 	/sbin/service jobmond stop
 	/sbin/chkconfig --del jobmond
     fi
+%endif
 fi
 
 %preun -n jobmonarch-jobarchived
 if [ "$1" = 0 ]; then
+%if 0%{?_unitdir:1}
+    /usr/bin/systemctl --no-reload disable jobarchived.service
+    /usr/bin/systemctl stop jobarchived.service
+%else
     if [ -x /sbin/chkconfig ]; then
 	/sbin/service jobarchived stop
 	/sbin/chkconfig --del jobarchived
     fi
+%endif
 fi
 
@@ -229,7 +277,11 @@
 %config(noreplace) %{_sysconfdir}/jobmond.conf
 %{_sysconfdir}/sysconfig/jobmond
-%{_initrddir}/jobmond
 %{_sbindir}/jobmond.py
 %{_sbindir}/jobmond
+%%if 0%{?_unitdir:1}
+%{_unitdir}/jobmond.service
+%else
+%{_initrddir}/jobmond
+%endif
 
 %files -n jobmonarch-jobarchived
@@ -238,5 +290,4 @@
 %config(noreplace) %{_sysconfdir}/jobarchived.conf
 %{_sysconfdir}/sysconfig/jobarchived
-%{_initrddir}/jobarchived
 %dir %{_datadir}/jobarchived
 %{_sbindir}/jobarchived.py
@@ -244,4 +295,9 @@
 %{_datadir}/jobarchived/*
 %dir %{_sharedstatedir}/jobarchive
+%%if 0%{?_unitdir:1}
+%{_unitdir}/jobarchived.service
+%else
+%{_initrddir}/jobarchived
+%endif
 
 %files -n jobmonarch-webfrontend
@@ -416,4 +472,13 @@
 
 %changelog
+* Wed Mar 05 2014 Olivier Lahaye <olivier.lahaye@free.fr> 1.2.0-1
+- Update default ganglia root.
+- Add native systemd support.
+- update to 1.2.0
+- Add --with switch to allow tunning at rpmbuild. Parameters are similar to ganglia ones.
+
+* Fri Feb 14 2014 Ramon Bastiaans <ramon.bastiaans@surfsara.nl> 1.1.2-1
+- New version
+
 * Fri Sep 20 2013 Olivier Lahaye <olivier.lahaye@free.fr> 1.1.1-1
 - update to 1.1.1
Index: /branches/1.2/pkg/rpm/systemd/jobarchived.service
===================================================================
--- /branches/1.2/pkg/rpm/systemd/jobarchived.service	(revision 955)
+++ /branches/1.2/pkg/rpm/systemd/jobarchived.service	(revision 955)
@@ -0,0 +1,17 @@
+# SystemD File for jobarchived
+# Olivier LAHAYE <olivier.lahaye@cea.fr>
+# Ferbruay 19th 2013.
+
+[Unit]
+Description=Start/Stop the jobarchived batch jobs archiving daemon
+After=syslog.target network.target postgresql.service jobmond.service
+
+[Service]
+Type=forking
+EnvironmentFile=-/etc/sysconfig/jobarchived
+ExecStart=/usr/sbin/jobarchived --pidfile=/var/run/jobarchived.pid $OPTIONS
+PIDFile=/var/run/jobarchived.pid
+
+[Install]
+WantedBy=multi-user.target
+
Index: /branches/1.2/pkg/rpm/systemd/jobmond.service
===================================================================
--- /branches/1.2/pkg/rpm/systemd/jobmond.service	(revision 955)
+++ /branches/1.2/pkg/rpm/systemd/jobmond.service	(revision 955)
@@ -0,0 +1,17 @@
+# SystemD File for jobmond
+# Olivier LAHAYE <olivier.lahaye@cea.fr>
+# Ferbruay 19th 2013.
+
+[Unit]
+Description=Start/Stop the jobmond batch jobs monitoring daemon
+After=syslog.target network.target
+
+[Service]
+Type=forking
+EnvironmentFile=-/etc/sysconfig/jobmond
+ExecStart=/usr/sbin/jobmond --pidfile=/var/run/jobmond.pid $OPTIONS
+PIDFile=/var/run/jobmond.pid
+
+[Install]
+WantedBy=multi-user.target
+
