rpm: compatibility with older systemd versions

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I5674b74e7b2ac06ade0b34b33513d2100105b10d
pull/6353/head
Andras Timar 2023-05-14 23:31:38 +02:00
parent 39e83470a8
commit fc19d7cb00
1 changed files with 10 additions and 3 deletions

View File

@ -97,9 +97,16 @@ getent passwd cool >/dev/null || useradd -g cool -r cool -d /opt/cool -s /bin/ba
setcap cap_fowner,cap_chown,cap_mknod,cap_sys_chroot=ep /usr/bin/coolforkit
setcap cap_sys_admin=ep /usr/bin/coolmount
if [ -f /etc/loolwsd/loolwsd.xml ]; then /usr/bin/coolconfig migrateconfig --write; fi
# systemd in RHEL 7 does not understand these options
if grep -q -F 'REDHAT_SUPPORT_PRODUCT_VERSION="7"' /etc/os-release; then
sed -i "/^ReadWritePaths/d;/^ProtectControlGroups/d;/^ProtectSystem/d" /usr/lib/systemd/system/coolwsd.service
# compatibility with older systemd versions
SYSTEMD_VERSION=$(busctl --system get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Version | grep -Eo [0-9]{3})
if [[ "$SYSTEMD_VERSION" -lt "228" ]]; then
sed -i "/^ProtectSystem/d" /usr/lib/systemd/system/coolwsd.service
fi
if [[ "$SYSTEMD_VERSION" -lt "231" ]]; then
sed -i "/^ReadWritePaths/d" /usr/lib/systemd/system/coolwsd.service
fi
if [[ "$SYSTEMD_VERSION" -lt "232" ]]; then
sed -i "/^ProtectControlGroups/d" /usr/lib/systemd/system/coolwsd.service
fi
if [ $1 -eq 1 ] ; then