do not create /var/run/dirsrv - setup will create it instead

do not create /var/run/dirsrv - setup will create it instead
remove the fedora-ds initscript upgrade stuff - we do not support that anymore
convert the remaining lua stuff to plain old shell script
Reviewed by: nkinder, nhosoi (Thanks!)
This commit is contained in:
Rich Megginson 2011-02-24 15:44:15 -07:00
parent df3a6cc703
commit 31909e6aa2

View File

@ -16,7 +16,7 @@
Summary: 389 Directory Server (base)
Name: 389-ds-base
Version: 1.2.8
Release: %{?relprefix}3%{?prerel}%{?dist}
Release: %{?relprefix}4%{?prerel}%{?dist}
License: GPLv2 with exceptions
URL: http://port389.org/
Group: System Environment/Daemons
@ -150,58 +150,13 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/plugins/*.la
# make sure perl scripts have a proper shebang
sed -i -e 's|#{{PERL-EXEC}}|#!/usr/bin/perl|' $RPM_BUILD_ROOT%{_datadir}/%{pkgname}/script-templates/template-*.pl
%clean
rm -rf $RPM_BUILD_ROOT
%pre -p <lua>
-- see if fedora-ds-base exists - if so, save the run level configuration
-- and set a flag that tells us to restore that config in %posttrans
-- and restart the server
-- we can get rid of this code once Fedora 11 becomes obsolete
rc = os.execute('rpm --quiet -q fedora-ds-base')
if rc == 0 then
%{pkgname}_exists = true
%{pkgname}_savelinks = {}
for dir in posix.files("%{_sysconfdir}/rc.d") do
if string.find(dir, "rc%d.d") then
-- print("looking in %{_sysconfdir}/rc.d/"..dir)
for link in posix.files("%{_sysconfdir}/rc.d/"..dir) do
if string.find(link, "[SK]%d%d%{pkgname}") then
fullname = "%{_sysconfdir}/rc.d/"..dir.."/"..link
linked = posix.readlink(fullname)
-- print(fullname.." is linked to "..linked)
%{pkgname}_savelinks[fullname] = linked
end
end
end
end
end
%post -p <lua>
os.execute('/sbin/chkconfig --add %{pkgname}')
os.execute('/sbin/ldconfig')
os.execute('/sbin/chkconfig --add %{pkgname}-snmp')
-- this has been problematic - if this directory
-- does not exist, the server will silently fail to
-- start - however, if the user has already created
-- it, we don't want to overwrite the permissions
-- on it - so we can't list it explicitly in the
-- files section - we list it as a ghost so that
-- it will be removed when the rpm is removed
if not posix.access("%{_localstatedir}/run/%{pkgname}") then
posix.mkdir("%{_localstatedir}/run/%{pkgname}")
end
-- since posttrans is not passed the upgrade status, we get
-- it here
if (arg[2] > 1) or %{pkgname}_exists then
-- print("in %{pkgname} post - upgrading")
%{pkgname}_upgrading = true
else
-- print("in %{pkgname} post - installing")
%{pkgname}_upgrading = false
end
%post
/sbin/chkconfig --add %{pkgname}
/sbin/ldconfig
/sbin/chkconfig --add %{pkgname}-snmp
%preun
if [ $1 = 0 ]; then # Final removal
@ -213,57 +168,49 @@ fi
%postun
/sbin/ldconfig
if [ $1 = 0 ]; then # Final removal
rm -rf /var/run/%{pkgname}
fi
%posttrans -p <lua>
-- if we saved the run level configuration in %pre, restore it now
-- we can get rid of this code once Fedora 11 becomes obsolete
if %{pkgname}_savelinks then
for fullpath,link in pairs(%{pkgname}_savelinks) do
posix.symlink(link,fullpath)
-- print("posttrans - restored run level "..fullpath.." to "..link)
end
end
if %{pkgname}_upgrading then
instbase = "%{_sysconfdir}/%{pkgname}"
-- print("posttrans - upgrading - looking for instances in "..instbase)
-- find all instances
instances = {} -- instances that require a restart after upgrade
for dir in posix.files(instbase) do
-- print("dir="..dir)
if string.find(dir,"^slapd-") and not string.find(dir,"\.removed$") then
inst = string.gsub(dir,"^slapd[-]", "")
-- print("found instance "..inst.." getting status")
rc = os.execute('/sbin/service %{pkgname} status '..inst..' >/dev/null 2>&1')
-- if instance is running, we must restart it after upgrade
if rc == 0 then
instances[inst] = inst
-- print("instance "..inst.." is running")
-- else
-- print("instance "..inst.." is shutdown")
end
end
end
-- shutdown all instances
-- print("shutting down all instances . . .")
os.execute('/sbin/service %{pkgname} stop > /dev/null 2>&1')
-- do the upgrade
-- print("upgrading instances . . .")
os.execute('%{_sbindir}/setup-ds.pl -l /dev/null -u -s General.UpdateMode=offline > /dev/null 2>&1')
-- restart instances that require it
for inst,dummy in pairs(instances) do
-- print("restarting instance "..inst)
os.execute('/sbin/service %{pkgname} start '..inst..' >/dev/null 2>&1')
end
-- restart the snmp subagent if needed
os.execute('/sbin/service %{pkgname}-snmp condrestart > /dev/null 2>&1')
end
-- if we upgraded from fedora to 389, the upgrade will shutdown
-- all old running instances, so we have to start them here
if %{pkgname}_exists then
-- print("restarting all instances due to package rename")
os.execute('/sbin/service %{pkgname} start >/dev/null 2>&1')
end
%posttrans
instbase="%{_sysconfdir}/%{pkgname}"
# echo posttrans - upgrading - looking for instances in $instbase
# find all instances
instances="" # instances that require a restart after upgrade
ninst=0 # number of instances found in total
for dir in $instbase/slapd-* ; do
# echo dir = $dir
if [ ! -d "$dir" ] ; then continue ; fi
case "$dir" in *.removed) continue ;; esac
basename=`basename $dir`
inst=`echo $basename | sed -e 's/slapd-//g'`
# echo found instance $inst - getting status
if /sbin/service %{pkgname} status $inst >/dev/null 2>&1 ; then
# echo instance $inst is running
instances="$instances $inst"
else
# echo instance $inst is not running
:
fi
ninst=`expr $ninst + 1`
done
if [ $ninst -eq 0 ] ; then
exit 0 # have no instances to upgrade - just skip the rest
fi
# shutdown all instances
# echo shutting down all instances . . .
/sbin/service %{pkgname} stop > /dev/null 2>&1
# do the upgrade
# echo upgrading instances . . .
%{_sbindir}/setup-ds.pl -l /dev/null -u -s General.UpdateMode=offline > /dev/null 2>&1
# restart instances that require it
for inst in $instances ; do
# echo restarting instance $inst
/sbin/service %{pkgname} start $inst >/dev/null 2>&1
done
# restart the snmp subagent if needed
/sbin/service %{pkgname}-snmp condrestart > /dev/null 2>&1
exit 0
%files
%defattr(-,root,root,-)
@ -301,6 +248,11 @@ end
%{_libdir}/pkgconfig/*
%changelog
* Thu Feb 24 2011 Rich Megginson <rmeggins@redhat.com> - 1.2.8-0.4.a3
- do not create /var/run/dirsrv - setup will create it instead
- remove the fedora-ds initscript upgrade stuff - we do not support that anymore
- convert the remaining lua stuff to plain old shell script
* Wed Feb 9 2011 Rich Megginson <rmeggins@redhat.com> - 1.2.8-0.3.a3
- 1.2.8.a3 release - git tag 389-ds-base-1.2.8.a3
- Bug 675320 - empty modify operation with repl on or lastmod off will crash server