PREIN
/bin/sh
# Add the dirsrv user and group accounts
/usr/share/rpm-helper/add-user 389-ds-base $1 dirsrv /var/lib/dirsrv /sbin/nologin
/usr/share/rpm-helper/add-group 389-ds-base $1 dirsrv /var/lib/dirsrv
PREUN
/bin/sh
if [ $1 -eq 0 ]; then # Final removal
# Package removal, not upgrade
# remove instance specific service files/links
rm -rf /etc/systemd/system/dirsrv.target.wants/* > /dev/null 2>&1 || :
fi
POSTIN
/bin/sh
output=/dev/null
# We need to do this because the BS doesn't accept the way Fedora (upstream) and others do it.
if [ $1 = 1 ] ; then
mkdir -p /etc/systemd/system/dirsrv.target.wants
fi
# reload to pick up any changes to systemd files
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
# reload to pick up any shared lib changes
# find all instances
instances="" # instances that require a restart after upgrade
ninst=0 # number of instances found in total
if [ -n "$DEBUGPOSTTRANS" ] ; then
output=$DEBUGPOSTTRANS
fi
echo looking for services in /etc/systemd/system/dirsrv.target.wants/* >> $output 2>&1 || :
for service in /etc/systemd/system/dirsrv.target.wants/* ; do
if [ ! -f "$service" ] ; then continue ; fi # in case nothing matches
inst=`echo $service | sed -e 's,/etc/systemd/system/dirsrv.target.wants/,,'`
echo found instance $inst - getting status >> $output 2>&1 || :
if /usr/bin/systemctl -q is-active $inst ; then
echo instance $inst is running >> $output 2>&1 || :
instances="$instances $inst"
else
echo instance $inst is not running >> $output 2>&1 || :
fi
ninst=`expr $ninst + 1`
done
if [ $ninst -eq 0 ] ; then
echo no instances to upgrade >> $output 2>&1 || :
exit 0 # have no instances to upgrade - just skip the rest
fi
# shutdown all instances
echo shutting down all instances . . . >> $output 2>&1 || :
for inst in $instances ; do
echo stopping instance $inst >> $output 2>&1 || :
/bin/systemctl stop $inst >> $output 2>&1 || :
done
echo remove pid files . . . >> $output 2>&1 || :
/usr/bin/rm -f /run/dirsrv*.pid /run/dirsrv*.startpid
# do the upgrade
echo upgrading instances . . . >> $output 2>&1 || :
DEBUGPOSTSETUPOPT=`/usr/bin/echo $DEBUGPOSTSETUP | /usr/bin/sed -e "s/[^d]//g"`
if [ -n "$DEBUGPOSTSETUPOPT" ] ; then
/usr/sbin/setup-ds.pl -l $output -$DEBUGPOSTSETUPOPT -u -s General.UpdateMode=offline >> $output 2>&1 || :
else
/usr/sbin/setup-ds.pl -l $output -u -s General.UpdateMode=offline >> $output 2>&1 || :
fi
# restart instances that require it
for inst in $instances ; do
echo restarting instance $inst >> $output 2>&1 || :
/usr/bin/systemctl start $inst >> $output 2>&1 || :
done
POSTUN
/bin/sh
if [ $1 = 0 ]; then # Final removal
rm -rf /run/dirsrv
fi
/usr/share/rpm-helper/del-user 389-ds-base $1 dirsrv
/usr/share/rpm-helper/del-group 389-ds-base $1 dirsrv