commit 76efee8b04b9e2e7e9db9cd7952809ac2a297f36 Author: Pete Zaitcev zaitcev@redhat.com Date: Wed Nov 2 10:33:30 2011 -0600
iwhd: add native systemd support
1. The unitdir madness. The problem here is that DESTDIR may be empty, and in the same time the prefix set to something. Therefore, unitdir cannot be defined as an absolute path. The _only_ way to stuff this makefile through the "make check" is to use one of the predefined variables that depend on prefix _and_ DESTDIR (which may be non-empty). Ergo, the double-dot over sysconfigdir. Madness.
2. Why did we ever put -c outside of the normal configuration? It is extremely unpleasant to explain how it works to fellow hackers and sysadmins, and it confuses people greatly. I pulled this in.
3. The -m 600 is necessary for users.js, because the passwords are in plaintext! They must be in plaintext for OAuth, because of the way hashing works.
Makefile.am | 15 ++++++++++++--- iwhd.init.in | 4 ++-- iwhd.service | 14 ++++++++++++++ iwhd.spec.in | 5 +++++ iwhd.sysconfig | 3 +++ 5 files changed, 36 insertions(+), 5 deletions(-) --- diff --git a/Makefile.am b/Makefile.am index 0b093d5..b0b1587 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,8 +28,10 @@ EXTRA_DIST = \ dc-register-image \ iwhd.init.in \ iwhd.logrotate \ + iwhd.service \ iwhd.spec \ iwhd.spec.in \ + iwhd.sysconfig \ qparser.h
BUILT_SOURCES = qparser.h qlexer.c @@ -137,13 +139,18 @@ iwhd-users.js: $(top_builddir)/config.status > $@-t && chmod a-w $@-t && mv $@-t $@
logrotate_dir = $(DESTDIR)$(sysconfdir)/logrotate.d +unitdir = $(sysconfdir)/../lib/systemd/system .PHONY: install-data-local install-data-local: iwhd.init iwhd-conf.js iwhd-users.js mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d $(INSTALL_SCRIPT) iwhd.init $(DESTDIR)$(sysconfdir)/rc.d/init.d/iwhd mkdir -p $(DESTDIR)$(sysconfdir)/iwhd $(INSTALL_DATA) iwhd-conf.js $(DESTDIR)$(sysconfdir)/iwhd/conf.js - $(INSTALL_DATA) iwhd-users.js $(DESTDIR)$(sysconfdir)/iwhd/users.js + $(INSTALL) -m 600 iwhd-users.js $(DESTDIR)$(sysconfdir)/iwhd/users.js + mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig + $(INSTALL_DATA) $(top_srcdir)/iwhd.sysconfig $(DESTDIR)$(sysconfdir)/sysconfig/iwhd + mkdir -p $(DESTDIR)$(unitdir) + $(INSTALL_DATA) $(top_srcdir)/iwhd.service $(DESTDIR)$(unitdir)/iwhd.service mkdir -p $(logrotate_dir) $(INSTALL_DATA) $(top_srcdir)/iwhd.logrotate $(logrotate_dir)/iwhd mkdir -p $(DESTDIR)$(DEFAULT_FS_DIR) @@ -152,8 +159,10 @@ install-data-local: iwhd.init iwhd-conf.js iwhd-users.js uninstall-local: rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/iwhd \ $(DESTDIR)$(sysconfdir)/iwhd/conf.js \ - $(logrotate_dir)/iwhd \ - $(DESTDIR)$(sysconfdir)/iwhd/users.js + $(DESTDIR)$(sysconfdir)/iwhd/users.js \ + $(DESTDIR)$(sysconfdir)/sysconfig/iwhd \ + $(DESTDIR)/$(unitdir)/iwhd.service \ + $(logrotate_dir)/iwhd rmdir $(DESTDIR)$(DEFAULT_FS_DIR)
AM_CPPFLAGS = $(HAIL_CFLAGS) -Ilib -I$(top_srcdir)/lib diff --git a/iwhd.init.in b/iwhd.init.in index ab03a26..a82622e 100644 --- a/iwhd.init.in +++ b/iwhd.init.in @@ -37,7 +37,7 @@ MONGOD_N_SECONDS=2 # writing in /tmp. export TMPDIR=@localstatedir@/cache/iwhd
-IWHD_ARGS="-d $MONGOD_SERVER_SPEC -l $IWHD_LOG_FILE" +IWHD_ARGS="-c $CONFIG_JS -d $MONGOD_SERVER_SPEC -l $IWHD_LOG_FILE"
test -r @sysconfdir@/sysconfig/iwhd && . @sysconfdir@/sysconfig/iwhd
@@ -84,7 +84,7 @@ start() { echo
printf %s $"Starting $SERVICE daemon: " - $PROCESS -c "$CONFIG_JS" $IWHD_ARGS & + $PROCESS $IWHD_ARGS & pid=$! RETVAL=$? if test $RETVAL = 0; then diff --git a/iwhd.service b/iwhd.service new file mode 100644 index 0000000..200148b --- /dev/null +++ b/iwhd.service @@ -0,0 +1,14 @@ +[Unit] +Description=Image Warehouse +After=network.target + +# The "simple" type requires communication channels being established +# by systemd with socket activation; this is not yet the case for iwhd. +# The best bet may actually be fixing up iwhd to use sd_notify(3). +[Service] +EnvironmentFile=-/etc/sysconfig/iwhd +Type=simple +ExecStart=/usr/bin/iwhd $IWHD_ARGS + +[Install] +WantedBy=multi-user.target diff --git a/iwhd.spec.in b/iwhd.spec.in index c1c67bd..38ada80 100644 --- a/iwhd.spec.in +++ b/iwhd.spec.in @@ -68,8 +68,13 @@ rm -rf %{buildroot} %config(noreplace) %{_sysconfdir}/iwhd/conf.js %config(noreplace) %{_sysconfdir}/iwhd/users.js %config(noreplace) %{_sysconfdir}/logrotate.d/iwhd +%config(noreplace) %{_sysconfdir}/sysconfig/iwhd %{_localstatedir}/lib/iwhd
+# Use _unitdir on F16+ +#{_unitdir}/iwhd.service +/lib/systemd/system/iwhd.service + %changelog * Wed Oct 7 2010 Jim Meyering meyering@redhat.com - 0.90-1 - Initial release. diff --git a/iwhd.sysconfig b/iwhd.sysconfig new file mode 100644 index 0000000..7533656 --- /dev/null +++ b/iwhd.sysconfig @@ -0,0 +1,3 @@ +# See iwhd(8) for the list of arguments. +# IWHD_ARGS="-c /etc/iwhd/conf.js -d localhost:27017 -l /var/log/iwhd.log" +IWHD_ARGS="-c /etc/iwhd/conf.js -l /var/log/iwhd.log"
iwhd-commit@lists.fedorahosted.org