From 4865831b913a7a413055237d3acf3623c421a884 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 27 Feb 2018 16:42:48 +0800 Subject: [PATCH] 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 50495ffb6da8d..5f8923b48fa20 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 cd88f328926b9..86ea87cde4e09 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 98982441ebcd9..11eb7e760d72c 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 d34bd057b7618..bd472f66b22fe 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 8272ad09c298a..fab1b9e8e5de2 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 db4995fb9ca8c..c2566f37b954e 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 0a43ee166ba73..672a10b1f1407 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 3f7fcaca351c6..e2dac0bf3f0e3 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 17fd7381f888c..f8b15dcd401a0 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 15e64abb4b0b4..45aa2afea0f26 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 -- 2.47.3