Sophie

Sophie

distrib > Mageia > cauldron > x86_64 > by-pkgid > 2dc8c7668a0246b1b3a0983e783266f1 > scriptlet

ejabberd-18.06-1.mga7.x86_64.rpm

PREIN

/bin/sh
getent group ejabberd >/dev/null || groupadd -r ejabberd
getent passwd ejabberd >/dev/null || \
useradd -r -g ejabberd -d /var/lib/ejabberd -s /sbin/nologin -M \
-c "ejabberd" ejabberd 2>/dev/null || :


if [ $1 -gt 1 ]; then
    # we should backup DB in every upgrade
    if ejabberdctl status >/dev/null ; then
        # Use timestamp to make database restoring easier
        TIME=$(date +%Y-%m-%dT%H:%M:%S)
        BACKUPDIR=$(mktemp -d -p /var/tmp/ ejabberd-$TIME.XXXXXX)
        chown ejabberd:ejabberd $BACKUPDIR
        BACKUP=$BACKUPDIR/ejabberd-database
        ejabberdctl backup $BACKUP
        # Change ownership to root:root because ejabberd user might be
        # removed on package removal.
        chown -R root:root $BACKUPDIR
        chmod 700 $BACKUPDIR
        echo
        echo The ejabberd database has been backed up to $BACKUP.
        echo
    fi

    # fix cookie path (since ver. 2.1.0 cookie stored in /var/lib/ejabberd/spool
    # rather than in /var/lib/ejabberd
    if [ -f /var/lib/ejabberd/spool/.erlang.cookie ]; then
        cp -pu /var/lib/ejabberd/{spool/,}.erlang.cookie
        echo
        echo The ejabberd cookie file was moved again.
        echo Please delete old one from /var/lib/ejabberd/spool/.erlang.cookie
        echo
    fi
fi

PREUN

/bin/sh
/usr/share/rpm-helper/del-service ejabberd $1 ejabberd

POSTIN

/bin/sh
/usr/share/rpm-helper/add-service ejabberd $1 ejabberd 


# Create SSL certificate with default values if it doesn't exist
(cd /etc/ejabberd
if [ ! -f ejabberd.pem ]
then
    echo "Generating SSL certificate /etc/ejabberd/ejabberd.pem..."
    HOSTNAME=$(hostname -s 2>/dev/null || echo "localhost")
    DOMAINNAME=$(hostname -d 2>/dev/null || echo "localdomain")
    openssl req -new -x509 -days 365 -nodes -out ejabberd.pem \
                -keyout ejabberd.pem > /dev/null 2>&1 <<+++
.
.
.
$DOMAINNAME
$HOSTNAME
ejabberd
root@$HOSTNAME.$DOMAINNAME
+++
chown ejabberd:ejabberd ejabberd.pem
chmod 600 ejabberd.pem
fi)

POSTUN

/bin/sh
/usr/share/rpm-helper/reread-services ejabberd