Rewrite the check_kernel script and implement support for RHEL, Fedora and Ubuntu.

Fixes #6332