install nodemanager with systemd unit files instead of initscripts
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 16 Jan 2014 09:17:00 +0000 (10:17 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 16 Jan 2014 09:17:00 +0000 (10:17 +0100)
Makefile
nodemanager-lib.spec
systemd/conf_files.service [new file with mode: 0644]
systemd/fuse-pl.service [new file with mode: 0644]
systemd/nm.service [new file with mode: 0644]

index c84241d..694ae92 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,22 @@
 # autoconf compatible variables
 datadir := /usr/share
 bindir := /usr/bin
+initdir=/etc/init.d
+systemddir := /usr/lib/systemd/system
 
+####################
+# call with either WITH_SYSTEMD=true or WITH_INIT=true
+ifneq "$(WITH_SYSTEMD)" ""
+use_sytemd=true
+else
+ifneq "$(WITH_INIT)" ""
+use_systemd=""
+else # if not set then try to guess
+use_systemd=$(bash -c 'type -p systemctl')
+endif
+endif
+
+####################
 lib: forward_api_calls
        python setup-lib.py build
 
@@ -23,12 +38,37 @@ forward_api_calls: forward_api_calls.c
        $(CC) -Wall -Os -o $@ $?
        strip $@
 
-install-lib:
+#################### install
+install-lib: install-miscell install-startup
        python setup-lib.py install \
                --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
                --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
                --install-scripts=$(DESTDIR)/$(bindir)
+
+# might be better in setup.py ?
+install-miscell:
        install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
+       install -d -m 755 $(DESTDIR)/var/lib/nodemanager
+       install -D -m 644 logrotate/nodemanager $(DESTDIR)/etc/logrotate.d/nodemanager
+       install -D -m 755 sshsh $(DESTDIR)/bin/sshsh
+       mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts
+       rsync -av sliver-initscripts/ $(DESTDIR)/$(datadir)/sliver-initscripts/
+       chmod 755 $(DESTDIR)/$(datadir)/sliver-initscripts/
+
+ifneq "$use_systemd" ""
+install-startup: install-systemd
+else
+install-startup: install-init
+endif
+
+install-init:
+       mkdir -p $(DESTDIR)$(initdir)
+       chmod 755 initscripts/*
+       rsync -av initscripts/ $(DESTDIR)$(initdir)/
+
+install-systemd:
+       mkdir -p $(DESTDIR)/$(systemddir)
+       rsync -av systemd/ $(DESTDIR)/$(systemddir)
 
 install-vs:
        python setup-vs.py install \
@@ -44,21 +84,7 @@ install-lxc:
                --install-scripts=$(DESTDIR)/$(bindir)
        install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
 
-install-scripts: 
-       mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts
-       rsync -av sliver-initscripts/ $(DESTDIR)/$(datadir)/sliver-initscripts/
-       chmod 755 $(DESTDIR)/$(datadir)/sliver-initscripts/
-
-       mkdir -p $(DESTDIR)/etc/init.d
-       chmod 755 initscripts/*
-       rsync -av initscripts/ $(DESTDIR)/etc/init.d/
-
-       install -d -m 755 $(DESTDIR)/var/lib/nodemanager
-
-       install -D -m 644 logrotate/nodemanager $(DESTDIR)/etc/logrotate.d/nodemanager
-       install -D -m 755 sshsh $(DESTDIR)/bin/sshsh
-
-
+#################### clean
 clean:
        python setup-lib.py clean
        python setup-vs.py clean
@@ -113,7 +139,7 @@ else
        @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        +$(RSYNC) --exclude sshsh $(LXC_EXCLUDES) --delete-excluded ./ $(NODEURL)/usr/share/NodeManager/
        +$(RSYNC) ./sshsh $(NODEURL)/bin/
-#      +$(RSYNC) ./initscripts/nm $(NODEURL)/etc/init.d/nm
+#      +$(RSYNC) ./initscripts/ $(NODEURL)/etc/init.d/
        +$(RSYNC) ./systemd/ $(NODEURL)/usr/lib/systemd/system/
 #      ssh -i $(NODE).key.rsa root@$(NODE) service nm restart
 endif
index 7687c9e..90a2dc6 100644 (file)
@@ -45,17 +45,24 @@ local operations on slices.
 nodemanager-lib only provides a skeleton and needs as a companion
 either nodemanager-vs or nodemanager-lxc
 
+# use initscripts or systemd unit files to start installed services
+%if "%{distro}" == "Fedora" && %{distrorelease} >= 18
+%define make_options=WITH_SYSTEMD=true
+%else
+%define make_options=WITH_INIT=true
+%endif
+
 %prep
 %setup -q
 
 %build
 # make manages the C and Python stuff
-%{__make} %{?_smp_mflags} lib
+%{__make} %{?_smp_mflags} %{make_options} lib 
 
 %install
 # make manages the C and Python stuff
 rm -rf $RPM_BUILD_ROOT
-%{__make} %{?_smp_mflags} install-lib DESTDIR="$RPM_BUILD_ROOT"
+%{__make} %{?_smp_mflags} %{make_options} install-lib DESTDIR="$RPM_BUILD_ROOT"
 
 # install the sliver initscript (that triggers the slice initscript if any)
 mkdir -p $RPM_BUILD_ROOT/usr/share/NodeManager/sliver-initscripts/
diff --git a/systemd/conf_files.service b/systemd/conf_files.service
new file mode 100644 (file)
index 0000000..5a6ecc8
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=Fetch configuration files as defined by controlling MyPLC
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/env python /usr/share/NodeManager/conf_files.py
+Before=lxc-sliceimage
+
+[Install]
+WantedBy=multi-user.target
diff --git a/systemd/fuse-pl.service b/systemd/fuse-pl.service
new file mode 100644 (file)
index 0000000..f98ddfe
--- /dev/null
@@ -0,0 +1,2 @@
+# This is placeholder for fuse-pl in a lxc/systemd setup
+# needs to be rewritten as the initscript version seems to rely on vservers
diff --git a/systemd/nm.service b/systemd/nm.service
new file mode 100644 (file)
index 0000000..f279894
--- /dev/null
@@ -0,0 +1,12 @@
+[Unit]
+Description=PlanetLab NodeManager
+After=libvirtd.target
+
+[Service]
+EnvironmentFile=/etc/sysconfig/nodemanager
+Type=forking
+PIDFile=/var/run/nodemanager.pid
+ExecStart=/usr/bin/env python /usr/share/NodeManager/nodemanager.py -d $OPTIONS
+
+[Install]
+WantedBy=multi-user.target