diff --git a/airtime_mvc/public/setup/database-setup.php b/airtime_mvc/public/setup/database-setup.php
index 17038ac74..a3e3ff2b6 100644
--- a/airtime_mvc/public/setup/database-setup.php
+++ b/airtime_mvc/public/setup/database-setup.php
@@ -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() . "
";
+ }
+ $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() . "
";
+ }
+ $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() . "
";
+ }
+ $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() . "
";
+ }
+
+ $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() . "
";
+ }
+ $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() . "
";
+ }
+ $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() . "
";
+ }
+ $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() . "
";
+ }
+ }
}
diff --git a/install b/install
index df19815fb..216ba0b90 100755
--- a/install
+++ b/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
diff --git a/installer/lib/requirements-debian-buster.apt b/installer/lib/requirements-debian-buster.apt
index e50bd7aed..5c665ec07 100644
--- a/installer/lib/requirements-debian-buster.apt
+++ b/installer/lib/requirements-debian-buster.apt
@@ -67,3 +67,5 @@ liquidsoap
libopus0
systemd-sysv
+
+xmlstarlet
diff --git a/installer/lib/requirements-debian-jessie.apt b/installer/lib/requirements-debian-jessie.apt
index 548835c90..4e22102cc 100644
--- a/installer/lib/requirements-debian-jessie.apt
+++ b/installer/lib/requirements-debian-jessie.apt
@@ -63,3 +63,5 @@ libopus0
sysvinit
sysvinit-utils
+
+xmlstarlet
diff --git a/installer/lib/requirements-debian-stretch.apt b/installer/lib/requirements-debian-stretch.apt
index 5f11226cb..c71175f6a 100644
--- a/installer/lib/requirements-debian-stretch.apt
+++ b/installer/lib/requirements-debian-stretch.apt
@@ -67,3 +67,5 @@ liquidsoap
libopus0
systemd-sysv
+
+xmlstarlet
diff --git a/installer/lib/requirements-ubuntu-bionic.apt b/installer/lib/requirements-ubuntu-bionic.apt
index 08e6f21a6..58be7819f 100644
--- a/installer/lib/requirements-ubuntu-bionic.apt
+++ b/installer/lib/requirements-ubuntu-bionic.apt
@@ -81,3 +81,5 @@ build-essential
libssl-dev
libffi-dev
python-dev
+
+xmlstarlet
diff --git a/installer/lib/requirements-ubuntu-precise.apt b/installer/lib/requirements-ubuntu-precise.apt
index 7c217f659..ed31b628f 100644
--- a/installer/lib/requirements-ubuntu-precise.apt
+++ b/installer/lib/requirements-ubuntu-precise.apt
@@ -70,3 +70,5 @@ liquidsoap-plugin-pulseaudio
liquidsoap-plugin-taglib
liquidsoap-plugin-voaacenc
liquidsoap-plugin-vorbis
+
+xmlstarlet
diff --git a/installer/lib/requirements-ubuntu-xenial.apt b/installer/lib/requirements-ubuntu-xenial.apt
index 70336c10c..41381915f 100644
--- a/installer/lib/requirements-ubuntu-xenial.apt
+++ b/installer/lib/requirements-ubuntu-xenial.apt
@@ -81,3 +81,5 @@ build-essential
libssl-dev
libffi-dev
python-dev
+
+xmlstarlet
diff --git a/installer/lib/requirements-ubuntu-xenial_docker_minimal.apt b/installer/lib/requirements-ubuntu-xenial_docker_minimal.apt
index 6d414ba2d..09c94f817 100644
--- a/installer/lib/requirements-ubuntu-xenial_docker_minimal.apt
+++ b/installer/lib/requirements-ubuntu-xenial_docker_minimal.apt
@@ -76,3 +76,5 @@ build-essential
libssl-dev
libffi-dev
python-dev
+
+xmlstarlet
diff --git a/installer/vagrant/centos.sh b/installer/vagrant/centos.sh
index ddfcecebd..ed3b0bf70 100644
--- a/installer/vagrant/centos.sh
+++ b/installer/vagrant/centos.sh
@@ -86,7 +86,8 @@ yum install -y \
policycoreutils-python \
python-celery \
python2-pika \
- lsof
+ lsof \
+ xmlstarlet
# for pip ssl install
yum install -y \