From 50707e7d621e00b4ab9715be8310af5f1a9e08c2 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 27 Feb 2018 15:27:18 +0800 Subject: [PATCH 1/2] debian: install system units using cmake Signed-off-by: Kefu Chai --- debian/ceph-common.install | 2 ++ debian/ceph-fuse.install | 1 + debian/ceph-mds.install | 1 + debian/ceph-mgr.install | 1 + debian/ceph-mon.install | 1 + debian/ceph-osd.install | 3 +++ debian/radosgw.install | 1 + debian/rbd-mirror.install | 1 + debian/rules | 34 ++-------------------------------- systemd/CMakeLists.txt | 4 +++- 10 files changed, 16 insertions(+), 33 deletions(-) diff --git a/debian/ceph-common.install b/debian/ceph-common.install index afba9d90240..dfc713d905e 100755 --- a/debian/ceph-common.install +++ b/debian/ceph-common.install @@ -4,6 +4,8 @@ etc/bash_completion.d/ceph etc/bash_completion.d/rados etc/bash_completion.d/radosgw-admin etc/bash_completion.d/rbd +lib/systemd/system/ceph.target +lib/systemd/system/rbdmap.service usr/bin/ceph usr/bin/ceph-authtool usr/bin/ceph-conf diff --git a/debian/ceph-fuse.install b/debian/ceph-fuse.install index d6ad4dcb2a6..e132b7957c1 100644 --- a/debian/ceph-fuse.install +++ b/debian/ceph-fuse.install @@ -1,3 +1,4 @@ +lib/systemd/system/ceph-fuse* usr/bin/ceph-fuse usr/sbin/mount.fuse.ceph sbin usr/share/man/man8/ceph-fuse.8 diff --git a/debian/ceph-mds.install b/debian/ceph-mds.install index 8a5d74e13c9..a26d5596c59 100644 --- a/debian/ceph-mds.install +++ b/debian/ceph-mds.install @@ -1,2 +1,3 @@ +lib/systemd/system/ceph-mds* usr/bin/ceph-mds usr/share/man/man8/ceph-mds.8 diff --git a/debian/ceph-mgr.install b/debian/ceph-mgr.install index 0ec0f7063db..34af599462a 100644 --- a/debian/ceph-mgr.install +++ b/debian/ceph-mgr.install @@ -1,2 +1,3 @@ +lib/systemd/system/ceph-mgr* usr/bin/ceph-mgr usr/lib/ceph/mgr diff --git a/debian/ceph-mon.install b/debian/ceph-mon.install index edf92852001..a9785bddbb1 100644 --- a/debian/ceph-mon.install +++ b/debian/ceph-mon.install @@ -1,3 +1,4 @@ +lib/systemd/system/ceph-mon* usr/bin/ceph-mon usr/bin/ceph-monstore-tool usr/bin/ceph-rest-api diff --git a/debian/ceph-osd.install b/debian/ceph-osd.install index 6e03f1b8df9..5e319f743b1 100644 --- a/debian/ceph-osd.install +++ b/debian/ceph-osd.install @@ -1,5 +1,8 @@ lib/udev/rules.d/60-ceph-by-parttypeuuid.rules lib/udev/rules.d/95-ceph-osd.rules +lib/systemd/system/ceph-disk@.service +lib/systemd/system/ceph-osd* +lib/systemd/system/ceph-volume@.service usr/bin/ceph-bluestore-tool usr/bin/ceph-clsinfo usr/bin/ceph-objectstore-tool diff --git a/debian/radosgw.install b/debian/radosgw.install index d583799299c..329ea0e480f 100644 --- a/debian/radosgw.install +++ b/debian/radosgw.install @@ -1,3 +1,4 @@ +lib/systemd/system/ceph-radosgw* usr/bin/radosgw usr/bin/radosgw-es usr/bin/radosgw-object-expirer diff --git a/debian/rbd-mirror.install b/debian/rbd-mirror.install index 80f8210361c..cc617a55304 100644 --- a/debian/rbd-mirror.install +++ b/debian/rbd-mirror.install @@ -1,2 +1,3 @@ +lib/systemd/system/ceph-rbd-mirror* usr/bin/rbd-mirror usr/share/man/man8/rbd-mirror.8 diff --git a/debian/rules b/debian/rules index c8088277447..50495ffb6da 100755 --- a/debian/rules +++ b/debian/rules @@ -6,11 +6,12 @@ export DESTDIR=$(CURDIR)/debian/tmp export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) extraopts += -DUSE_CRYPTOPP=OFF -DWITH_OCF=ON -DWITH_LTTNG=ON -DWITH_PYTHON3=ON -DWITH_EMBEDDED=OFF -extraopts += -DWITH_CEPHFS_JAVA=ON -DWITH_SYSTEMD=OFF +extraopts += -DWITH_CEPHFS_JAVA=ON -DWITH_SYSTEMD=ON # assumes that ceph is exmpt from multiarch support, so we override the libdir. extraopts += -DCMAKE_INSTALL_LIBDIR=/usr/lib extraopts += -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib extraopts += -DCMAKE_INSTALL_SYSCONFDIR=/etc +extraopts += -DCMAKE_INSTALL_SYSTEMD_SERVICEDIR=/lib/systemd/system ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) extraopts += -DBOOST_J=$(NUMJOBS) @@ -77,52 +78,21 @@ override_dh_installinit: install -d -m0755 debian/rbd-mirror/etc/init install -m0644 src/upstart/ceph-rbd-mirror*.conf debian/rbd-mirror/etc/init # install the systemd stuff manually since we have funny service names - install -d -m0755 debian/ceph-common/lib/systemd/system - install -m0644 systemd/ceph.target debian/ceph-common/lib/systemd/system install -d -m0755 debian/ceph-common/etc/default install -m0644 etc/default/ceph debian/ceph-common/etc/default/ install -d -m0755 debian/ceph-common/usr/lib/tmpfiles.d install -m 0644 -D systemd/ceph.tmpfiles.d debian/ceph-common/usr/lib/tmpfiles.d/ceph.conf - install -d -m0755 debian/ceph-base/lib/systemd/system - install -d -m0755 debian/ceph-mon/lib/systemd/system - install -d -m0755 debian/ceph-osd/lib/systemd/system - install -m0644 systemd/ceph-mon@.service debian/ceph-mon/lib/systemd/system - install -m0644 systemd/ceph-osd@.service debian/ceph-osd/lib/systemd/system - install -m0644 systemd/ceph-disk@.service debian/ceph-osd/lib/systemd/system - install -m0644 systemd/ceph-volume@.service debian/ceph-osd/lib/systemd/system - install -m0644 systemd/rbdmap.service debian/ceph-common/lib/systemd/system sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-mon/lib/systemd/system/ceph-mon@.service sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-osd/lib/systemd/system/ceph-osd@.service sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-osd/lib/systemd/system/ceph-disk@.service sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-osd/lib/systemd/system/ceph-volume@.service - install -m0644 systemd/ceph-mon.target debian/ceph-mon/lib/systemd/system - install -m0644 systemd/ceph-osd.target debian/ceph-osd/lib/systemd/system - install -d -m0755 debian/ceph-mds/lib/systemd/system - install -m0644 systemd/ceph-mds@.service debian/ceph-mds/lib/systemd/system sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-mds/lib/systemd/system/ceph-mds@.service - install -m0644 systemd/ceph-mds.target debian/ceph-mds/lib/systemd/system - - install -d -m0755 debian/ceph-fuse/lib/systemd/system - install -m0644 systemd/ceph-fuse@.service debian/ceph-fuse/lib/systemd/system sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-fuse/lib/systemd/system/ceph-fuse@.service - install -m0644 systemd/ceph-fuse.target debian/ceph-fuse/lib/systemd/system - - install -d -m0755 debian/ceph-mgr/lib/systemd/system - install -m0644 systemd/ceph-mgr@.service debian/ceph-mgr/lib/systemd/system sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-mgr/lib/systemd/system/ceph-mgr@.service - install -m0644 systemd/ceph-mgr.target debian/ceph-mgr/lib/systemd/system - - install -d -m0755 debian/radosgw/lib/systemd/system - install -m0644 systemd/ceph-radosgw@.service debian/radosgw/lib/systemd/system sed -i s./etc/sysconfig/./etc/default/.g debian/radosgw/lib/systemd/system/ceph-radosgw@.service - install -m0644 systemd/ceph-radosgw.target debian/radosgw/lib/systemd/system - - install -d -m0755 debian/rbd-mirror/lib/systemd/system - install -m0644 systemd/ceph-rbd-mirror@.service debian/rbd-mirror/lib/systemd/system sed -i s./etc/sysconfig/./etc/default/.g debian/rbd-mirror/lib/systemd/system/ceph-rbd-mirror@.service - install -m0644 systemd/ceph-rbd-mirror.target debian/rbd-mirror/lib/systemd/system dh_installinit -p ceph-base --name ceph --no-start dh_installinit -p radosgw --no-start diff --git a/systemd/CMakeLists.txt b/systemd/CMakeLists.txt index 3b03b6e6132..cd88f328926 100644 --- a/systemd/CMakeLists.txt +++ b/systemd/CMakeLists.txt @@ -1,3 +1,5 @@ +set(CMAKE_INSTALL_SYSTEMD_SERVICEDIR "${CMAKE_INSTALL_LIBEXECDIR}/systemd/system" + CACHE PATH "Location for systemd service files") install(FILES ceph.target ceph-fuse.target @@ -17,4 +19,4 @@ install(FILES ceph-disk@.service ceph-volume@.service rbdmap.service - DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/systemd/system) + DESTINATION ${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}) From 4865831b913a7a413055237d3acf3623c421a884 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 27 Feb 2018 16:42:48 +0800 Subject: [PATCH 2/2] cmake,deb: set EnvironmentFile using cmake this change also fix the EnvironmentFile specified in rbdmap.service. without this change EnvironmentFile in rbdmap.service is always /etc/sysconfig/ceph even on debian derived distros. after this change, this variable is /etc/default/ceph in rbdmap.service shipped by the deb packages. Signed-off-by: Kefu Chai --- debian/rules | 14 ++------- systemd/CMakeLists.txt | 29 ++++++++++++++----- ...ph-fuse@.service => ceph-fuse@.service.in} | 2 +- ...ceph-mds@.service => ceph-mds@.service.in} | 2 +- ...ceph-mgr@.service => ceph-mgr@.service.in} | 2 +- ...ceph-mon@.service => ceph-mon@.service.in} | 2 +- ...ceph-osd@.service => ceph-osd@.service.in} | 2 +- ...osgw@.service => ceph-radosgw@.service.in} | 2 +- ...r@.service => ceph-rbd-mirror@.service.in} | 2 +- systemd/{rbdmap.service => rbdmap.service.in} | 2 +- 10 files changed, 31 insertions(+), 28 deletions(-) rename systemd/{ceph-fuse@.service => ceph-fuse@.service.in} (91%) rename systemd/{ceph-mds@.service => ceph-mds@.service.in} (94%) rename systemd/{ceph-mgr@.service => ceph-mgr@.service.in} (93%) rename systemd/{ceph-mon@.service => ceph-mon@.service.in} (95%) rename systemd/{ceph-osd@.service => ceph-osd@.service.in} (94%) rename systemd/{ceph-radosgw@.service => ceph-radosgw@.service.in} (93%) rename systemd/{ceph-rbd-mirror@.service => ceph-rbd-mirror@.service.in} (93%) rename systemd/{rbdmap.service => rbdmap.service.in} (90%) diff --git a/debian/rules b/debian/rules index 50495ffb6da..5f8923b48fa 100755 --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,8 @@ export DESTDIR=$(CURDIR)/debian/tmp export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) extraopts += -DUSE_CRYPTOPP=OFF -DWITH_OCF=ON -DWITH_LTTNG=ON -DWITH_PYTHON3=ON -DWITH_EMBEDDED=OFF -extraopts += -DWITH_CEPHFS_JAVA=ON -DWITH_SYSTEMD=ON +extraopts += -DWITH_CEPHFS_JAVA=ON +extraopts += -DWITH_SYSTEMD=ON -DCEPH_SYSTEMD_ENV_DIR=/etc/default # assumes that ceph is exmpt from multiarch support, so we override the libdir. extraopts += -DCMAKE_INSTALL_LIBDIR=/usr/lib extraopts += -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib @@ -83,17 +84,6 @@ override_dh_installinit: install -d -m0755 debian/ceph-common/usr/lib/tmpfiles.d install -m 0644 -D systemd/ceph.tmpfiles.d debian/ceph-common/usr/lib/tmpfiles.d/ceph.conf - sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-mon/lib/systemd/system/ceph-mon@.service - sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-osd/lib/systemd/system/ceph-osd@.service - sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-osd/lib/systemd/system/ceph-disk@.service - sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-osd/lib/systemd/system/ceph-volume@.service - - sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-mds/lib/systemd/system/ceph-mds@.service - sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-fuse/lib/systemd/system/ceph-fuse@.service - sed -i s./etc/sysconfig/./etc/default/.g debian/ceph-mgr/lib/systemd/system/ceph-mgr@.service - sed -i s./etc/sysconfig/./etc/default/.g debian/radosgw/lib/systemd/system/ceph-radosgw@.service - sed -i s./etc/sysconfig/./etc/default/.g debian/rbd-mirror/lib/systemd/system/ceph-rbd-mirror@.service - dh_installinit -p ceph-base --name ceph --no-start dh_installinit -p radosgw --no-start diff --git a/systemd/CMakeLists.txt b/systemd/CMakeLists.txt index cd88f328926..86ea87cde4e 100644 --- a/systemd/CMakeLists.txt +++ b/systemd/CMakeLists.txt @@ -1,5 +1,26 @@ set(CMAKE_INSTALL_SYSTEMD_SERVICEDIR "${CMAKE_INSTALL_LIBEXECDIR}/systemd/system" CACHE PATH "Location for systemd service files") +set(CEPH_SYSTEMD_ENV_DIR "/etc/sysconf" + CACHE PATH "Location for systemd service environmental variable settings files") +set(SYSTEMD_ENV_FILE "${CEPH_SYSTEMD_ENV_DIR}/ceph") +foreach(service + ceph-fuse@ + ceph-mds@ + ceph-mgr@ + ceph-mon@ + ceph-osd@ + ceph-radosgw@ + ceph-rbd-mirror@ + rbdmap) + configure_file( + ${service}.service.in + ${service}.service + @ONLY) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${service}.service + DESTINATION ${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}) +endforeach() + install(FILES ceph.target ceph-fuse.target @@ -9,14 +30,6 @@ install(FILES ceph-mds.target ceph-radosgw.target ceph-rbd-mirror.target - ceph-fuse@.service - ceph-mds@.service - ceph-mgr@.service - ceph-mon@.service - ceph-osd@.service - ceph-radosgw@.service - ceph-rbd-mirror@.service ceph-disk@.service ceph-volume@.service - rbdmap.service DESTINATION ${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}) diff --git a/systemd/ceph-fuse@.service b/systemd/ceph-fuse@.service.in similarity index 91% rename from systemd/ceph-fuse@.service rename to systemd/ceph-fuse@.service.in index 98982441ebc..11eb7e760d7 100644 --- a/systemd/ceph-fuse@.service +++ b/systemd/ceph-fuse@.service.in @@ -6,7 +6,7 @@ Conflicts=umount.target PartOf=ceph-fuse.target [Service] -EnvironmentFile=-/etc/sysconfig/ceph +EnvironmentFile=-@SYSTEMD_ENV_FILE@ Environment=CLUSTER=ceph ExecStart=/usr/bin/ceph-fuse -f --cluster ${CLUSTER} %I TasksMax=infinity diff --git a/systemd/ceph-mds@.service b/systemd/ceph-mds@.service.in similarity index 94% rename from systemd/ceph-mds@.service rename to systemd/ceph-mds@.service.in index d34bd057b76..bd472f66b22 100644 --- a/systemd/ceph-mds@.service +++ b/systemd/ceph-mds@.service.in @@ -7,7 +7,7 @@ PartOf=ceph-mds.target [Service] LimitNOFILE=1048576 LimitNPROC=1048576 -EnvironmentFile=-/etc/sysconfig/ceph +EnvironmentFile=-@SYSTEMD_ENV_FILE@ Environment=CLUSTER=ceph ExecStart=/usr/bin/ceph-mds -f --cluster ${CLUSTER} --id %i --setuser ceph --setgroup ceph ExecReload=/bin/kill -HUP $MAINPID diff --git a/systemd/ceph-mgr@.service b/systemd/ceph-mgr@.service.in similarity index 93% rename from systemd/ceph-mgr@.service rename to systemd/ceph-mgr@.service.in index 8272ad09c29..fab1b9e8e5d 100644 --- a/systemd/ceph-mgr@.service +++ b/systemd/ceph-mgr@.service.in @@ -7,7 +7,7 @@ PartOf=ceph-mgr.target [Service] LimitNOFILE=1048576 LimitNPROC=1048576 -EnvironmentFile=-/etc/sysconfig/ceph +EnvironmentFile=-@SYSTEMD_ENV_FILE@ Environment=CLUSTER=ceph ExecStart=/usr/bin/ceph-mgr -f --cluster ${CLUSTER} --id %i --setuser ceph --setgroup ceph diff --git a/systemd/ceph-mon@.service b/systemd/ceph-mon@.service.in similarity index 95% rename from systemd/ceph-mon@.service rename to systemd/ceph-mon@.service.in index db4995fb9ca..c2566f37b95 100644 --- a/systemd/ceph-mon@.service +++ b/systemd/ceph-mon@.service.in @@ -13,7 +13,7 @@ PartOf=ceph-mon.target [Service] LimitNOFILE=1048576 LimitNPROC=1048576 -EnvironmentFile=-/etc/sysconfig/ceph +EnvironmentFile=-@SYSTEMD_ENV_FILE@ Environment=CLUSTER=ceph ExecStart=/usr/bin/ceph-mon -f --cluster ${CLUSTER} --id %i --setuser ceph --setgroup ceph ExecReload=/bin/kill -HUP $MAINPID diff --git a/systemd/ceph-osd@.service b/systemd/ceph-osd@.service.in similarity index 94% rename from systemd/ceph-osd@.service rename to systemd/ceph-osd@.service.in index 0a43ee166ba..672a10b1f14 100644 --- a/systemd/ceph-osd@.service +++ b/systemd/ceph-osd@.service.in @@ -7,7 +7,7 @@ PartOf=ceph-osd.target [Service] LimitNOFILE=1048576 LimitNPROC=1048576 -EnvironmentFile=-/etc/sysconfig/ceph +EnvironmentFile=-@SYSTEMD_ENV_FILE@ Environment=CLUSTER=ceph ExecStart=/usr/bin/ceph-osd -f --cluster ${CLUSTER} --id %i --setuser ceph --setgroup ceph ExecStartPre=/usr/lib/ceph/ceph-osd-prestart.sh --cluster ${CLUSTER} --id %i diff --git a/systemd/ceph-radosgw@.service b/systemd/ceph-radosgw@.service.in similarity index 93% rename from systemd/ceph-radosgw@.service rename to systemd/ceph-radosgw@.service.in index 3f7fcaca351..e2dac0bf3f0 100644 --- a/systemd/ceph-radosgw@.service +++ b/systemd/ceph-radosgw@.service.in @@ -7,7 +7,7 @@ PartOf=ceph-radosgw.target [Service] LimitNOFILE=1048576 LimitNPROC=1048576 -EnvironmentFile=-/etc/sysconfig/ceph +EnvironmentFile=-@SYSTEMD_ENV_FILE@ Environment=CLUSTER=ceph ExecStart=/usr/bin/radosgw -f --cluster ${CLUSTER} --name client.%i --setuser ceph --setgroup ceph PrivateDevices=yes diff --git a/systemd/ceph-rbd-mirror@.service b/systemd/ceph-rbd-mirror@.service.in similarity index 93% rename from systemd/ceph-rbd-mirror@.service rename to systemd/ceph-rbd-mirror@.service.in index 17fd7381f88..f8b15dcd401 100644 --- a/systemd/ceph-rbd-mirror@.service +++ b/systemd/ceph-rbd-mirror@.service.in @@ -7,7 +7,7 @@ PartOf=ceph-rbd-mirror.target [Service] LimitNOFILE=1048576 LimitNPROC=1048576 -EnvironmentFile=-/etc/sysconfig/ceph +EnvironmentFile=-@SYSTEMD_ENV_FILE@ Environment=CLUSTER=ceph ExecStart=/usr/bin/rbd-mirror -f --cluster ${CLUSTER} --id %i --setuser ceph --setgroup ceph ExecReload=/bin/kill -HUP $MAINPID diff --git a/systemd/rbdmap.service b/systemd/rbdmap.service.in similarity index 90% rename from systemd/rbdmap.service rename to systemd/rbdmap.service.in index 15e64abb4b0..45aa2afea0f 100644 --- a/systemd/rbdmap.service +++ b/systemd/rbdmap.service.in @@ -5,7 +5,7 @@ After=network-online.target local-fs.target Wants=network-online.target local-fs.target [Service] -EnvironmentFile=-/etc/sysconfig/ceph +EnvironmentFile=-@SYSTEMD_ENV_FILE@ Environment=RBDMAPFILE=/etc/ceph/rbdmap Type=oneshot RemainAfterExit=yes