Don't complain about an already running CFEngine.

Move the stop section to the beginning of the pre-script, so that the
port checks come afterwards.
Make sure libvirt doesn't try to pick up the system libcurl.

It will fail later because the package will not contain libvirt.
Redmine #6581: Fix upgrade overwriting config files with templates.

This required several things:

- Almost all of the post script was only executed on install, not
  upgrade. Now most (but not all) sections are performed on both.
- The config files contain the private keys, but we don't have a
  dedicated file for them, so we need to fish them out of the config
  files, store them somewhere, and then restore them after the file
  has been upgraded.
- Lots of indentation corrections.
- Don't regenerate new SSL certificate if we already have one.
Redmine #6581: Don't perform uninstall steps if we are upgrading.

This fixes the daemons being stopped after an upgrade.

Note that this will only have an effect when we upgrade from a package
that includes this change, because the uninstall script is always
taken from the *old* package. Hence, the earliest package that this
change will have any effect for, is the second version that includes
the change, which at the time of writing is probably going to be
3.6.3.
Redmine #6581: Make sure that daemons are restarted when upgrading.