Rewrite of the chroot script

Not functional yet but getting there. We are now running the activate
and deactive code inside a single sudo process. This is to avoid asking
the root password multiple times.

Lots of code cleanups while at it.