在rpm安装时启用systemd服务

问题描述 投票:1回答:1

我正在尝试构建一个rpm包,以正确的方式启用systemd服务。

在我的rpm spec文件中,我添加了:

%{?systemd_requires}
BuildRequires: systemd

...

%postun
%systemd_postun yeah.service

我的rpm拷贝在/ usr / lib / systemd / system / yeah.service文件中。

但是在安装包之后,该服务仍然是禁用的:

root@ansible-1:1:~# systemctl status yeah
Unit yeah.service could not be found.
root@ansible-1:1:~# rpm -Uvh /home/intersec/delivery/yeah.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:yeah################################# [100%]
root@ansible-1:1:~# systemctl status yeah
● yeah.service - Yeah
   Loaded: loaded (/usr/lib/systemd/system/yeah.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

怎么了?

拉乌尔

centos7 systemd rpm-spec
1个回答
1
投票

卸载后运行%postun脚本。我想你也应该补充一下

%post
%systemd_post yeah.service
© www.soinside.com 2019 - 2024. All rights reserved.