rpm 规范文件中的 chkconfig 命令
我想在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的,得到答案了。我应该从 %post 部分而不是 %install 部分发出 chkconfig 命令。
Ok, Got the answer. I should have issue the chkconfig command from the %post section instead of %install section.
实际上,我认为你的答案是错误的......
首先,你想要执行
/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 fromchkconfig
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.您不妨依赖网络管理器提供的任何内容。
And you might as well depend on whatever provides network manager.