CC-2758: Make airtime-install script Debian/Ubuntu compatible
-initial commit
This commit is contained in:
parent
d26e410799
commit
8cafc52cad
|
@ -16,7 +16,7 @@ if [[ "$DEB" = "Status: install ok installed" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#Check whether version of virtualenv is <= 1.4.5. If so exit install.
|
#Check whether version of virtualenv is <= 1.4.8. If so exit install.
|
||||||
BAD_VERSION="1.4.8"
|
BAD_VERSION="1.4.8"
|
||||||
VERSION=$(virtualenv --version)
|
VERSION=$(virtualenv --version)
|
||||||
NEWEST_VERSION=$(echo -e "$BAD_VERSION\n$VERSION\n'" | sort -t '.' -g | tail -n 1)
|
NEWEST_VERSION=$(echo -e "$BAD_VERSION\n$VERSION\n'" | sort -t '.' -g | tail -n 1)
|
||||||
|
@ -71,13 +71,14 @@ python ${SCRIPTPATH}/../python_apps/media-monitor/install/media-monitor-install.
|
||||||
|
|
||||||
python ${SCRIPTPATH}/../python_apps/icecast2/install/icecast2-install.py
|
python ${SCRIPTPATH}/../python_apps/icecast2/install/icecast2-install.py
|
||||||
|
|
||||||
|
# Start monit if it is not running, or restart if it is.
|
||||||
# Need to ensure monit is running before Airtime daemons are run. This is
|
# Need to ensure monit is running before Airtime daemons are run. This is
|
||||||
# so we can ensure they can register with monit to monitor them when they start.
|
# so we can ensure they can register with monit to monitor them when they start.
|
||||||
# If monit is already running, this step is still useful as we need monit to
|
# If monit is already running, this step is still useful as we need monit to
|
||||||
# reload its config files.
|
# reload its config files.
|
||||||
/etc/init.d/monit restart
|
/etc/init.d/monit restart
|
||||||
|
|
||||||
#allow monit to boot up before issuing commands
|
#give monit some time to boot-up before issuing commands
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
#-e Causes bash script to exit if any of the installers
|
||||||
|
#return with a non-zero return value.
|
||||||
|
|
||||||
|
if [ `whoami` != 'root' ]; then
|
||||||
|
echo "Please run as root user."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set +e
|
||||||
|
DEB=$(dpkg -s airtime 2> /dev/null | grep Status)
|
||||||
|
set -e
|
||||||
|
if [[ "$DEB" = "Status: install ok installed" ]]; then
|
||||||
|
echo -e "\nDebian package of Airtime detected. Please use the debian package to upgrade.\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Check whether version of virtualenv is <= 1.4.8. If so exit install.
|
||||||
|
BAD_VERSION="1.4.8"
|
||||||
|
VERSION=$(virtualenv --version)
|
||||||
|
NEWEST_VERSION=$(echo -e "$BAD_VERSION\n$VERSION\n'" | sort -t '.' -g | tail -n 1)
|
||||||
|
echo -n "Ensuring python-virtualenv version > $BAD_VERSION..."
|
||||||
|
if [[ "$NEWEST_VERSION" = "$BAD_VERSION" ]]; then
|
||||||
|
URL="http://apt.sourcefabric.org/pool/main/p/python-virtualenv/python-virtualenv_1.4.9-3_all.deb"
|
||||||
|
echo "Failed!"
|
||||||
|
echo "You have version $BAD_VERSION or older installed. Please install package at $URL first and then try installing Airtime again."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Success!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo -e "\n******************************** Install Begin *********************************"
|
||||||
|
|
||||||
|
#copy files to
|
||||||
|
## /etc/airtime
|
||||||
|
#+ /etc/apache2/sites-available/airtime
|
||||||
|
#+ /etc/apache2/sites-enabled/airtime
|
||||||
|
## /etc/cron.d/
|
||||||
|
## /etc/init.d/
|
||||||
|
## /etc/monit/conf.d/
|
||||||
|
# /usr/lib/airtime/airtime_virtualenv
|
||||||
|
# /usr/lib/airtime/api_clients
|
||||||
|
# /usr/lib/airtime/media-monitor
|
||||||
|
# /srv/airtime
|
||||||
|
# /usr/lib/airtime/pypo
|
||||||
|
# /usr/lib/airtime/show-recorder
|
||||||
|
## /usr/lib/airtime/utils
|
||||||
|
## /usr/bin/airtime-*
|
||||||
|
## /usr/share/airtime
|
||||||
|
## /var/log/airtime
|
||||||
|
## /var/tmp/airtime
|
||||||
|
|
||||||
|
# Absolute path to this script, e.g. /home/user/bin/foo.sh
|
||||||
|
SCRIPT=`readlink -f $0`
|
||||||
|
# Absolute path this script is in, thus /home/user/bin
|
||||||
|
SCRIPTPATH=`dirname $SCRIPT`
|
||||||
|
|
||||||
|
mkdir -p /etc/airtime
|
||||||
|
cp $SCRIPTPATH/../airtime_mvc/build/airtime.conf /etc/airtime
|
||||||
|
cp $SCRIPTPATH/../python_apps/api_clients/api_client.cfg /etc/airtime
|
||||||
|
cp $SCRIPTPATH/../python_apps/show-recorder/recorder.cfg /etc/airtime
|
||||||
|
cp $SCRIPTPATH/../python_apps/media-monitor/media-monitor.cfg /etc/airtime
|
||||||
|
cp $SCRIPTPATH/../python_apps/pypo/pypo.cfg /etc/airtime
|
||||||
|
cp $SCRIPTPATH/../python_apps/pypo/liquidsoap_scripts/liquidsoap.cfg /etc/airtime
|
||||||
|
|
||||||
|
HOUR=$(($RANDOM%24))
|
||||||
|
MIN=$(($RANDOM%60))
|
||||||
|
echo "$MIN $HOUR * * * root /usr/lib/airtime/utils/phone_home_stat" > /etc/cron.d/airtime-crons
|
||||||
|
|
||||||
|
cp $SCRIPTPATH/../python_apps/show-recorder/airtime-show-recorder-init-d /etc/init.d/airtime-show-recorder
|
||||||
|
cp $SCRIPTPATH/../python_apps/media-monitor/airtime-media-monitor-init-d /etc/init.d/airtime-media-monitor
|
||||||
|
cp $SCRIPTPATH/../python_apps/pypo/airtime-playout-init-d /etc/init.d/airtime-playout
|
||||||
|
|
||||||
|
cp $SCRIPTPATH/../python_apps/monit/monit-airtime-generic.cfg /etc/monit/conf.d/
|
||||||
|
#cp $SCRIPTPATH/../python_apps/monit/monit-airtime-rabbitmq-server.cfg /etc/monit/conf.d/
|
||||||
|
cp $SCRIPTPATH/../python_apps/media-monitor/monit-airtime-media-monitor.cfg /etc/monit/conf.d/
|
||||||
|
cp $SCRIPTPATH/../python_apps/show-recorder/monit-airtime-show-recorder.cfg /etc/monit/conf.d/
|
||||||
|
cp $SCRIPTPATH/../python_apps/pypo/monit-airtime-liquidsoap.cfg /etc/monit/conf.d/
|
||||||
|
cp $SCRIPTPATH/../python_apps/pypo/monit-airtime-playout.cfg /etc/monit/conf.d/
|
||||||
|
|
||||||
|
cp -R $SCRIPTPATH/../utils /usr/lib/airtime
|
||||||
|
|
||||||
|
ln -s /usr/lib/airtime/utils/airtime-import/airtime-import /usr/bin/airtime-import
|
||||||
|
ln -s /usr/lib/airtime/utils/airtime-update-db-settings /usr/bin/airtime-update-db-settings
|
||||||
|
ln -s /usr/lib/airtime/utils/airtime-check-system /usr/bin/airtime-check-system
|
||||||
|
ln -s /usr/lib/airtime/utils/airtime-log /usr/bin/airtime-log
|
||||||
|
|
||||||
|
cp -R $SCRIPTPATH/../airtime_mvc/* /usr/share/airtime/
|
||||||
|
|
||||||
|
mkdir -p /var/log/airtime
|
||||||
|
mkdir -p /var/tmp/airtime
|
|
@ -15,10 +15,11 @@ require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||||
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
||||||
require_once(__DIR__.'/airtime-constants.php');
|
require_once(__DIR__.'/airtime-constants.php');
|
||||||
|
|
||||||
AirtimeInstall::ExitIfNotRoot();
|
|
||||||
|
|
||||||
$newInstall = false;
|
|
||||||
$version = AirtimeInstall::GetVersionInstalled();
|
|
||||||
|
|
||||||
|
AirtimeInstall::ExitIfNotRoot();
|
||||||
|
|
||||||
require_once('Zend/Loader/Autoloader.php');
|
require_once('Zend/Loader/Autoloader.php');
|
||||||
$autoloader = Zend_Loader_Autoloader::getInstance();
|
$autoloader = Zend_Loader_Autoloader::getInstance();
|
||||||
|
@ -41,8 +42,7 @@ try {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$opts->parse();
|
$opts->parse();
|
||||||
}
|
} catch (Zend_Console_Getopt_Exception $e) {
|
||||||
catch (Zend_Console_Getopt_Exception $e) {
|
|
||||||
print $e->getMessage() .PHP_EOL;
|
print $e->getMessage() .PHP_EOL;
|
||||||
printUsage($opts);
|
printUsage($opts);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -50,9 +50,10 @@ catch (Zend_Console_Getopt_Exception $e) {
|
||||||
|
|
||||||
if (isset($opts->h)) {
|
if (isset($opts->h)) {
|
||||||
printUsage($opts);
|
printUsage($opts);
|
||||||
exit(1);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$version = AirtimeInstall::GetVersionInstalled();
|
||||||
// The current version is already installed.
|
// The current version is already installed.
|
||||||
if (isset($version) && ($version != false) && ($version == AIRTIME_VERSION) && !isset($opts->r)) {
|
if (isset($version) && ($version != false) && ($version == AIRTIME_VERSION) && !isset($opts->r)) {
|
||||||
echo "Airtime $version is already installed.".PHP_EOL;
|
echo "Airtime $version is already installed.".PHP_EOL;
|
||||||
|
@ -83,6 +84,7 @@ if($version === false){
|
||||||
// The only way we get here is if we are doing a new install or a reinstall.
|
// The only way we get here is if we are doing a new install or a reinstall.
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
$newInstall = false;
|
||||||
if(is_null($version)) {
|
if(is_null($version)) {
|
||||||
$newInstall = true;
|
$newInstall = true;
|
||||||
}
|
}
|
||||||
|
@ -95,8 +97,7 @@ if (is_null($opts->r) && isset($opts->n)) {
|
||||||
$overwrite = false;
|
$overwrite = false;
|
||||||
if (isset($opts->o) || $newInstall == true) {
|
if (isset($opts->o) || $newInstall == true) {
|
||||||
$overwrite = true;
|
$overwrite = true;
|
||||||
}
|
} else if (!isset($opts->p) && !isset($opts->o) && isset($opts->r)) {
|
||||||
else if (!isset($opts->p) && !isset($opts->o) && isset($opts->r)) {
|
|
||||||
if (AirtimeIni::IniFilesExist()) {
|
if (AirtimeIni::IniFilesExist()) {
|
||||||
$userAnswer = "x";
|
$userAnswer = "x";
|
||||||
while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) {
|
while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) {
|
||||||
|
@ -106,8 +107,7 @@ else if (!isset($opts->p) && !isset($opts->o) && isset($opts->r)) {
|
||||||
if (in_array($userAnswer, array("o", "O"))) {
|
if (in_array($userAnswer, array("o", "O"))) {
|
||||||
$overwrite = true;
|
$overwrite = true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$overwrite = true;
|
$overwrite = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,8 +136,7 @@ AirtimeInstall::InstallStorageDirectory();
|
||||||
|
|
||||||
if ($db_install) {
|
if ($db_install) {
|
||||||
if($newInstall) {
|
if($newInstall) {
|
||||||
// This is called with "passthru" so that we can pass in a parameter. See the file itself
|
//call external script. "y" argument means force creation of database tables.
|
||||||
// for why we need to do this.
|
|
||||||
passthru('php '.__DIR__.'/airtime-db-install.php y');
|
passthru('php '.__DIR__.'/airtime-db-install.php y');
|
||||||
AirtimeInstall::DbConnect(true);
|
AirtimeInstall::DbConnect(true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,4 +22,5 @@ except Exception, e:
|
||||||
print 'Error loading config file: ', e
|
print 'Error loading config file: ', e
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
#copy python files
|
||||||
copy_dir("%s/../../api_clients"%current_script_dir, config["bin_dir"])
|
copy_dir("%s/../../api_clients"%current_script_dir, config["bin_dir"])
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
#-e Causes bash script to exit if any of the installers
|
||||||
|
#return with a non-zero return value.
|
||||||
|
|
||||||
|
if [ `whoami` != 'root' ]; then
|
||||||
|
echo "Please run as root user."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Absolute path to this script, e.g. /home/user/bin/foo.sh
|
||||||
|
SCRIPT=`readlink -f $0`
|
||||||
|
# Absolute path this script is in, thus /home/user/bin
|
||||||
|
SCRIPTPATH=`dirname $SCRIPT`
|
||||||
|
|
||||||
|
BIN_DIR=/usr/lib/airtime/api_clients
|
||||||
|
|
||||||
|
#copy api_client files
|
||||||
|
cp -R $SCRIPTPATH/../../api_clients $BIN_DIR
|
|
@ -0,0 +1,18 @@
|
||||||
|
from subprocess import Popen
|
||||||
|
import os
|
||||||
|
|
||||||
|
if os.geteuid() != 0:
|
||||||
|
print "Please run this as root."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
#update-rc.d init script
|
||||||
|
p = Popen("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True)
|
||||||
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
|
|
||||||
|
#Start media-monitor daemon
|
||||||
|
#p = Popen("/etc/init.d/airtime-media-monitor start-no-monit", shell=True)
|
||||||
|
p = Popen("/etc/init.d/airtime-media-monitor restart", shell=True)
|
||||||
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
|
@ -0,0 +1,60 @@
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
from configobj import ConfigObj
|
||||||
|
|
||||||
|
if os.geteuid() != 0:
|
||||||
|
print "Please run this as root."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def get_current_script_dir():
|
||||||
|
current_script_dir = os.path.realpath(__file__)
|
||||||
|
index = current_script_dir.rindex('/')
|
||||||
|
return current_script_dir[0:index]
|
||||||
|
|
||||||
|
def copy_dir(src_dir, dest_dir):
|
||||||
|
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||||
|
shutil.rmtree(dest_dir)
|
||||||
|
if not (os.path.exists(dest_dir)):
|
||||||
|
print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
||||||
|
shutil.copytree(src_dir, dest_dir)
|
||||||
|
|
||||||
|
def create_dir(path):
|
||||||
|
try:
|
||||||
|
os.makedirs(path)
|
||||||
|
except Exception, e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
PATH_INI_FILE = '/etc/airtime/media-monitor.cfg'
|
||||||
|
|
||||||
|
# load config file
|
||||||
|
try:
|
||||||
|
config = ConfigObj(PATH_INI_FILE)
|
||||||
|
except Exception, e:
|
||||||
|
print 'Error loading config file: ', e
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Absolute path this script is in
|
||||||
|
current_script_dir = get_current_script_dir()
|
||||||
|
|
||||||
|
#copy monit files
|
||||||
|
shutil.copy('%s/../monit-airtime-media-monitor.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
||||||
|
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
||||||
|
|
||||||
|
#create log dir
|
||||||
|
create_dir(config['log_dir'])
|
||||||
|
|
||||||
|
#copy python files
|
||||||
|
copy_dir("%s/.."%current_script_dir, config["bin_dir"])
|
||||||
|
|
||||||
|
#set executable permissions on python files
|
||||||
|
os.system("chown -R pypo:pypo "+config["bin_dir"])
|
||||||
|
|
||||||
|
#copy init.d script
|
||||||
|
shutil.copy(config["bin_dir"]+"/airtime-media-monitor-init-d", "/etc/init.d/airtime-media-monitor")
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
python media-monitor-install-files.py
|
||||||
|
python media-monitor-initialize.py
|
|
@ -0,0 +1,110 @@
|
||||||
|
import platform
|
||||||
|
import shutil
|
||||||
|
from subprocess import Popen
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
sys.path.append('/usr/lib/airtime/api_clients/')
|
||||||
|
import api_client
|
||||||
|
from configobj import ConfigObj
|
||||||
|
|
||||||
|
if os.geteuid() != 0:
|
||||||
|
print "Please run this as root."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def is_natty():
|
||||||
|
try:
|
||||||
|
f = open('/etc/lsb-release')
|
||||||
|
except IOError as e:
|
||||||
|
#File doesn't exist, so we're not even dealing with Ubuntu
|
||||||
|
return False
|
||||||
|
|
||||||
|
for line in f:
|
||||||
|
split = line.split("=")
|
||||||
|
split[0] = split[0].strip(" \r\n")
|
||||||
|
split[1] = split[1].strip(" \r\n")
|
||||||
|
if split[0] == "DISTRIB_CODENAME" and (split[1] == "natty" or split[1] == "oneiric"):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_current_script_dir():
|
||||||
|
current_script_dir = os.path.realpath(__file__)
|
||||||
|
index = current_script_dir.rindex('/')
|
||||||
|
return current_script_dir[0:index]
|
||||||
|
|
||||||
|
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']
|
||||||
|
if(temp == ""):
|
||||||
|
temp = ""
|
||||||
|
buffer += "\"" + temp + "\""
|
||||||
|
else:
|
||||||
|
temp = d[u'value']
|
||||||
|
if(temp == ""):
|
||||||
|
temp = "0"
|
||||||
|
buffer += temp
|
||||||
|
buffer += "\n"
|
||||||
|
fh.write(buffer)
|
||||||
|
fh.write("log_file = \"/var/log/airtime/pypo-liquidsoap/<script>.log\"\n");
|
||||||
|
fh.close()
|
||||||
|
|
||||||
|
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
|
||||||
|
|
||||||
|
# load config file
|
||||||
|
try:
|
||||||
|
config = ConfigObj(PATH_INI_FILE)
|
||||||
|
except Exception, e:
|
||||||
|
print 'Error loading config file: ', e
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
current_script_dir = get_current_script_dir()
|
||||||
|
|
||||||
|
#select appropriate liquidsoap file for given system os/architecture
|
||||||
|
architecture = platform.architecture()[0]
|
||||||
|
natty = is_natty()
|
||||||
|
|
||||||
|
if architecture == '64bit' and natty:
|
||||||
|
print "Installing 64-bit liquidsoap binary (Natty)"
|
||||||
|
shutil.copy("%s/../liquidsoap_bin/liquidsoap-natty-amd64"%current_script_dir, "%s/../liquidsoap_bin/liquidsoap"%current_script_dir)
|
||||||
|
elif architecture == '32bit' and natty:
|
||||||
|
print "Installing 32-bit liquidsoap binary (Natty)"
|
||||||
|
shutil.copy("%s/../liquidsoap_bin/liquidsoap-natty-i386"%current_script_dir, "%s/../liquidsoap_bin/liquidsoap"%current_script_dir)
|
||||||
|
elif architecture == '64bit' and not natty:
|
||||||
|
print "Installing 64-bit liquidsoap binary"
|
||||||
|
shutil.copy("%s/../liquidsoap_bin/liquidsoap-amd64"%current_script_dir, "%s/../liquidsoap_bin/liquidsoap"%current_script_dir)
|
||||||
|
elif architecture == '32bit' and not natty:
|
||||||
|
print "Installing 32-bit liquidsoap binary"
|
||||||
|
shutil.copy("%s/../liquidsoap_bin/liquidsoap-i386"%current_script_dir, "%s/../liquidsoap_bin/liquidsoap"%current_script_dir)
|
||||||
|
else:
|
||||||
|
print "Unknown system architecture."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
#initialize init.d scripts
|
||||||
|
p = Popen("update-rc.d airtime-playout defaults >/dev/null 2>&1", shell=True)
|
||||||
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
|
|
||||||
|
#generate liquidsoap config file
|
||||||
|
#access the DB and generate liquidsoap.cfg under /etc/airtime/
|
||||||
|
api_client = api_client.api_client_factory(config)
|
||||||
|
ss = api_client.get_stream_setting()
|
||||||
|
|
||||||
|
if ss is not None:
|
||||||
|
generate_liquidsoap_config(ss)
|
||||||
|
else:
|
||||||
|
print "Unable to connect to the Airtime server."
|
||||||
|
|
||||||
|
#restart airtime-playout
|
||||||
|
print "Waiting for processes to start..."
|
||||||
|
#p = Popen("/etc/init.d/airtime-playout start-no-monit", shell=True)
|
||||||
|
p = Popen("/etc/init.d/airtime-playout restart", shell=True)
|
||||||
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
|
@ -0,0 +1,78 @@
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
from configobj import ConfigObj
|
||||||
|
|
||||||
|
if os.geteuid() != 0:
|
||||||
|
print "Please run this as root."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def get_current_script_dir():
|
||||||
|
current_script_dir = os.path.realpath(__file__)
|
||||||
|
index = current_script_dir.rindex('/')
|
||||||
|
return current_script_dir[0:index]
|
||||||
|
|
||||||
|
def copy_dir(src_dir, dest_dir):
|
||||||
|
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||||
|
shutil.rmtree(dest_dir)
|
||||||
|
if not (os.path.exists(dest_dir)):
|
||||||
|
print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
||||||
|
shutil.copytree(src_dir, dest_dir)
|
||||||
|
|
||||||
|
def create_dir(path):
|
||||||
|
try:
|
||||||
|
os.makedirs(path)
|
||||||
|
except Exception, e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
|
||||||
|
|
||||||
|
# load config file
|
||||||
|
try:
|
||||||
|
config = ConfigObj(PATH_INI_FILE)
|
||||||
|
except Exception, e:
|
||||||
|
print 'Error loading config file: ', e
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Absolute path this script is in
|
||||||
|
current_script_dir = get_current_script_dir()
|
||||||
|
|
||||||
|
#copy monit files
|
||||||
|
shutil.copy('%s/../monit-airtime-playout.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
||||||
|
shutil.copy('%s/../monit-airtime-liquidsoap.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
||||||
|
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
||||||
|
|
||||||
|
#create pypo log dir
|
||||||
|
create_dir(config['pypo_log_dir'])
|
||||||
|
|
||||||
|
#create liquidsoap log dir
|
||||||
|
create_dir(config['liquidsoap_log_dir'])
|
||||||
|
|
||||||
|
#create cache, tmp, file dirs
|
||||||
|
create_dir(config['cache_dir'])
|
||||||
|
create_dir(config['file_dir'])
|
||||||
|
create_dir(config['tmp_dir'])
|
||||||
|
|
||||||
|
#copy files to bin dir
|
||||||
|
copy_dir("%s/.."%current_script_dir, config["bin_dir"]+"/bin/")
|
||||||
|
|
||||||
|
# delete /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap.cfg
|
||||||
|
# as we don't use it anymore.(CC-2552)
|
||||||
|
os.remove(config["bin_dir"]+"/bin/liquidsoap_scripts/liquidsoap.cfg")
|
||||||
|
|
||||||
|
#set permissions in bin dir and cache dir
|
||||||
|
os.system("chmod 755 "+os.path.join(config["bin_dir"], "bin/liquidsoap_scripts/notify.sh"))
|
||||||
|
os.system("chown -R pypo:pypo "+config["bin_dir"])
|
||||||
|
os.system("chown -R pypo:pypo "+config["cache_base_dir"])
|
||||||
|
|
||||||
|
#copy init.d script
|
||||||
|
shutil.copy(config["bin_dir"]+"/bin/airtime-playout-init-d", "/etc/init.d/airtime-playout")
|
||||||
|
|
||||||
|
#copy log rotate script
|
||||||
|
shutil.copy(config["bin_dir"]+"/bin/liquidsoap_scripts/airtime-liquidsoap.logrotate", "/etc/logrotate.d/airtime-liquidsoap")
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ def create_path(path):
|
||||||
|
|
||||||
def copy_dir(src_dir, dest_dir):
|
def copy_dir(src_dir, dest_dir):
|
||||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||||
#print "Removing old directory "+dest_dir
|
|
||||||
shutil.rmtree(dest_dir)
|
shutil.rmtree(dest_dir)
|
||||||
if not (os.path.exists(dest_dir)):
|
if not (os.path.exists(dest_dir)):
|
||||||
print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
python pypo-install-files.py
|
||||||
|
python pypo-initialize.py
|
|
@ -0,0 +1,20 @@
|
||||||
|
from subprocess import Popen
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if os.geteuid() != 0:
|
||||||
|
print "Please run this as root."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
#register init.d script
|
||||||
|
p = Popen("update-rc.d airtime-show-recorder defaults >/dev/null 2>&1", shell=True)
|
||||||
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
|
|
||||||
|
#start daemon
|
||||||
|
print "Waiting for processes to start..."
|
||||||
|
p = Popen("/etc/init.d/airtime-show-recorder stop", shell=True)
|
||||||
|
p = Popen("/etc/init.d/airtime-show-recorder start-no-monit", shell=True)
|
||||||
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
|
@ -0,0 +1,67 @@
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
from configobj import ConfigObj
|
||||||
|
|
||||||
|
if os.geteuid() != 0:
|
||||||
|
print "Please run this as root."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def get_current_script_dir():
|
||||||
|
current_script_dir = os.path.realpath(__file__)
|
||||||
|
index = current_script_dir.rindex('/')
|
||||||
|
return current_script_dir[0:index]
|
||||||
|
|
||||||
|
def copy_dir(src_dir, dest_dir):
|
||||||
|
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||||
|
shutil.rmtree(dest_dir)
|
||||||
|
if not (os.path.exists(dest_dir)):
|
||||||
|
print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
||||||
|
shutil.copytree(src_dir, dest_dir)
|
||||||
|
|
||||||
|
def create_dir(path):
|
||||||
|
try:
|
||||||
|
os.makedirs(path)
|
||||||
|
except Exception, e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
PATH_INI_FILE = '/etc/airtime/recorder.cfg'
|
||||||
|
|
||||||
|
# load config file
|
||||||
|
try:
|
||||||
|
config = ConfigObj(PATH_INI_FILE)
|
||||||
|
except Exception, e:
|
||||||
|
print 'Error loading config file: ', e
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Absolute path this script is in
|
||||||
|
current_script_dir = get_current_script_dir()
|
||||||
|
|
||||||
|
#create temporary media-storage directory
|
||||||
|
print "Creating temporary media storage directory"
|
||||||
|
create_dir(config["base_recorded_files"])
|
||||||
|
#os.system("chmod -R 755 "+config["base_recorded_files"])
|
||||||
|
os.system("chown -R pypo:pypo "+config["base_recorded_files"])
|
||||||
|
|
||||||
|
#create log directories
|
||||||
|
print "Creating log directories"
|
||||||
|
create_dir(config["log_dir"])
|
||||||
|
os.system("chmod -R 755 " + config["log_dir"])
|
||||||
|
os.system("chown -R pypo:pypo "+config["log_dir"])
|
||||||
|
|
||||||
|
#copy python files
|
||||||
|
copy_dir("%s/.."%current_script_dir, config["bin_dir"])
|
||||||
|
|
||||||
|
#set python file permissions
|
||||||
|
print "Setting permissions"
|
||||||
|
os.system("chmod -R 755 "+config["bin_dir"])
|
||||||
|
os.system("chown -R pypo:pypo "+config["bin_dir"])
|
||||||
|
|
||||||
|
#copy init.d script
|
||||||
|
shutil.copy(config["bin_dir"]+"/airtime-show-recorder-init-d", "/etc/init.d/airtime-show-recorder")
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
python recorder-install-files.py
|
||||||
|
python recorder-initialize.py
|
Loading…
Reference in New Issue