nicer CLI install

This commit is contained in:
Shish 2024-01-15 21:45:55 +00:00
parent 4c8029fce6
commit c0bb34fbf1

View file

@ -40,10 +40,14 @@ function install()
$dsn = get_dsn(); $dsn = get_dsn();
if ($dsn) { if ($dsn) {
do_install($dsn); do_install($dsn);
} else {
if(PHP_SAPI == 'cli') {
print("INSTALL_DSN needs to be set for CLI installation\n");
} else { } else {
ask_questions(); ask_questions();
} }
} }
}
function get_dsn() function get_dsn()
{ {
@ -308,11 +312,16 @@ function write_config($dsn)
} }
if (file_put_contents("data/config/shimmie.conf.php", $file_content, LOCK_EX)) { if (file_put_contents("data/config/shimmie.conf.php", $file_content, LOCK_EX)) {
if(PHP_SAPI == 'cli') {
print("Installation Successful\n");
exit(0);
} else {
header("Location: index.php?flash=Installation%20complete"); header("Location: index.php?flash=Installation%20complete");
die_nicely( die_nicely(
"Installation Successful", "Installation Successful",
"<p>If you aren't redirected, <a href=\"index.php\">click here to Continue</a>." "<p>If you aren't redirected, <a href=\"index.php\">click here to Continue</a>."
); );
}
} else { } else {
$h_file_content = htmlentities($file_content); $h_file_content = htmlentities($file_content);
throw new InstallerException( throw new InstallerException(