install nodemanager with systemd unit files instead of initscripts
[nodemanager.git] / Makefile
1 #
2 # Node Manager Makefile
3 #
4 # David Eisenstat <deisenst@cs.princeton.edu>
5 # Mark Huang <mlhuang@cs.princeton.edu>
6 # Copyright (C) 2006 The Trustees of Princeton University
7 #
8
9 # autoconf compatible variables
10 datadir := /usr/share
11 bindir := /usr/bin
12 initdir=/etc/init.d
13 systemddir := /usr/lib/systemd/system
14
15 ####################
16 # call with either WITH_SYSTEMD=true or WITH_INIT=true
17 ifneq "$(WITH_SYSTEMD)" ""
18 use_sytemd=true
19 else
20 ifneq "$(WITH_INIT)" ""
21 use_systemd=""
22 else # if not set then try to guess
23 use_systemd=$(bash -c 'type -p systemctl')
24 endif
25 endif
26
27 ####################
28 lib: forward_api_calls
29         python setup-lib.py build
30
31 vs: 
32         python setup-vs.py build
33
34 lxc: 
35         python setup-lxc.py build
36
37 forward_api_calls: forward_api_calls.c
38         $(CC) -Wall -Os -o $@ $?
39         strip $@
40
41 #################### install
42 install-lib: install-miscell install-startup
43         python setup-lib.py install \
44                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
45                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
46                 --install-scripts=$(DESTDIR)/$(bindir)
47
48 # might be better in setup.py ?
49 install-miscell:
50         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
51         install -d -m 755 $(DESTDIR)/var/lib/nodemanager
52         install -D -m 644 logrotate/nodemanager $(DESTDIR)/etc/logrotate.d/nodemanager
53         install -D -m 755 sshsh $(DESTDIR)/bin/sshsh
54         mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts
55         rsync -av sliver-initscripts/ $(DESTDIR)/$(datadir)/sliver-initscripts/
56         chmod 755 $(DESTDIR)/$(datadir)/sliver-initscripts/
57
58 ifneq "$use_systemd" ""
59 install-startup: install-systemd
60 else
61 install-startup: install-init
62 endif
63
64 install-init:
65         mkdir -p $(DESTDIR)$(initdir)
66         chmod 755 initscripts/*
67         rsync -av initscripts/ $(DESTDIR)$(initdir)/
68
69 install-systemd:
70         mkdir -p $(DESTDIR)/$(systemddir)
71         rsync -av systemd/ $(DESTDIR)/$(systemddir)
72
73 install-vs:
74         python setup-vs.py install \
75                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
76                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
77                 --install-scripts=$(DESTDIR)/$(bindir)
78         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
79
80 install-lxc:
81         python setup-lxc.py install \
82                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
83                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
84                 --install-scripts=$(DESTDIR)/$(bindir)
85         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
86
87 #################### clean
88 clean:
89         python setup-lib.py clean
90         python setup-vs.py clean
91         python setup-lxc.py clean
92         rm -f forward_api_calls *.pyc build
93
94 .PHONY: all install clean
95
96 ##########
97 tags:
98         (find . '(' -name '*.py' -o -name '*.c' -o -name '*.spec' ')' ; ls initscripts/*) | xargs etags 
99
100 .PHONY: tags
101
102 ########## sync
103 # for use with the test framework; push local stuff on a test node
104 # howto use: go on testmaster in the build you want to use and just run
105 # $ exp
106 # cut'n paste the result in a terminal in your working dir, e.g. (although all are not required)
107 # $ export BUILD=2013.07.02--lxc18
108 # $ export PLCHOSTLXC=gotan.pl.sophia.inria.fr
109 # $ export GUESTNAME=2013.07.02--lxc18-1-vplc01
110 # $ export GUESTHOSTNAME=vplc01.pl.sophia.inria.fr
111 # $ export KVMHOST=kvm64-6.pl.sophia.inria.fr
112 # $ export NODE=vnode01.pl.sophia.inria.fr
113 # and then just run
114 # $ make sync
115
116 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
117 RSYNC_EXCLUDES          := --exclude .git  --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
118 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
119 RSYNC                   := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
120
121 ifdef NODE
122 NODEURL:=root@$(NODE):/
123 endif
124
125 # this is for lxc only, we need to exclude the vs stuff that otherwise messes up everything on node
126 # keep this in sync with setup-vs.spec
127 LXC_EXCLUDES= --exclude sliver_vs.py --exclude coresched_vs.py
128
129 sync:synclxc
130
131 synclxc: $(NODE).key.rsa
132 ifeq (,$(NODEURL))
133         @echo "sync: You must define NODE on the command line"
134         @echo "  e.g. make sync NODE=vnode01.inria.fr"
135         @exit 1
136 else
137         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
138         @echo WARNING : this target might not be very reliable - use with care
139         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
140         +$(RSYNC) --exclude sshsh $(LXC_EXCLUDES) --delete-excluded ./ $(NODEURL)/usr/share/NodeManager/
141         +$(RSYNC) ./sshsh $(NODEURL)/bin/
142 #       +$(RSYNC) ./initscripts/ $(NODEURL)/etc/init.d/
143         +$(RSYNC) ./systemd/ $(NODEURL)/usr/lib/systemd/system/
144 #       ssh -i $(NODE).key.rsa root@$(NODE) service nm restart
145 endif
146
147 ### fetching the key
148
149 TESTMASTER ?= testmaster.onelab.eu
150
151 ifdef BUILD
152 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
153 endif
154
155 key: $(NODE).key.rsa
156
157 $(NODE).key.rsa:
158 ifeq (,$(KEYURL))
159         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
160         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
161         @echo "  note that for now all test builds use the same key, so any BUILD would do"
162         @exit 1
163 else
164         @echo "FETCHING key"
165         +scp $(KEYURL) $@
166 endif