chkconfig command in rpm spec file
Asked Answered
A

3

10

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
Antitype answered 21/3, 2011 at 9:4 Comment(1)
Basically I would like to create an rpm package which will disable network manager (chkconfig --del NetworkMnager). Please advise the correct spec file.Antitype
A
8

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

Antitype answered 21/3, 2011 at 10:26 Comment(0)
U
2

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.

Urbanize answered 9/7, 2011 at 14:5 Comment(0)
S
-1

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

Schonfeld answered 7/4, 2014 at 17:7 Comment(1)
The RPM installation/uninstallation will fail if /etc/init.d/NetworkManager is not present, this service file is part of the Network Manager package, so your RPM has a runtime dependency on the Network Manager package.Schonfeld

© 2022 - 2024 — McMap. All rights reserved.