More work on media-monitor and pypo install process

This commit is contained in:
Duncan Sommerville 2014-12-19 13:49:33 -05:00
parent 6d38f2ccfc
commit 75c2a4a18b
10 changed files with 40 additions and 281 deletions

View File

@ -189,9 +189,6 @@ index_path = '/var/tmp/airtime/media-monitor/last_index'
# cache_base_dir: The pypo base cache directory
# The default is '/var/tmp/airtime/pypo/'
#
# bin_dir: The directory containing pypo binaries
# The default is '/usr/lib/airtime/pypo'
#
# log_base_dir: The base directory for Airtime log files
# The default is '/var/log/airtime'
#
@ -255,7 +252,6 @@ file_dir = '/var/tmp/airtime/pypo/files/'
tmp_dir = '/var/tmp/airtime/pypo/tmp/'
# ------- Setup directories - !! Don't include trailing slash !! -------
cache_base_dir = '/var/tmp/airtime/pypo'
bin_dir = '/usr/lib/airtime/pypo'
log_base_dir = '/var/log/airtime'
pypo_log_dir = '/var/log/airtime/pypo'
liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap'

View File

@ -246,26 +246,26 @@ if [ "$apache" = "f" -a ${_i} -eq 1 ]; then
fi
fi
if [ "$apache" = "t" ]; then
loud "\n-----------------------------------------------------"
loud " * Installing Apache * "
loud "-----------------------------------------------------"
if [ "$in_place" = "t" ]; then
if [ "$in_place" = "t" ]; then
verbose "\n * Setting current Airtime directory as web root..."
web_root=${AIRTIMEROOT}/airtime_mvc/public
chmod -R 755 ${AIRTIMEROOT}
elif [ -n "$web_root" ]; then
elif [ -n "$web_root" ]; then
verbose "\n * Creating Apache web root directory..."
mkdir -p ${web_root}/airtime/public/
cp -R ${AIRTIMEROOT}/airtime_mvc/* ${web_root}/airtime/
chmod -R 755 ${web_root}
else
else
verbose "\n * Creating default Apache web root directory /usr/share/airtime/..."
web_root="/usr/share"
mkdir -p ${web_root}/airtime/public/
cp -R ${AIRTIMEROOT}/airtime_mvc/* ${web_root}/airtime/
fi
fi
if [ "$apache" = "t" ]; then
loud "\n-----------------------------------------------------"
loud " * Installing Apache * "
loud "-----------------------------------------------------"
loudCmd "apt-get -y --force-yes install apache2 libapache2-mod-php5"
set +e
@ -317,16 +317,8 @@ loud "\n-----------------------------------------------------"
loud " * Installing Airtime Services * "
loud "-----------------------------------------------------"
verbose "\n * Installing liquidsoap, python, and virtualenv..."
loudCmd "apt-get -y --force-yes install liquidsoap python python-virtualenv"
verbose "...Done"
# DS, 19/12/14 -- I don't really like this script... should we rewrite it,
# or maybe see if we can get rid of virtualenv entirely?
verbose "\n * Activating Airtime virtualenv..."
loudCmd "$AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh"
. /usr/lib/airtime/airtime_virtualenv/bin/activate
verbose "\n * Installing liquidsoap and python..."
loudCmd "apt-get -y --force-yes install liquidsoap python"
verbose "...Done"
verbose "\n * Creating /usr/lib/airtime..."
@ -353,7 +345,13 @@ cp -R ${AIRTIMEROOT}/python_apps/media-monitor/media-monitor2 /usr/lib/airtime/m
verbose "...Done"
verbose "\n * Installing media-monitor..."
python ${AIRTIMEROOT}/python_apps/media-monitor/setup.py install
if [ -z web_root ]; then
python ${web_root}/python_apps/media-monitor/setup.py develop
elif [ "$in_place" = "t" ]; then
python ${AIRTIMEROOT}/python_apps/media-monitor/setup.py develop
else
python /usr/share/airtime/python_apps/media-monitor/setup.py develop
fi
verbose "...Done"
verbose "\n * Copying pypo files..."
@ -362,18 +360,24 @@ cp -R ${AIRTIMEROOT}/python_apps/pypo/pypo /usr/lib/airtime/pypo/bin/
verbose "...Done"
verbose "\n * Installing pypo..."
python ${AIRTIMEROOT}/python_apps/pypo/setup.py install
if [ -z web_root ]; then
python ${web_root}/python_apps/pypo/setup.py develop
elif [ "$in_place" = "t" ]; then
python ${AIRTIMEROOT}/python_apps/pypo/setup.py develop
else
python /usr/share/airtime/python_apps/pypo/setup.py develop
fi
verbose "...Done"
verbose "\n * Creating init files..."
sed -e "s/WEB_USER/${web_user}/g" /usr/lib/airtime/media-monitor/airtime-media-monitor-init-d > /etc/init.d/airtime-media-monitor
verbose "\n * Creating sudoers files..."
# sed -e "s/WEB_USER/${web_user}/g" /usr/lib/airtime/media-monitor/airtime-media-monitor-init-d > /etc/init.d/airtime-media-monitor
touch /etc/sudoers.d/airtime-media-monitor_${web_user}
echo "${web_user} ALL = (root) NOPASSWD: /sbin/start airtime-media-monitor, \
/sbin/stop airtime-media-monitor, \
/sbin/restart airtime-media-monitor, \
/sbin/status airtime-media-monitor" > /etc/sudoers.d/airtime-media-monitor_${web_user}
sed -e "s/WEB_USER/${web_user}/g" /usr/lib/airtime/pypo/bin/airtime-playout-init-d > /etc/init.d/airtime-playout
# sed -e "s/WEB_USER/${web_user}/g" /usr/lib/airtime/pypo/bin/airtime-playout-init-d > /etc/init.d/airtime-playout
touch /etc/sudoers.d/airtime-playout_${web_user}
echo "${web_user} ALL = (root) NOPASSWD: /sbin/start airtime-playout, \
/sbin/stop airtime-playout, \
@ -381,7 +385,7 @@ echo "${web_user} ALL = (root) NOPASSWD: /sbin/start airtime-playout, \
/sbin/status airtime-playout" > /etc/sudoers.d/airtime-playout_${web_user}
ln -sf /usr/bin/liquidsoap /usr/bin/airtime-liquidsoap
sed -e "s/WEB_USER/${web_user}/g" /usr/lib/airtime/pypo/bin/airtime-liquidsoap-init-d > /etc/init.d/airtime-liquidsoap
# sed -e "s/WEB_USER/${web_user}/g" /usr/lib/airtime/pypo/bin/airtime-liquidsoap-init-d > /etc/init.d/airtime-liquidsoap
touch /etc/sudoers.d/airtime-liquidsoap_${web_user}
echo "${web_user} ALL = (root) NOPASSWD: /sbin/start airtime-liquidsoap, \
/sbin/stop airtime-liquidsoap, \

View File

@ -1,30 +0,0 @@
#!/bin/bash
# Location of pypo_cli.py Python script
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
media_monitor_path="/usr/lib/airtime/media-monitor/"
media_monitor_script="media_monitor.py"
api_client_path="/usr/lib/airtime/:/usr/lib/airtime/media-monitor/mm2/"
cd ${media_monitor_path}
exec 2>&1
set +e
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8"
set -e
if [ "$?" != "0" ]; then
echo "non UTF-8 default locale found in /etc/default/locale." > /var/log/airtime/media-monitor/error.log
exit 1
fi
export PYTHONPATH=${api_client_path}
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`
exec python ${media_monitor_path}${media_monitor_script} > /var/log/airtime/media-monitor/py-interpreter.log 2>&1
# EOF

View File

@ -27,17 +27,6 @@ stop () {
rm -f $PIDFILE
}
start_with_monit() {
start
monit monitor airtime-media-monitor >/dev/null 2>&1
}
stop_with_monit() {
monit unmonitor airtime-media-monitor >/dev/null 2>&1
stop
}
case "${1:-''}" in
'start')
# start commands here
@ -58,18 +47,6 @@ case "${1:-''}" in
start
echo "Done."
;;
'start-with-monit')
# restart commands here
echo -n "Starting $NAME: "
start_with_monit
echo "Done."
;;
'stop-with-monit')
# restart commands here
echo -n "Stopping $NAME: "
stop_with_monit
echo "Done."
;;
'status')
# status commands here
/usr/bin/airtime-check-system

View File

@ -40,7 +40,7 @@ setup(name='airtime-media-monitor',
zip_safe=False,
data_files=data_files)
# Reload the initctl config so that playout services works
# Reload the initctl config so that the media-monitor service works
if data_files:
print "Reloading initctl configuration"
call(['initctl', 'reload-configuration'])

View File

@ -23,25 +23,15 @@ do
done
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
export HOME="/var/tmp/airtime/pypo/"
api_client_path="/usr/lib/airtime/"
if [ $debug = "t" ]; then
if [ "$debug" = "t" ]; then
ls_path="/usr/bin/airtime-liquidsoap --verbose -f"
else
ls_path="/usr/bin/airtime-liquidsoap --verbose -f -d"
fi
ls_param="/usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq"
export PYTHONPATH=${api_client_path}
SCRIPT=`readlink -f $0`
# Absolute directory this script is in
SCRIPTPATH=`dirname $SCRIPT`
cd $SCRIPTPATH/liquidsoap_scripts
cd /usr/lib/airtime/pypo/bin/liquidsoap_scripts
python generate_liquidsoap_cfg.py
exec ${ls_path} ${ls_param} 2>&1

View File

@ -1,17 +1,5 @@
#!/bin/bash
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
# Absolute path to this script
SCRIPT=`readlink -f $0`
# Absolute directory this script is in
pypo_path=`dirname $SCRIPT`
api_client_path="/usr/lib/airtime/"
pypo_script="pypocli.py"
cd ${pypo_path}
set +e
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8" > /dev/null
set -e
@ -21,11 +9,9 @@ if [ "$?" != "0" ]; then
fi
export HOME="/var/tmp/airtime/pypo/"
export PYTHONPATH=${api_client_path}:$PYTHONPATH
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`
export TERM=xterm
exec python ${pypo_path}/${pypo_script} > /var/log/airtime/pypo/py-interpreter.log 2>&1
exec python /usr/lib/airtime/pypo/bin/pypocli.py > /var/log/airtime/pypo/py-interpreter.log 2>&1
# EOF

View File

@ -1,48 +0,0 @@
#!/bin/bash -e
debug="f"
showhelp () {
echo "Usage: airtime-liquidsoap [options]
--help|-h Displays usage information.
--debug|-d Print error messages to console"
}
set -- $(getopt -l help,debug "hd" "$@")
while [ $# -gt 0 ]
do
case "$1" in
(-h|--help) showhelp; exit 0;;
(-d|--debug) debug="t";;
(--) shift; break;;
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
(*) break;;
esac
shift
done
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
export HOME="/var/tmp/airtime/pypo/"
api_client_path="/usr/lib/airtime/"
if [ $debug = "t" ]; then
ls_path="/usr/bin/airtime-liquidsoap --verbose -f"
else
ls_path="/usr/bin/airtime-liquidsoap --verbose -f -d"
fi
ls_param="/usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq"
export PYTHONPATH=${api_client_path}
SCRIPT=`readlink -f $0`
# Absolute directory this script is in
SCRIPTPATH=`dirname $SCRIPT`
cd $SCRIPTPATH/liquidsoap_scripts
python generate_liquidsoap_cfg.py
exec ${ls_path} ${ls_param} 2>&1
# EOF

View File

@ -1,31 +0,0 @@
#!/bin/bash
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
# Absolute path to this script
SCRIPT=`readlink -f $0`
# Absolute directory this script is in
pypo_path=`dirname $SCRIPT`
api_client_path="/usr/lib/airtime/"
pypo_script="pypocli.py"
cd ${pypo_path}
set +e
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8"
set -e
if [ "$?" != "0" ]; then
echo "non UTF-8 default locale found in /etc/default/locale." > /var/log/airtime/pypo/error.log
exit 1
fi
export HOME="/var/tmp/airtime/pypo/"
export PYTHONPATH=${api_client_path}:$PYTHONPATH
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`
export TERM=xterm
exec python ${pypo_path}/${pypo_script} > /var/log/airtime/pypo/py-interpreter.log 2>&1
# EOF

View File

@ -1,85 +0,0 @@
############################################
# pypo - configuration #
############################################
# Set the type of client you are using.
# Currently supported types:
# 1) "obp" = Open Broadcast Platform
# 2) "airtime"
#
api_client = "airtime"
############################################
# Cache Directories #
# *include* trailing slash !! #
############################################
cache_dir = '/var/tmp/airtime/pypo/cache/'
file_dir = '/var/tmp/airtime/pypo/files/'
tmp_dir = '/var/tmp/airtime/pypo/tmp/'
############################################
# Setup Directories #
# Do *not* include trailing slash !! #
############################################
cache_base_dir = '/var/tmp/airtime/pypo'
bin_dir = '/usr/lib/airtime/pypo'
log_base_dir = '/var/log/airtime'
pypo_log_dir = '/var/log/airtime/pypo'
liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap'
############################################
# Liquidsoap settings #
############################################
ls_host = '127.0.0.1'
ls_port = '1234'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
rabbitmq_vhost = '/'
############################################
# pypo preferences #
############################################
# Poll interval in seconds.
#
# This will rarely need to be changed because any schedule changes are
# automatically sent to pypo immediately.
#
# This is how often the poll script downloads new schedules and files from the
# server in the event that no changes are made to the schedule.
#
poll_interval = 3600 # in seconds.
# Push interval in seconds.
#
# This is how often the push script checks whether it has something new to
# push to liquidsoap.
#
# It's hard to imagine a situation where this should be more than 1 second.
#
push_interval = 1 # in seconds
# 'pre' or 'otf'. 'pre' cues while playlist preparation
# while 'otf' (on the fly) cues while loading into ls
# (needs the post_processor patch)
cue_style = 'pre'
############################################
# Recorded Audio settings #
############################################
record_bitrate = 256
record_samplerate = 44100
record_channels = 2
record_sample_size = 16
#can be either ogg|mp3, mp3 recording requires installation of the package "lame"
record_file_type = 'ogg'
# base path to store recordered shows at
base_recorded_files = '/var/tmp/airtime/show-recorder/'