Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 29ded081c0ddcce3fdf1642661dcb55f > scriptlet

389-admin-1.1.16-1.fc15.i686.rpm

PREIN

<lua>
-- save ownership/permissions on the dirs/files that rpm changes
-- if these don't exist, the vars will be nil
dirsrvadmin_adminserv = posix.stat('/etc/dirsrv/admin-serv')
dirsrvadmin_consoleconf = posix.stat('/etc/dirsrv/admin-serv/console.conf')
-- save the run level configuration, if any
rc = os.execute('rpm --quiet -q fedora-ds-admin')
if rc == 0 then
    dirsrvadmin_exists = true
    dirsrvadmin_savelinks = {}
    for dir in posix.files("/etc/rc.d") do
        if string.find(dir, "rc%d.d") then
--          print("looking in /etc/rc.d/"..dir)
            for link in posix.files("/etc/rc.d/"..dir) do
                if string.find(link, "[SK]%d%ddirsrv-admin") then
                    fullname = "/etc/rc.d/"..dir.."/"..link
                    linked = posix.readlink(fullname)
--                  print(fullname.." is linked to "..linked)
                    dirsrv_savelinks[fullname] = linked
                end
            end
        end
    end
end

PREUN

/bin/sh
if [ $1 = 0 ]; then
        /sbin/service dirsrv-admin stop >/dev/null 2>&1 || :
        /sbin/chkconfig --del dirsrv-admin
fi

POSTIN

<lua>
-- do the usual daemon post setup stuff
os.execute('/sbin/chkconfig --add dirsrv-admin')
os.execute('/sbin/ldconfig')
-- restore permissions if upgrading
if dirsrvadmin_adminserv then
    posix.chmod('/etc/dirsrv/admin-serv', dirsrvadmin_adminserv.mode)
    posix.chown('/etc/dirsrv/admin-serv', dirsrvadmin_adminserv.uid, dirsrvadmin_adminserv.gid)
end
if dirsrvadmin_consoleconf then
    posix.chmod('/etc/dirsrv/admin-serv/console.conf', dirsrvadmin_consoleconf.mode)
    posix.chown('/etc/dirsrv/admin-serv/console.conf', dirsrvadmin_consoleconf.uid, dirsrvadmin_consoleconf.gid)
end

POSTUN

/bin/sh
/sbin/ldconfig

POSTTRANS

<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 dirsrvadmin_savelinks then
    for fullpath,link in pairs(dirsrvadmin_savelinks) do
        posix.symlink(link,fullpath)
--        print("posttrans - restored run level "..fullpath.." to "..link)
    end
end
if dirsrvadmin_exists then
    os.execute('/sbin/service dirsrv-admin start >/dev/null 2>&1')
end