Debian – Is it possible to stop dpkg-reconfigure restarting services

automated-installdebiandpkg

I'm building an install key for a Debian based system. The install key basically copies a disk image onto the system and then in a chroot installs a number of packages that are copied onto the install key during the build process.

One of the things the install key does is wipe the existing ssh keys (so we don't create a bunch of "identical" ssh servers). To try and stick with the debian way of doing things I run dpkg-reconfigure openssh-server to regenerate the keys but at the end of the reconfigure it attempts to restart the server which of course isn't running in the install key chroot.

Is it possible to tell debconf to reconfigure but don't restart services?

Best Answer

What you are asking isn't a function of debconf or dpkg-reconfigure, directly. If you download the .deb for openssh-server and extract the files from control.tar.gz you will see that the 'postinst' script executes invoke-rc.d or /etc/init.d/ssh:

Line 418:

setup_init() {
  if [ -x /etc/init.d/ssh ]; then
    update-rc.d ssh start 16 2 3 4 5 . stop 84 1 . >/dev/null
    if [ -x /usr/sbin/invoke-rc.d ]; then
      invoke-rc.d ssh restart
    else
      /etc/init.d/ssh restart
    fi
  fi
}