PREIN
/bin/sh
/usr/sbin/useradd -c "Network UPS Tools" -u 57 \
-s /bin/false -r -d /var/lib/ups nut 2> /dev/null || :
/usr/sbin/usermod -G dialout nut
# do not let upsmon run during upgrade rhbz#916472
# phase 1: stop upsmon before upsd changes
if [ "$1" = "2" ]; then
rm -f /var/run/nut/nut-restart-after-rpm-install
/bin/systemctl is-active nut-monitor.service >/dev/null 2>&1 && touch /var/run/nut/nut-restart-after-rpm-install ||:
/bin/systemctl stop nut-monitor.service >/dev/null 2>&1
fi
PREUN
/bin/sh
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
systemctl --no-reload disable nut-driver.service nut-server.service > /dev/null 2>&1 || :
systemctl stop nut-driver.service nut-server.service > /dev/null 2>&1 || :
fi
POSTIN
/bin/sh
/sbin/ldconfig
udevadm control --reload ||:
if [ $1 -eq 1 ] ; then
# Initial installation
systemctl preset nut-driver.service nut-server.service >/dev/null 2>&1 || :
fi
POSTUN
/bin/sh
/sbin/ldconfig
systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
systemctl try-restart nut-driver.service nut-server.service >/dev/null 2>&1 || :
fi
POSTTRANS
/bin/sh
# phase 2: start upsmon again
if [ -e /var/run/nut/nut-restart-after-rpm-install ]; then
/bin/systemctl restart nut-monitor.service >/dev/null 2>&1 || :
rm -f /var/run/nut/nut-restart-after-rpm-install
else
# maybe we did not stop it - if we reinstalled just nut-client
/bin/systemctl try-restart nut-monitor.service >/dev/null 2>&1 || :
fi