CC-2758: Make airtime-install script Debian/Ubuntu compatible
-initial commit
This commit is contained in:
parent
d26e410799
commit
8cafc52cad
16 changed files with 491 additions and 15 deletions
|
@ -22,4 +22,5 @@ except Exception, e:
|
|||
print 'Error loading config file: ', e
|
||||
sys.exit(1)
|
||||
|
||||
#copy python files
|
||||
copy_dir("%s/../../api_clients"%current_script_dir, config["bin_dir"])
|
||||
|
|
19
python_apps/api_clients/install/api_client_install.sh
Normal file
19
python_apps/api_clients/install/api_client_install.sh
Normal file
|
@ -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
|
||||
|
||||
|
4
python_apps/media-monitor/install/media-monitor-install.sh
Executable file
4
python_apps/media-monitor/install/media-monitor-install.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
python media-monitor-install-files.py
|
||||
python media-monitor-initialize.py
|
110
python_apps/pypo/install/pypo-initialize.py
Normal file
110
python_apps/pypo/install/pypo-initialize.py
Normal file
|
@ -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
|
78
python_apps/pypo/install/pypo-install-files.py
Normal file
78
python_apps/pypo/install/pypo-install-files.py
Normal file
|
@ -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):
|
||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||
#print "Removing old directory "+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)
|
4
python_apps/pypo/install/pypo-install.sh
Executable file
4
python_apps/pypo/install/pypo-install.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
python pypo-install-files.py
|
||||
python pypo-initialize.py
|
20
python_apps/show-recorder/install/recorder-initialize.py
Normal file
20
python_apps/show-recorder/install/recorder-initialize.py
Normal file
|
@ -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
|
67
python_apps/show-recorder/install/recorder-install-files.py
Normal file
67
python_apps/show-recorder/install/recorder-install-files.py
Normal file
|
@ -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
|
||||
|
||||
|
4
python_apps/show-recorder/install/recorder-install.sh
Executable file
4
python_apps/show-recorder/install/recorder-install.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
python recorder-install-files.py
|
||||
python recorder-initialize.py
|
Loading…
Add table
Add a link
Reference in a new issue