The dr CLI has a new site:installed command, with the alias is-installed. It works before Drupal is installed. It exits with 0 when the site is installed, 1 when it is not, and 2 when the database cannot be checked. Use --quiet to only set the exit code.
if vendor/bin/dr is-installed --quiet; then
# Update the site.
else
vendor/bin/dr install standard
fiA site whose installation stopped partway through does not count as installed.
Code can use the new \Drupal\Core\Installer\InstallerKernel::isSiteInstalled() method. It returns TRUE when the current site's settings.php has database connection information and the installer has finished. It throws an exception when the database cannot be checked. It does not need a booted kernel.
use Drupal\Core\Installer\InstallerKernel;
if (InstallerKernel::isSiteInstalled()) {
// ...
}
To check whether the installer is running in the current request, keep using InstallerKernel::installationAttempted().