first stab at icecast password change on install

This commit is contained in:
Robb Ebright 2020-01-01 21:03:30 -05:00
parent 1c2906f5ab
commit 5d3295c86c
9 changed files with 44 additions and 0 deletions

View file

@ -79,6 +79,7 @@ class DatabaseSetup extends Setup {
$this->setNewDatabaseConnection(self::$_properties["dbname"]);
$this->checkSchemaExists();
$this->createDatabaseTables();
$this->updateIcecastPassword();
}
/**
@ -175,5 +176,25 @@ class DatabaseSetup extends Setup {
array(self::DB_NAME,));
}
}
/**
* Updates the icecast password in the database based upon the temp file created during install
* @throws AirtimeDatabaseException
*/
private function updateIcecastPassword() {
if (!file_exists(LIBRETIME_CONF_DIR . '/icecast_pass')) {
throw new AirtimeDatabaseException("The Icecast Password file was not accessible", array());
};
$icecastPass = file_get_contents(LIBRETIME_CONF_DIR . '/icecast_pass', true);
error_log($icecastPass);
$statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's1_pass' AND SET value = :icecastpass WHERE keyname = 's1_admin_pass'; "
. "UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's2_pass'; "
. "UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's2_admin_pass'; "
. "UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's3_pass'; "
. "UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's3_admin_pass'; "
. "INSERT INTO cc_pref (keystr, valstr) VALUES ('default_icecast_password', :icecastpass )");
if (!$statement->execute(array(":icecastpass" => $icecastPass))) {
throw new AirtimeDatabaseException("Could not update the database with icecast password!", array());
}
}
}