Fix commands for apt package manager.

Force yes when performing apt-get install. Even though we provide
noninteractive, apt still prompts in some situations.

Grep dpkg-query when checking if package is installed. In some cases,
dpkg -l will exit 0 if the package exists, but is not in an installed
state.