rpm 规范文件中的 chkconfig 命令

发布于 2024-10-25 04:56:26 字数 901 浏览 5 评论 0原文

我想在 rpm 规范文件的 %install 部分使用“chkconfig --del NetworkManager”命令。如果我包含此命令,rpm 构建正常,但当我安装该 rpm 时,看起来该命令没有被执行。安装后,我使用“chkconfig --list”命令进行验证,并观察到该服务一直在运行。

这是我正在使用的规格文件。请让我知道我出错了。

%define name disable_network-manager
%define version 1.0
%define release fc

Name:       %{name}
Version:    %{version}
Release:    1%{?dist}
Summary:    Includes the script to disable Network Manager services

Group:      Development/Other
License:    GPL
URL:        www.abcd.com
Source0:    %{name}-%{version}.tar.gz
BuildRoot:  %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

%description
sample text.

%prep
%setup -q

#%build

%install
/sbin/chkconfig --del NetworkManager
rm -rf $RPM_BUILD_ROOT
install -m 0755 -d $RPM_BUILD_ROOT/usr/bin
install -m 0755 enablenm.sh $RPM_BUILD_ROOT/usr/bin/enablenm.sh

%clean
rm -rf $RPM_BUILD_ROOT


%files
/usr/bin/enablenm.sh

I would like to use 'chkconfig --del NetworkManager' command in the %install section of a rpm spec file. If I include this command the rpm is building fine but when I install that rpm, it looks that the command does not get executed. After installing I verified using 'chkconfig --list' command and observed the service is till running.

Here is spec file I am using. Please let me know ehre I am going wrong.

%define name disable_network-manager
%define version 1.0
%define release fc

Name:       %{name}
Version:    %{version}
Release:    1%{?dist}
Summary:    Includes the script to disable Network Manager services

Group:      Development/Other
License:    GPL
URL:        www.abcd.com
Source0:    %{name}-%{version}.tar.gz
BuildRoot:  %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

%description
sample text.

%prep
%setup -q

#%build

%install
/sbin/chkconfig --del NetworkManager
rm -rf $RPM_BUILD_ROOT
install -m 0755 -d $RPM_BUILD_ROOT/usr/bin
install -m 0755 enablenm.sh $RPM_BUILD_ROOT/usr/bin/enablenm.sh

%clean
rm -rf $RPM_BUILD_ROOT


%files
/usr/bin/enablenm.sh

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鲜肉鲜肉永远不皱 2024-11-01 04:56:26

好的,得到答案了。我应该从 %post 部分而不是 %install 部分发出 chkconfig 命令。

Ok, Got the answer. I should have issue the chkconfig command from the %post section instead of %install section.

夏至、离别 2024-11-01 04:56:26

实际上,我认为你的答案是错误的......

首先,你想要执行 /sbin/chkconfig NetworkManager off 将其彻底关闭; --del 将其从 chkconfig 控制中删除。

其次,这只会阻止它在您下次重新启动时运行。要停止当前正在运行的实例,您需要调用 /sbin/service NetworkManager stop

但是,是的,%install 部分不在目标计算机上运行,​​仅在构建计算机上运行。 %post 是放置上面两个命令的正确位置。

Actually, your answer is wrong I think...

First, you want to do /sbin/chkconfig NetworkManager off to turn it off cleanly; --del removes it from chkconfig control.

Secondly, that just stops it from running next time you reboot. To stop the currently running instance, you need to call /sbin/service NetworkManager stop .

But yes, the %install section is not run on the target machine, only on the build machine. %post is the proper place to put the two commands I have above.

夏了南城 2024-11-01 04:56:26

您不妨依赖网络管理器提供的任何内容。

And you might as well depend on whatever provides network manager.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文