1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-23 04:23:08 +00:00
freebsd-ports/security/cyrus-sasl2/files/pkg-deinstall.in
Hajimu UMEMOTO b379403f85 check exit status of sasldblistusers2 when deinstalling
cyrus-sasl2 package.

PR:		243363
Reported by:	hsakamt__at__tsnr.com
2020-01-16 15:08:09 +00:00

51 lines
1.1 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
# Created by: hetzels@westbend.net
#set -vx
PKG_BATCH=${BATCH:=NO}
PKG_PREFIX=${PKG_PREFIX:=/usr/local}
SASLDB_NAME=%%SASLDB_NAME%%
SASLDB_NAME=${SASLDB_NAME:+${PKG_PREFIX}/etc/%%SASLDB_NAME%%}
CYRUS_USER=${CYRUS_USER:=%%CYRUS_USER%%}
CYRUS_GROUP=${CYRUS_GROUP:=%%CYRUS_GROUP%%}
# delete sasldb database
delete_sasldb() {
if [ -f ${SASLDB_NAME} ] ; then
result=$(${PKG_PREFIX}/sbin/sasldblistusers2)
if [ $? -eq 0 -a -z "${result}" ]; then
rm ${SASLDB_NAME}
if [ -f ${SASLDB_NAME}-lock ] ; then
rm ${SASLDB_NAME}-lock
fi
else
echo "WARNING: Users SASL passwords are in ${SASLDB_NAME}, keeping this file"
fi
fi
}
delete_user() {
if pw usershow ${CYRUS_USER} 2>/dev/null 1>&2; then
echo "To delete Cyrus user permanently, use 'pw userdel ${CYRUS_USER}'"
fi
if pw groupshow ${CYRUS_GROUP} 2>/dev/null 1>&2; then
echo "To delete Cyrus group permanently, use 'pw groupdel ${CYRUS_GROUP}'"
fi
}
case $2 in
DEINSTALL)
if [ -n "${SASLDB_NAME}" ]; then
delete_sasldb
fi
;;
POST-DEINSTALL)
delete_user
;;
esac