+if [ $1 -eq 0 ]; then
+ # On uninstall (not upgrade), disable and stop the units
+ /bin/systemctl --no-reload disable foobar.service foobar.socket >/dev/null 2>&1 || :
+ /bin/systemctl stop foobar.service foobar.socket >/dev/null 2>&1 || :
+fi
+
+%postun
+# Reload init system configuration, to make systemd honour changed
+# or deleted unit files
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # On upgrade (not uninstall), optionally, restart the daemon
+ /bin/systemctl try-restart foobar.service >/dev/null 2>&1 || :
+fi</programlisting>
+
+ <para>Depending on whether your service should
+ or should not be started/stopped/restarted
+ during package installation, deinstallation or
+ upgrade, a different set of commands may be
+ specified. See
+ <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+ for details.</para>
+
+ <para>To facilitate upgrades from a package
+ version that shipped only SysV init scripts to
+ a package version that ships both a SysV init
+ script and a native systemd service file, use
+ a fragment like the following:</para>
+
+ <programlisting>%triggerun -- foobar < 0.47.11-1
+if /sbin/chkconfig --level 5 foobar ; then
+ /bin/systemctl --no-reload enable foobar.service foobar.socket >/dev/null 2>&1 || :