Qt apt-get installation script for multiple Linux Distributions

I'm trying to build a Qt install script for multiple Linux distributions. I know that Ubuntu uses "apt-get" repository and RHEL and CentOS use "yum" repository. What's the best way to detect the distribution in my script.

I was thinking something like the following just wanted to know the best way to detect the distro.