+if [ $1 -eq 0 ]; then
+ # Disable and stop the units
+ /bin/systemctl disable foobar.service foobar.socket >/dev/null 2>&1 || :
+ /bin/systemctl stop foobar.service foobar.socket >/dev/null 2>&1 || :
+fi
+
+%postun
+if [ $1 -ge 1 ] ; then
+ # On upgrade, reload init system configuration if we changed unit files
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+ # On upgrade, 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>%triggerin -- foobar < 0.47.11-1
+if /sbin/chkconfig foobar ; then
+ /bin/systemctl enable foobar.service foobar.socket >/dev/null 2>&1 || :