-make sure to autogenerate liquidsoap.cfg before liquidsoap starts
This commit is contained in:
parent
effd28bad1
commit
d8ae8002d2
|
@ -91,6 +91,7 @@ class AirtimeIni
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
if (!copy(__DIR__."/../../python_apps/pypo/liquidsoap_scripts/liquidsoap.cfg", AirtimeIni::CONF_FILE_LIQUIDSOAP)){
|
||||
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
|
@ -98,6 +99,7 @@ class AirtimeIni
|
|||
echo "Could not set ownership of liquidsoap.cfg to 'pypo'. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
* */
|
||||
|
||||
if (!copy(__DIR__."/../../python_apps/media-monitor/media-monitor.cfg", AirtimeIni::CONF_FILE_MEDIAMONITOR)){
|
||||
echo "Could not copy media-monitor.cfg to /etc/airtime/. Exiting.";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/bin/bash -e
|
||||
|
||||
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
|
||||
. ${virtualenv_bin}activate
|
||||
|
@ -10,15 +10,13 @@ ls_path="/usr/bin/airtime-liquidsoap --verbose"
|
|||
ls_param="/usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq"
|
||||
|
||||
exec 2>&1
|
||||
export PYTHONPATH=${api_client_path}
|
||||
|
||||
while [ ! -e /etc/airtime/liquidsoap.cfg ]; do
|
||||
echo "/etc/airtime/liquidsoap.cfg does not exist."
|
||||
sleep 1
|
||||
done
|
||||
rm -f /etc/airtime/liquidsoap.cfg
|
||||
|
||||
cd /usr/lib/airtime/pypo/bin/liquidsoap_scripts
|
||||
python generate_liquidsoap_cfg.py
|
||||
|
||||
export PYTHONPATH=${api_client_path}
|
||||
exec ${ls_path} ${ls_param}
|
||||
|
||||
# EOF
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import os
|
||||
import grp
|
||||
import stat
|
||||
import shutil
|
||||
import sys
|
||||
import subprocess
|
||||
|
@ -42,7 +44,15 @@ try:
|
|||
|
||||
if not os.path.exists(PATH_INI_FILE):
|
||||
shutil.copy('%s/../pypo.cfg'%current_script_dir, PATH_INI_FILE)
|
||||
|
||||
|
||||
try:
|
||||
os.remove("/etc/airtime/liquidsoap.cfg")
|
||||
except Exception, e:
|
||||
pass
|
||||
gid = grp.getgrnam("pypo").gr_gid
|
||||
os.chown("/etc/airtime", -1, gid)
|
||||
os.chmod("/etc/airtime", stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
|
||||
|
||||
# load config file
|
||||
try:
|
||||
config = ConfigObj(PATH_INI_FILE)
|
||||
|
|
|
@ -109,17 +109,19 @@ try:
|
|||
print e
|
||||
sys.exit(1)
|
||||
|
||||
"""
|
||||
logging.basicConfig(format='%(message)s')
|
||||
|
||||
#generate liquidsoap config file
|
||||
#access the DB and generate liquidsoap.cfg under /etc/airtime/
|
||||
ac = api_client.api_client_factory(config, logging.getLogger())
|
||||
ss = ac.get_stream_setting()
|
||||
|
||||
|
||||
if ss is not None:
|
||||
generate_liquidsoap_config(ss)
|
||||
else:
|
||||
print "Unable to connect to the Airtime server."
|
||||
"""
|
||||
|
||||
#initialize init.d scripts
|
||||
subprocess.call("update-rc.d airtime-playout defaults >/dev/null 2>&1", shell=True)
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
import logging
|
||||
import sys
|
||||
from api_clients import api_client
|
||||
from configobj import ConfigObj
|
||||
|
||||
def generate_liquidsoap_config(ss):
|
||||
data = ss['msg']
|
||||
fh = open('/etc/airtime/liquidsoap.cfg', 'w')
|
||||
fh.write("################################################\n")
|
||||
fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n")
|
||||
fh.write("################################################\n")
|
||||
for d in data:
|
||||
buffer = d[u'keyname'] + " = "
|
||||
if(d[u'type'] == 'string'):
|
||||
temp = d[u'value']
|
||||
buffer += '"%s"' % temp
|
||||
else:
|
||||
temp = d[u'value']
|
||||
if(temp == ""):
|
||||
temp = "0"
|
||||
buffer += temp
|
||||
buffer += "\n"
|
||||
fh.write(api_client.encode_to(buffer))
|
||||
fh.write('log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"\n')
|
||||
fh.close()
|
||||
|
||||
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
|
||||
|
||||
try:
|
||||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit(1)
|
||||
|
||||
logging.basicConfig(format='%(message)s')
|
||||
ac = api_client.api_client_factory(config, logging.getLogger())
|
||||
ss = ac.get_stream_setting()
|
||||
|
||||
if ss is not None:
|
||||
try:
|
||||
generate_liquidsoap_config(ss)
|
||||
except Exception, e:
|
||||
logging.error(e)
|
||||
else:
|
||||
print "Unable to connect to the Airtime server."
|
||||
sys.exit(1)
|
Loading…
Reference in New Issue