Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chkconfig command in rpm spec file

Tags:

rpm

rpmbuild

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
like image 448
Souvik Avatar asked Mar 21 '11 09:03

Souvik


2 Answers

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

like image 137
Souvik Avatar answered Nov 01 '22 18:11

Souvik


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.

like image 27
Aaron D. Marasco Avatar answered Nov 01 '22 17:11

Aaron D. Marasco