Merge pull request #933 from Robbt/icecast-password
change default icecast password automatically during install
This commit is contained in:
commit
5cfa57234b
|
@ -79,6 +79,7 @@ class DatabaseSetup extends Setup {
|
|||
$this->setNewDatabaseConnection(self::$_properties["dbname"]);
|
||||
$this->checkSchemaExists();
|
||||
$this->createDatabaseTables();
|
||||
$this->updateIcecastPassword();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,5 +176,82 @@ 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());
|
||||
};
|
||||
$icecast_pass_txt = file(LIBRETIME_CONF_DIR . '/icecast_pass');
|
||||
$icecast_pass = $icecast_pass_txt[0];
|
||||
$icecast_pass = str_replace(PHP_EOL, '', $icecast_pass);
|
||||
$statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's1_pass'");
|
||||
$statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR);
|
||||
try {
|
||||
$statement->execute();
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
print "Error!: " . $ex->getMessage() . "<br />";
|
||||
}
|
||||
$statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's1_admin_pass'");
|
||||
$statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR);
|
||||
try {
|
||||
$statement->execute();
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
print "Error!: " . $ex->getMessage() . "<br />";
|
||||
}
|
||||
$statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's2_pass'");
|
||||
$statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR);
|
||||
try {
|
||||
$statement->execute();
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
print "Error!: " . $ex->getMessage() . "<br />";
|
||||
}
|
||||
$statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's2_admin_pass'");
|
||||
$statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR);
|
||||
try {
|
||||
$statement->execute();
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
print "Error!: " . $ex->getMessage() . "<br />";
|
||||
}
|
||||
|
||||
$statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's3_pass'");
|
||||
$statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR);
|
||||
try {
|
||||
$statement->execute();
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
print "Error!: " . $ex->getMessage() . "<br />";
|
||||
}
|
||||
$statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's3_admin_pass'");
|
||||
$statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR);
|
||||
try {
|
||||
$statement->execute();
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
print "Error!: " . $ex->getMessage() . "<br />";
|
||||
}
|
||||
$statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's1_admin_pass'");
|
||||
$statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR);
|
||||
try {
|
||||
$statement->execute();
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
print "Error!: " . $ex->getMessage() . "<br />";
|
||||
}
|
||||
$statement = self::$dbh->prepare("INSERT INTO cc_pref (keystr, valstr) VALUES ('default_icecast_password', :icecastpass )");
|
||||
$statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR);
|
||||
try {
|
||||
$statement->execute();
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
print "Error!: " . $ex->getMessage() . "<br />";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
14
install
14
install
|
@ -900,8 +900,19 @@ if [ "$icecast" = "t" ]; then
|
|||
icecast_unit_name="icecast2"
|
||||
if [ "$dist" != "centos" ]; then
|
||||
sed -i 's/ENABLE=false/ENABLE=true/g' /etc/default/icecast2
|
||||
icecast_config="/etc/icecast2/icecast.xml"
|
||||
else
|
||||
icecast_unit_name="icecast"
|
||||
icecast_config="/etc/icecast.xml"
|
||||
fi
|
||||
# only update icecast password if
|
||||
if [ ! -f "/etc/airtime/airtime.conf" ]; then
|
||||
icecast_pass=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12};)
|
||||
echo $icecast_pass > /tmp/icecast_pass
|
||||
loud "\n New install detected setting icecast password to random value."
|
||||
xmlstarlet ed --inplace -u /icecast/authentication/source-password -v $icecast_pass $icecast_config
|
||||
xmlstarlet ed --inplace -u /icecast/authentication/relay-password -v $icecast_pass $icecast_config
|
||||
xmlstarlet ed --inplace -u /icecast/authentication/admin-password -v $icecast_pass $icecast_config
|
||||
fi
|
||||
# restart in case icecast was already started (like is the case on debian)
|
||||
systemInitCommand restart ${icecast_unit_name}
|
||||
|
@ -1107,9 +1118,12 @@ if [ ! -d "/etc/airtime" ]; then
|
|||
|
||||
verbose "\n * Creating /etc/airtime/ directory..."
|
||||
mkdir /etc/airtime
|
||||
# need to copy the icecast_pass from temp to /etc/airtime so installer can read it
|
||||
cp /tmp/icecast_pass /etc/airtime/icecast_pass
|
||||
fi
|
||||
|
||||
|
||||
|
||||
chown -R ${web_user}:${web_user} /etc/airtime
|
||||
|
||||
if [ ! -d "/srv/airtime" ]; then
|
||||
|
|
|
@ -67,3 +67,5 @@ liquidsoap
|
|||
libopus0
|
||||
|
||||
systemd-sysv
|
||||
|
||||
xmlstarlet
|
||||
|
|
|
@ -63,3 +63,5 @@ libopus0
|
|||
|
||||
sysvinit
|
||||
sysvinit-utils
|
||||
|
||||
xmlstarlet
|
||||
|
|
|
@ -67,3 +67,5 @@ liquidsoap
|
|||
libopus0
|
||||
|
||||
systemd-sysv
|
||||
|
||||
xmlstarlet
|
||||
|
|
|
@ -81,3 +81,5 @@ build-essential
|
|||
libssl-dev
|
||||
libffi-dev
|
||||
python-dev
|
||||
|
||||
xmlstarlet
|
||||
|
|
|
@ -70,3 +70,5 @@ liquidsoap-plugin-pulseaudio
|
|||
liquidsoap-plugin-taglib
|
||||
liquidsoap-plugin-voaacenc
|
||||
liquidsoap-plugin-vorbis
|
||||
|
||||
xmlstarlet
|
||||
|
|
|
@ -81,3 +81,5 @@ build-essential
|
|||
libssl-dev
|
||||
libffi-dev
|
||||
python-dev
|
||||
|
||||
xmlstarlet
|
||||
|
|
|
@ -76,3 +76,5 @@ build-essential
|
|||
libssl-dev
|
||||
libffi-dev
|
||||
python-dev
|
||||
|
||||
xmlstarlet
|
||||
|
|
|
@ -86,7 +86,8 @@ yum install -y \
|
|||
policycoreutils-python \
|
||||
python-celery \
|
||||
python2-pika \
|
||||
lsof
|
||||
lsof \
|
||||
xmlstarlet
|
||||
|
||||
# for pip ssl install
|
||||
yum install -y \
|
||||
|
|
Loading…
Reference in New Issue