install api 2.0 apache config on update
This commit is contained in:
parent
2df0189a90
commit
2024f9a887
51
install
51
install
|
@ -35,13 +35,13 @@ showhelp () {
|
||||||
-r, --web-root=WEB_ROOT
|
-r, --web-root=WEB_ROOT
|
||||||
Set the web root for Airtime files
|
Set the web root for Airtime files
|
||||||
This will copy the Airtime application files, but you will need
|
This will copy the Airtime application files, but you will need
|
||||||
to give your web user access to the given directory if it is
|
to give your web user access to the given directory if it is
|
||||||
not accessible
|
not accessible
|
||||||
--web-port=WEB_PORT
|
--web-port=WEB_PORT
|
||||||
Set what port the LibreTime interface should run on.
|
Set what port the LibreTime interface should run on.
|
||||||
-I, --in-place
|
-I, --in-place
|
||||||
Set the current Airtime directory as the web root
|
Set the current Airtime directory as the web root
|
||||||
Note that you will need to give your web user permission to
|
Note that you will need to give your web user permission to
|
||||||
access this directory if it is not accessible
|
access this directory if it is not accessible
|
||||||
-p, --postgres
|
-p, --postgres
|
||||||
Create a default postgres user named 'airtime' with password
|
Create a default postgres user named 'airtime' with password
|
||||||
|
@ -107,7 +107,7 @@ function loud() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Evaluate commands silently if quiet.
|
# Evaluate commands silently if quiet.
|
||||||
# If not quiet, output command if verbose.
|
# If not quiet, output command if verbose.
|
||||||
function loudCmd() {
|
function loudCmd() {
|
||||||
if [[ ${_q} -eq 0 ]]; then
|
if [[ ${_q} -eq 0 ]]; then
|
||||||
|
@ -131,12 +131,12 @@ function checkCommandExists() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to determine if systemd, Upstart or System V Init is the active
|
# Function to determine if systemd, Upstart or System V Init is the active
|
||||||
# init system. All the newer supported distros use systemd out-of-the-box but
|
# init system. All the newer supported distros use systemd out-of-the-box but
|
||||||
# a sysadmin could have installed an alternative init compatibility package.
|
# a sysadmin could have installed an alternative init compatibility package.
|
||||||
# As a result, making assumptions based on the distribution and release is
|
# As a result, making assumptions based on the distribution and release is
|
||||||
# not a good idea. The detection works as follows:
|
# not a good idea. The detection works as follows:
|
||||||
# 1. Get the process name where PID=1 and follow any symlinks.
|
# 1. Get the process name where PID=1 and follow any symlinks.
|
||||||
# 2. Look up that path in the appropriate package manager to get the name
|
# 2. Look up that path in the appropriate package manager to get the name
|
||||||
# of the package that process is part of.
|
# of the package that process is part of.
|
||||||
# See https://unix.stackexchange.com/questions/196166/how-to-find-out-if-a-system-uses-sysv-upstart-or-systemd-initsystem
|
# See https://unix.stackexchange.com/questions/196166/how-to-find-out-if-a-system-uses-sysv-upstart-or-systemd-initsystem
|
||||||
has_systemd_init=false
|
has_systemd_init=false
|
||||||
|
@ -338,7 +338,7 @@ function systemInitInstall() {
|
||||||
|
|
||||||
# Function to wrap different systemd vs. Upstart init commands depending
|
# Function to wrap different systemd vs. Upstart init commands depending
|
||||||
# on which init system has been detected. Syntax is similar to systemctl.
|
# on which init system has been detected. Syntax is similar to systemctl.
|
||||||
# Usage:
|
# Usage:
|
||||||
# systemInitCommand _command_ [service-name ...]
|
# systemInitCommand _command_ [service-name ...]
|
||||||
# Where _command_ is one of: start, stop, status, reload, restart
|
# Where _command_ is one of: start, stop, status, reload, restart
|
||||||
# enable, disable and either daemon-reload or reload-configuration.
|
# enable, disable and either daemon-reload or reload-configuration.
|
||||||
|
@ -368,10 +368,10 @@ function systemInitCommand() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
daemon-reload|reload-configuration)
|
daemon-reload|reload-configuration)
|
||||||
$has_systemd_init &&
|
$has_systemd_init &&
|
||||||
loudCmd "systemctl daemon-reload"
|
loudCmd "systemctl daemon-reload"
|
||||||
$has_upstart_init &&
|
$has_upstart_init &&
|
||||||
loudCmd "initctl reload-configuration"
|
loudCmd "initctl reload-configuration"
|
||||||
;;
|
;;
|
||||||
*) echo -e "$0:${FUNCNAME}(): ERROR: command \"$command\" is not supported!" >&2
|
*) echo -e "$0:${FUNCNAME}(): ERROR: command \"$command\" is not supported!" >&2
|
||||||
|
@ -719,7 +719,7 @@ if [ "$ignore_dependencies" = "f" ]; then
|
||||||
loud "\n-----------------------------------------------------"
|
loud "\n-----------------------------------------------------"
|
||||||
loud " * Installing External Dependencies * "
|
loud " * Installing External Dependencies * "
|
||||||
loud "-----------------------------------------------------"
|
loud "-----------------------------------------------------"
|
||||||
|
|
||||||
if $is_ubuntu_dist; then
|
if $is_ubuntu_dist; then
|
||||||
loudCmd "add-apt-repository -y ppa:libretime/libretime"
|
loudCmd "add-apt-repository -y ppa:libretime/libretime"
|
||||||
fi
|
fi
|
||||||
|
@ -781,10 +781,10 @@ if [ -f /etc/airtime/airtime.conf ]; then
|
||||||
# TODO use VERSION or some other way to check for updates and handle
|
# TODO use VERSION or some other way to check for updates and handle
|
||||||
# media-monitor case on it's own
|
# media-monitor case on it's own
|
||||||
OLD_CONF=$(grep -F "[media-monitor]" /etc/airtime/airtime.conf || true)
|
OLD_CONF=$(grep -F "[media-monitor]" /etc/airtime/airtime.conf || true)
|
||||||
|
|
||||||
if [ -n "${OLD_CONF}" ]; then
|
if [ -n "${OLD_CONF}" ]; then
|
||||||
upgrade="t"
|
upgrade="t"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
verbose "Stopping airtime services..."
|
verbose "Stopping airtime services..."
|
||||||
systemInitCommand stop airtime_analyzer airtime-celery airtime-playout airtime-liquidsoap airtime-media-monitor
|
systemInitCommand stop airtime_analyzer airtime-celery airtime-playout airtime-liquidsoap airtime-media-monitor
|
||||||
|
@ -796,7 +796,7 @@ if [ -f /etc/airtime/airtime.conf ]; then
|
||||||
|
|
||||||
echo "Looks like you have an old version of Airtime. Your current /etc/airtime/airtime.conf \
|
echo "Looks like you have an old version of Airtime. Your current /etc/airtime/airtime.conf \
|
||||||
will be moved to /etc/airtime/airtime.conf.tmp"
|
will be moved to /etc/airtime/airtime.conf.tmp"
|
||||||
# If we don't remove the existing python files in /usr/lib and the
|
# If we don't remove the existing python files in /usr/lib and the
|
||||||
# /etc/init.d startup scripts, services won't work properly
|
# /etc/init.d startup scripts, services won't work properly
|
||||||
if [ -d /usr/lib/airtime/ ]; then
|
if [ -d /usr/lib/airtime/ ]; then
|
||||||
rm -rf /usr/lib/airtime/
|
rm -rf /usr/lib/airtime/
|
||||||
|
@ -807,20 +807,27 @@ will be moved to /etc/airtime/airtime.conf.tmp"
|
||||||
rm -f /etc/default/airtime-celery
|
rm -f /etc/default/airtime-celery
|
||||||
|
|
||||||
if [ "$apache" = "t" ]; then
|
if [ "$apache" = "t" ]; then
|
||||||
# If the user selects an "in-place" install or passes in a web root,
|
# If the user selects an "in-place" install or passes in a web root,
|
||||||
# we need to replace the old apache airtime.conf
|
# we need to replace the old apache airtime.conf
|
||||||
rm /etc/apache2/sites-available/airtime.conf /etc/apache2/sites-enabled/airtime.conf
|
rm -f /etc/apache2/sites-available/airtime.conf /etc/apache2/sites-enabled/airtime.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d /usr/share/airtime -a web_root = /usr/share/airtime ]; then
|
if [ -d /usr/share/airtime -a web_root = /usr/share/airtime ]; then
|
||||||
rm -rf /usr/share/airtime
|
rm -rf /usr/share/airtime
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv /etc/airtime/airtime.conf /etc/airtime/airtime.conf.tmp
|
mv /etc/airtime/airtime.conf /etc/airtime/airtime.conf.tmp
|
||||||
set -e
|
set -e
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
API2_APACHE_CONF=$(grep -F "ProxyPass" /etc/apache2/sites-available/airtime.conf || true)
|
||||||
|
if [ -z "${API2_APACHE_CONF}" -a "$apache" = "t" ]; then
|
||||||
|
# Remove Apache configuration so that the ProxyPass configuration for API 2.0
|
||||||
|
# is installed
|
||||||
|
rm -f /etc/apache2/sites-available/airtime.conf /etc/apache2/sites-enabled/airtime.conf
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$apache" = "f" -a ${_i} -eq 1 ]; then
|
if [ "$apache" = "f" -a ${_i} -eq 1 ]; then
|
||||||
echo -e "Install default Airtime apache configuration? (Y/n): \c"
|
echo -e "Install default Airtime apache configuration? (Y/n): \c"
|
||||||
read IN
|
read IN
|
||||||
|
@ -936,7 +943,7 @@ if [ "$icecast" = "t" ]; then
|
||||||
loud "\n-----------------------------------------------------"
|
loud "\n-----------------------------------------------------"
|
||||||
loud " * Configuring Icecast * "
|
loud " * Configuring Icecast * "
|
||||||
loud "-----------------------------------------------------"
|
loud "-----------------------------------------------------"
|
||||||
|
|
||||||
verbose "\n * Enabling Icecast 2..."
|
verbose "\n * Enabling Icecast 2..."
|
||||||
icecast_unit_name="icecast2"
|
icecast_unit_name="icecast2"
|
||||||
if [ "$dist" != "centos" ]; then
|
if [ "$dist" != "centos" ]; then
|
||||||
|
@ -947,7 +954,7 @@ if [ "$icecast" = "t" ]; then
|
||||||
icecast_config="/etc/icecast.xml"
|
icecast_config="/etc/icecast.xml"
|
||||||
fi
|
fi
|
||||||
systemInitCommand enable ${icecast_unit_name}
|
systemInitCommand enable ${icecast_unit_name}
|
||||||
# only update icecast password if
|
# only update icecast password if
|
||||||
if [ ! -e "/etc/airtime/airtime.conf" ] && [ ! -e "/etc/airtime/airtime.conf.tmp" ]; then
|
if [ ! -e "/etc/airtime/airtime.conf" ] && [ ! -e "/etc/airtime/airtime.conf.tmp" ]; then
|
||||||
icecast_pass=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12};)
|
icecast_pass=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12};)
|
||||||
echo $icecast_pass > /tmp/icecast_pass
|
echo $icecast_pass > /tmp/icecast_pass
|
||||||
|
@ -1099,8 +1106,8 @@ if [ $skip_postgres -eq 0 ]; then
|
||||||
count=$(psql -d postgres -tAc "SELECT count(*) FROM pg_roles WHERE rolname='airtime';")
|
count=$(psql -d postgres -tAc "SELECT count(*) FROM pg_roles WHERE rolname='airtime';")
|
||||||
if [[ $count -eq 0 ]]; then
|
if [[ $count -eq 0 ]]; then
|
||||||
psql -d postgres -tAc "CREATE USER airtime WITH ENCRYPTED PASSWORD 'airtime'; ALTER USER airtime CREATEDB;"
|
psql -d postgres -tAc "CREATE USER airtime WITH ENCRYPTED PASSWORD 'airtime'; ALTER USER airtime CREATEDB;"
|
||||||
[[ $? -eq 0 ]] &&
|
[[ $? -eq 0 ]] &&
|
||||||
echo "Created airtime user in PostgreSQL" ||
|
echo "Created airtime user in PostgreSQL" ||
|
||||||
echo "$0:${FUNCNAME}(): ERROR: Can't create airtime user in PostgreSQL!"
|
echo "$0:${FUNCNAME}(): ERROR: Can't create airtime user in PostgreSQL!"
|
||||||
else
|
else
|
||||||
echo "airtime user already exists in PostgreSQL"
|
echo "airtime user already exists in PostgreSQL"
|
||||||
|
|
Loading…
Reference in New Issue