[rhn-users] shutdown services when upgrading

Doerbeck, Christoph Christoph.Doerbeck at FMR.COM
Sat Jun 11 12:00:29 UTC 2005


$1 is a shell command line argument which you can test in 
the script areas of the rpm to determine how many copies of
the rpm will remain at the completion of the install/removal.
Here is a comment that I stick into all the rpms I develop.
I make VERY heavy use of this.

##
## test $1 to determine what to do on 
##          $1 = 0 means full package erase (0 versions left)
##          $1 = 1 means upgrade (1 version still installed after this
erase)
##

So for example, it's a mechanism to determine from within your
rpm, if this is an upgrade (rpm -U) or a erase (rpm -e).  This is 
important when considering that a package removal runs  %postun 
scripts AFTER the new package has already been installed.  You
don't want it to go removing things the new package needs.

Hope that helps.

Christoph 


-----Original Message-----
From: Rich Graves [mailto:rcgraves at brandeis.edu] 
Sent: Friday, June 10, 2005 5:11 PM
To: Red Hat Network Users List
Subject: Re: [rhn-users] shutdown services when upgrading


On Fri, 10 Jun 2005, Jim Pelton wrote:

> So I'm trying to develop a good strategy for updating (with up2date) 
> some web servers and several other production level boxes.  My
question 
> arose out of the need to update httpd on the web farm.  If I go ahead 
> and update, will the rpm %pre and %post scripts (or whatever does this

> type of thing) shutdown the httpd service, update and then bring it
back 
> up?

You can choose not to run scripts by giving rpm the --noscripts option.

I'm not entirely sure what the $1 below refers to. I do know that just
about every time I update bind, it has done the wrong thing, both
stopping
the service and removing it with chkconfig. So I'd test it if I were
you.

[root]# up2date --get httpd
[root]# -qp --scripts /var/spool/up2date/httpd-2.0.46-46.ent.i386.rpm
preinstall scriptlet (using /bin/sh):
# Add the "apache" user
/usr/sbin/useradd -c "Apache" -u 48 \
        -s /sbin/nologin -r -d /var/www apache 2> /dev/null || :

# Prevent removal of index.html on upgrades from 1.3
postinstall scriptlet (using /bin/sh):
# Register the httpd service
/sbin/chkconfig --add httpd
preuninstall scriptlet (using /bin/sh):
if [ $1 = 0 ]; then
        /sbin/service httpd stop > /dev/null 2>&1
        /sbin/chkconfig --del httpd
fi
-- 
Rich Graves <rcgraves at brandeis.edu>
UNet Systems Administrator

_______________________________________________
rhn-users mailing list
rhn-users at redhat.com
https://www.redhat.com/mailman/listinfo/rhn-users




More information about the rhn-users mailing list