Sophie

Sophie

distrib > Fedora > 18 > x86_64 > media > updates > by-pkgid > ba36abdc071f5fd5a3683aa3d1dd1ac3 > scriptlet

abrt-2.1.9-1.fc18.x86_64.rpm

PREIN

/bin/sh
#uidgid pair 173:173 reserved in setup rhbz#670231
getent group abrt >/dev/null || groupadd -f -g 173 --system abrt
getent passwd abrt >/dev/null || useradd --system -g abrt -u 173 -d /etc/abrt -s /sbin/nologin abrt

OLD_LOCATION="/var/spool/abrt"
NEW_LOCATION="/var/tmp/abrt"
# $1 == 1 if install; 2 if upgrade
if [ "$1" -eq 2 ]
then
    test -d "$OLD_LOCATION" || exit 0
    mkdir -p "$NEW_LOCATION"

    #restorecon "$NEW_LOCATION"
    find "$OLD_LOCATION" -maxdepth 1 -type f -exec cp '{}' "$NEW_LOCATION" \;

    for DD in `find "$OLD_LOCATION" -maxdepth 1 -type d`
    do
        # skip dump location self
        if [ "$DD" == "$OLD_LOCATION" ]; then
            continue
        fi

        # skip symlinks
        if [ -L "$DD" ]; then
            continue
        fi

        # check if time element exists, if so then consider a directory as dump
        # directory and move it to the new location
        if [ -f "$DD/time" ]; then
            NEW_DD="$NEW_LOCATION/"`basename $DD`

            # to be sure we do not override anything
            if [ -d "$NEW_DD" ]; then
                continue
            fi

            if cp --recursive -- "$DD" "$NEW_DD"; then
                # owner of dump dir is identified by his group
                # so get the owner of dump dir
                OWNER_GID=`stat -c "%g" "$DD"`

                # use group's user in case where group contains only single user
                if [ $(getent passwd | cut -f3,4,5 -d: | grep -c ":$OWNER_GID:") -eq 1 ]; then
                    OWNER_UID=`getent passwd | cut -f3,4,5 -d: | grep ":$OWNER_GID:" | cut -f1 -d:`
                else
                    # otherwise get owner from dd's uid element
                    OWNER_UID=`cat "$NEW_DD/uid"`
                fi

                getent passwd "$OWNER_UID" >/dev/null || {
                    # if user doesn't exist pass the ownership to root
                    OWNER_UID=0
                }

                # set new schema of ownership
                chown --recursive "$OWNER_UID":abrt "$NEW_DD" && {
                    chmod 770 "$NEW_DD"
                    find "$NEW_DD" -type d -exec chmod 770 '{}' \;
                    find "$NEW_DD" -type f -exec chmod 660 '{}' \;
                }
            fi
        fi
    done
fi

# doesn't mather if it fails or not for any reason
if which restorecon 1>/dev/null 2>&1; then
    restorecon -R "$NEW_LOCATION" 1>/dev/null 2>&1 || true
fi
exit 0

PREUN

/bin/sh

if [ $1 -eq 0 ] ; then 
        # Package removal, not upgrade 
        /usr/bin/systemctl --no-reload disable abrtd.service > /dev/null 2>&1 || : 
        /usr/bin/systemctl stop abrtd.service > /dev/null 2>&1 || : 
fi

POSTIN

/bin/sh
# $1 == 1 if install; 2 if upgrade

if [ $1 -eq 1 ] ; then 
        # Initial installation 
        /usr/bin/systemctl preset abrtd.service >/dev/null 2>&1 || : 
fi

POSTUN

/bin/sh

/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : 
if [ $1 -ge 1 ] ; then 
        # Package upgrade, not uninstall 
        /usr/bin/systemctl try-restart abrtd.service >/dev/null 2>&1 || : 
fi

POSTTRANS

/bin/sh
# update the old problem dirs to contain "type" element
abrtdir=$(grep "DumpLocation" /etc/abrt/abrt.conf | cut -d'=' -f2 | tr -d ' '); cd $abrtdir 2>/dev/null && for i in `find . -name "analyzer" 2>/dev/null`; do len=${#i};cp "$i" "${i:0:$len-9}/type"; done; for i in `find "$abrtdir" -mindepth 1 -maxdepth 1 -type d`; do chown `stat --format=%U:abrt $i` $i/*; done
service abrtd condrestart >/dev/null 2>&1 || :