cc-2055: switch to init.d
-allow install script to be created from any location (no hardcoded paths) -make python install scripts return 1 on error -daemon now started automatically on boot using rc.local autostart -change all prints to logs instead -create airtime-uninstall shell script (and remove pypo user in here) -create pypo user in shell script
This commit is contained in:
parent
079d9d36b0
commit
6ab5ac4582
|
@ -4,20 +4,29 @@
|
|||
#return with a non-zero return value.
|
||||
set -e
|
||||
|
||||
echo -e "\n******************************** Install Begin *********************************";
|
||||
# Absolute path to this script
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute directory this script is in
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
php airtime-install.php $@
|
||||
echo -e "\n******************************** Install Begin *********************************"
|
||||
|
||||
echo "*** Pypo Installation ***"
|
||||
#python ".__DIR__."/../python_apps/pypo/install/pypo-install.py
|
||||
python ../python_apps/pypo/install/pypo-install.py
|
||||
php ${SCRIPTPATH}/airtime-install.php $@
|
||||
|
||||
echo -e "\n*** Creating Pypo User ***"
|
||||
python ${SCRIPTPATH}/../python_apps/create-pypo-user.py
|
||||
|
||||
echo -e "\n*** Pypo Installation ***"
|
||||
python ${SCRIPTPATH}/../python_apps/pypo/install/pypo-install.py
|
||||
|
||||
#echo -e "\n*** Recorder Installation ***"
|
||||
#python ${SCRIPTPATH}/../python_apps/show-recorder/install/recorder-install.py
|
||||
|
||||
#echo -e "\n*** Media Monitor Installation ***"
|
||||
#python ${SCRIPTPATH}/../python_apps/pytag-fs/install/media-monitor-install.py
|
||||
|
||||
#echo "*** Recorder Installation ***"
|
||||
#python ".__DIR__."/../python_apps/show-recorder/install/recorder-install.py
|
||||
#python ../python_apps/show-recorder/install/recorder-install.py
|
||||
|
||||
sleep 4
|
||||
|
||||
airtime-check-system
|
||||
|
||||
echo -e "\n******************************* Install Complete *******************************";
|
||||
echo -e "\n******************************* Install Complete *******************************"
|
||||
|
|
|
@ -123,7 +123,5 @@ AirtimeInstall::CreateSymlinksToUtils();
|
|||
|
||||
AirtimeInstall::CreateZendPhpLogFile();
|
||||
|
||||
//wait for 1.9.0 release
|
||||
//echo PHP_EOL."*** Media Monitor Installation ***".PHP_EOL;
|
||||
//system("python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-install.py");
|
||||
|
||||
/* FINISHED AIRTIME PHP INSTALLER */
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Absolute path to this script
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute directory this script is in
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
echo -e "\n******************************* Uninstall Begin ********************************"
|
||||
|
||||
php ${SCRIPTPATH}/airtime-uninstall.php
|
||||
|
||||
echo -e "\n*** Uninstalling Pypo ***"
|
||||
python ${SCRIPTPATH}/../python_apps/pypo/install/pypo-uninstall.py
|
||||
|
||||
#echo -e "\n*** Uninstalling Show Recorder ***"
|
||||
#python ${SCRIPTPATH}/../python_apps/show-recorder/install/recorder-uninstall.py
|
||||
|
||||
#echo -e "\n*** Uninstalling Media Monitor ***"
|
||||
#python ${SCRIPTPATH}/../python_apps/pytag-fs/install/media-monitor-uninstall.py
|
||||
|
||||
echo -e "\n*** Removing Pypo User ***"
|
||||
python ${SCRIPTPATH}/../python_apps/remove-pypo-user.py
|
||||
|
||||
echo -e "\n****************************** Uninstall Complete ******************************\n"
|
||||
echo "NOTE: To fully remove all Airtime files, you will also have to manually delete"
|
||||
echo " the directories '/srv/airtime'(default storage location of media files)"
|
||||
echo -e " and '/etc/airtime'(where the config files are stored).\n"
|
|
@ -19,7 +19,6 @@ require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.
|
|||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||
|
||||
echo PHP_EOL;
|
||||
echo "******************************* Uninstall Begin ********************************".PHP_EOL;
|
||||
echo "* Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL;
|
||||
AirtimeInstall::UninstallPhpCode();
|
||||
|
||||
|
@ -81,18 +80,7 @@ if ($results == 0) {
|
|||
# Disabled as this should be a manual process
|
||||
#AirtimeInstall::DeleteFilesRecursive(AirtimeInstall::CONF_DIR_STORAGE);
|
||||
|
||||
echo PHP_EOL."*** Uninstalling Pypo ***".PHP_EOL;
|
||||
$command = "python ".__DIR__."/../python_apps/pypo/install/pypo-uninstall.py";
|
||||
system($command);
|
||||
|
||||
echo PHP_EOL."*** Uninstalling Show Recorder ***".PHP_EOL;
|
||||
$command = "python ".__DIR__."/../python_apps/show-recorder/install/recorder-uninstall.py";
|
||||
system($command);
|
||||
|
||||
//wait for 1.9.0 release
|
||||
//echo PHP_EOL."*** Uninstalling Media Monitor ***".PHP_EOL;
|
||||
//$command = "python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-uninstall.py";
|
||||
//system($command);
|
||||
|
||||
#Disabled as this should be a manual process
|
||||
#AirtimeIni::RemoveIniFiles();
|
||||
|
@ -101,10 +89,4 @@ AirtimeInstall::RemoveSymlinks();
|
|||
AirtimeInstall::UninstallBinaries();
|
||||
AirtimeInstall::RemoveLogDirectories();
|
||||
|
||||
echo PHP_EOL;
|
||||
echo "****************************** Uninstall Complete ******************************".PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
echo "NOTE: To fully remove all Airtime files, you will also have to manually delete".PHP_EOL;
|
||||
echo " the directories '".AirtimeInstall::CONF_DIR_STORAGE."'(where the media files are stored)".PHP_EOL;
|
||||
echo " and '/etc/airtime'(where the config files are stored).".PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
/* FINISHED AIRTIME PHP UNINSTALLER */
|
||||
|
|
|
@ -22,13 +22,13 @@ from urlparse import urlparse
|
|||
AIRTIME_VERSION = "1.9.0-devel"
|
||||
|
||||
def api_client_factory(config):
|
||||
logger = logging.getLogger()
|
||||
if config["api_client"] == "airtime":
|
||||
return AirTimeApiClient(config)
|
||||
elif config["api_client"] == "obp":
|
||||
return ObpApiClient(config)
|
||||
else:
|
||||
print 'API Client "'+config["api_client"]+'" not supported. Please check your config file.'
|
||||
print
|
||||
logger.info('API Client "'+config["api_client"]+'" not supported. Please check your config file.\n')
|
||||
sys.exit()
|
||||
|
||||
def recursive_urlencode(d):
|
||||
|
@ -155,18 +155,18 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
except Exception, e:
|
||||
if e[1] == 401:
|
||||
if (verbose):
|
||||
print '#####################################'
|
||||
print '# YOUR API KEY SEEMS TO BE INVALID:'
|
||||
print '# ' + self.config["api_key"]
|
||||
print '#####################################'
|
||||
logger.info('#####################################')
|
||||
logger.info('# YOUR API KEY SEEMS TO BE INVALID:')
|
||||
logger.info('# ' + self.config["api_key"])
|
||||
logger.info('#####################################')
|
||||
return -1
|
||||
|
||||
if e[1] == 404:
|
||||
if (verbose):
|
||||
print '#####################################'
|
||||
print '# Unable to contact the Airtime-API'
|
||||
print '# ' + url
|
||||
print '#####################################'
|
||||
logger.info('#####################################')
|
||||
logger.info('# Unable to contact the Airtime-API')
|
||||
logger.info('# ' + url)
|
||||
logger.info('#####################################')
|
||||
return -1
|
||||
|
||||
logger.error("Unable to detect Airtime Version - %s, Response: %s", e, response)
|
||||
|
@ -190,23 +190,21 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
|
||||
|
||||
def is_server_compatible(self, verbose = True):
|
||||
logger = logging.getLogger()
|
||||
version = self.__get_airtime_version(verbose)
|
||||
if (version == -1):
|
||||
if (verbose):
|
||||
print 'Unable to get Airtime version number.'
|
||||
print
|
||||
logger.info('Unable to get Airtime version number.\n')
|
||||
return False
|
||||
elif (version[0:3] != AIRTIME_VERSION[0:3]):
|
||||
if (verbose):
|
||||
print 'Airtime version found: ' + str(version)
|
||||
print 'pypo is at version ' +AIRTIME_VERSION+' and is not compatible with this version of Airtime.'
|
||||
print
|
||||
logger.info('Airtime version found: ' + str(version))
|
||||
logger.info('pypo is at version ' +AIRTIME_VERSION+' and is not compatible with this version of Airtime.\n')
|
||||
return False
|
||||
else:
|
||||
if (verbose):
|
||||
print 'Airtime version: ' + str(version)
|
||||
print 'pypo is at version ' +AIRTIME_VERSION+' and is compatible with this version of Airtime.'
|
||||
print
|
||||
logger.info('Airtime version: ' + str(version))
|
||||
logger.info('pypo is at version ' +AIRTIME_VERSION+' and is compatible with this version of Airtime.')
|
||||
return True
|
||||
|
||||
|
||||
|
@ -226,7 +224,7 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
response = json.loads(response_json)
|
||||
status = response['check']
|
||||
except Exception, e:
|
||||
print e
|
||||
logger.error(e)
|
||||
|
||||
return status, response
|
||||
|
||||
|
@ -393,29 +391,25 @@ class ObpApiClient():
|
|||
self.api_auth = urllib.urlencode({'api_key': self.config["api_key"]})
|
||||
|
||||
def is_server_compatible(self, verbose = True):
|
||||
logger = logging.getLogger()
|
||||
obp_version = self.get_obp_version()
|
||||
|
||||
if obp_version == 0:
|
||||
if (verbose):
|
||||
print '#################################################'
|
||||
print 'Unable to get OBP version. Is OBP up and running?'
|
||||
print '#################################################'
|
||||
print
|
||||
logger.error('Unable to get OBP version. Is OBP up and running?\n')
|
||||
return False
|
||||
elif obp_version < OBP_MIN_VERSION:
|
||||
if (verbose):
|
||||
print 'OBP version: ' + str(obp_version)
|
||||
print 'OBP min-version: ' + str(OBP_MIN_VERSION)
|
||||
print 'pypo not compatible with this version of OBP'
|
||||
print
|
||||
logger.warn('OBP version: ' + str(obp_version))
|
||||
logger.warn('OBP min-version: ' + str(OBP_MIN_VERSION))
|
||||
logger.warn('pypo not compatible with this version of OBP\n')
|
||||
return False
|
||||
else:
|
||||
if (verbose):
|
||||
print 'OBP API: ' + str(API_BASE)
|
||||
print 'OBP version: ' + str(obp_version)
|
||||
print 'OBP min-version: ' + str(OBP_MIN_VERSION)
|
||||
print 'pypo is compatible with this version of OBP'
|
||||
print
|
||||
logger.warn('OBP API: ' + str(API_BASE))
|
||||
logger.warn('OBP version: ' + str(obp_version))
|
||||
logger.warn('OBP min-version: ' + str(OBP_MIN_VERSION))
|
||||
logger.warn('pypo is compatible with this version of OBP\n')
|
||||
return True
|
||||
|
||||
|
||||
|
@ -437,10 +431,10 @@ class ObpApiClient():
|
|||
except Exception, e:
|
||||
try:
|
||||
if e[1] == 401:
|
||||
print '#####################################'
|
||||
print '# YOUR API KEY SEEMS TO BE INVALID'
|
||||
print '# ' + self.config["api_auth"]
|
||||
print '#####################################'
|
||||
logger.error('#####################################')
|
||||
logger.error('# YOUR API KEY SEEMS TO BE INVALID')
|
||||
logger.error('# ' + self.config["api_auth"])
|
||||
logger.error('#####################################')
|
||||
sys.exit()
|
||||
|
||||
except Exception, e:
|
||||
|
@ -448,10 +442,10 @@ class ObpApiClient():
|
|||
|
||||
try:
|
||||
if e[1] == 404:
|
||||
print '#####################################'
|
||||
print '# Unable to contact the OBP-API'
|
||||
print '# ' + url
|
||||
print '#####################################'
|
||||
logger.error('#####################################')
|
||||
logger.error('# Unable to contact the OBP-API')
|
||||
logger.error('# ' + url)
|
||||
logger.error('#####################################')
|
||||
sys.exit()
|
||||
|
||||
except Exception, e:
|
||||
|
@ -502,15 +496,14 @@ class ObpApiClient():
|
|||
logger.info("export status %s", response['check'])
|
||||
status = response['check']
|
||||
except Exception, e:
|
||||
print e
|
||||
logger.error(e)
|
||||
|
||||
return status, response
|
||||
|
||||
|
||||
def get_media(self, src, dest):
|
||||
try:
|
||||
print '** urllib auth with: ',
|
||||
print self.api_auth
|
||||
logger.info('** urllib auth with: ' + self.api_auth)
|
||||
urllib.urlretrieve(src, dst, False, self.api_auth)
|
||||
logger.info("downloaded %s to %s", src, dst)
|
||||
except Exception, e:
|
||||
|
@ -535,7 +528,6 @@ class ObpApiClient():
|
|||
logger.info("API-Message %s", response['message'])
|
||||
|
||||
except Exception, e:
|
||||
print e
|
||||
api_status = False
|
||||
logger.error("Unable to connect to the OBP API - %s", e)
|
||||
|
||||
|
@ -561,7 +553,7 @@ class ObpApiClient():
|
|||
url = url.replace("%%media_id%%", str(media_id))
|
||||
url = url.replace("%%playlist_id%%", str(playlist_id))
|
||||
url = url.replace("%%transmission_id%%", str(transmission_id))
|
||||
print url
|
||||
logger.info(url)
|
||||
|
||||
try:
|
||||
response = urllib.urlopen(url, self.api_auth)
|
||||
|
@ -571,7 +563,6 @@ class ObpApiClient():
|
|||
logger.info("TXT %s", response['str_dls'])
|
||||
|
||||
except Exception, e:
|
||||
print e
|
||||
api_status = False
|
||||
logger.error("Unable to connect to the OBP API - %s", e)
|
||||
|
||||
|
@ -592,7 +583,6 @@ class ObpApiClient():
|
|||
logger.info("API-Message %s", response['message'])
|
||||
|
||||
except Exception, e:
|
||||
print e
|
||||
api_status = False
|
||||
logger.error("Unable to handle the OBP API request - %s", e)
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
|
||||
def create_user(username):
|
||||
print "Checking for user "+username
|
||||
|
||||
p = Popen('id '+username, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
||||
output = p.stdout.read()
|
||||
|
||||
if (output[0:3] != "uid"):
|
||||
# Make the pypo user
|
||||
print "Creating user "+username
|
||||
os.system("adduser --system --quiet --group --shell /bin/bash "+username)
|
||||
|
||||
#set pypo password
|
||||
p = os.popen('/usr/bin/passwd pypo 1>/dev/null 2>&1', 'w')
|
||||
p.write('pypo\n')
|
||||
p.write('pypo\n')
|
||||
p.close()
|
||||
else:
|
||||
print "User already exists."
|
||||
#add pypo to audio group
|
||||
os.system("adduser " + username + " audio 1>/dev/null 2>&1")
|
||||
#add pypo to www-data group
|
||||
os.system("adduser " + username + " www-data 1>/dev/null 2>&1")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
create_user("pypo")
|
|
@ -33,7 +33,8 @@ except Exception, e:
|
|||
try:
|
||||
config = ConfigObj('/etc/airtime/MediaMonitor.cfg')
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
logger = logging.getLogger();
|
||||
logger.error('Error loading config file: %s', e)
|
||||
sys.exit()
|
||||
|
||||
"""
|
||||
|
|
|
@ -14,7 +14,7 @@ import shutil
|
|||
import string
|
||||
import platform
|
||||
from configobj import ConfigObj
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from subprocess import Popen
|
||||
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
|
@ -27,27 +27,6 @@ def create_path(path):
|
|||
print "Creating directory " + path
|
||||
os.makedirs(path)
|
||||
|
||||
def create_user(username):
|
||||
print "Checking for user "+username
|
||||
p = Popen('id '+username, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
||||
output = p.stdout.read()
|
||||
if (output[0:3] != "uid"):
|
||||
# Make the pypo user
|
||||
print "Creating user "+username
|
||||
os.system("adduser --system --quiet --group --shell /bin/bash "+username)
|
||||
|
||||
#set pypo password
|
||||
p = os.popen('/usr/bin/passwd pypo 1>/dev/null 2>&1', 'w')
|
||||
p.write('pypo\n')
|
||||
p.write('pypo\n')
|
||||
p.close()
|
||||
else:
|
||||
print "User already exists."
|
||||
#add pypo to audio group
|
||||
os.system("adduser " + username + " audio 1>/dev/null 2>&1")
|
||||
#add pypo to www-data group
|
||||
os.system("adduser " + username + " www-data 1>/dev/null 2>&1")
|
||||
|
||||
def copy_dir(src_dir, dest_dir):
|
||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||
print "Removing old directory "+dest_dir
|
||||
|
@ -59,7 +38,6 @@ def copy_dir(src_dir, dest_dir):
|
|||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
#print current_script_dir[0:index]
|
||||
return current_script_dir[0:index]
|
||||
|
||||
|
||||
|
@ -69,18 +47,13 @@ try:
|
|||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
|
||||
current_script_dir = get_current_script_dir()
|
||||
#print "Checking and removing any existing media monitor processes"
|
||||
#os.system("python %s/media-monitor-uninstall.py 1>/dev/null 2>&1"% current_script_dir)
|
||||
#time.sleep(5)
|
||||
|
||||
p = Popen("/etc/init.d/airtime-media-monitor stop", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
# Create users
|
||||
create_user("pypo")
|
||||
|
||||
print "Creating log directories"
|
||||
create_path(config["log_dir"])
|
||||
os.system("chmod -R 755 " + config["log_dir"])
|
||||
|
@ -98,6 +71,9 @@ try:
|
|||
|
||||
print "Installing media-monitor daemon"
|
||||
shutil.copy(config["bin_dir"]+"/airtime-media-monitor-init-d", "/etc/init.d/airtime-media-monitor")
|
||||
|
||||
p = Popen("update-rc.d airtime-media-monitor defaults", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
print "Waiting for processes to start..."
|
||||
p = Popen("/etc/init.d/airtime-media-monitor start", shell=True)
|
||||
|
|
|
@ -15,15 +15,6 @@ PATH_INI_FILE = '/etc/airtime/MediaMonitor.cfg'
|
|||
def remove_path(path):
|
||||
os.system("rm -rf " + path)
|
||||
|
||||
def remove_user(username):
|
||||
os.system("killall -u %s 1>/dev/null 2>&1" % username)
|
||||
|
||||
#allow all process to be completely closed before we attempt to delete user
|
||||
print "Waiting for processes to close..."
|
||||
time.sleep(5)
|
||||
|
||||
os.system("deluser --remove-home " + username + " 1>/dev/null 2>&1")
|
||||
|
||||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
|
@ -35,9 +26,10 @@ try:
|
|||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
|
||||
os.system("/etc/init.d/airtime-media-monitor stop")
|
||||
os.system("rm -f /etc/init.d/airtime-media-monitor")
|
||||
|
||||
print "Removing log directories"
|
||||
remove_path(config["log_dir"])
|
||||
|
@ -48,7 +40,6 @@ try:
|
|||
print "Removing application files"
|
||||
remove_path(config["bin_dir"])
|
||||
|
||||
remove_user("pypo")
|
||||
print "Uninstall complete."
|
||||
except Exception, e:
|
||||
print "exception:" + str(e)
|
||||
|
|
|
@ -14,7 +14,7 @@ import shutil
|
|||
import string
|
||||
import platform
|
||||
from configobj import ConfigObj
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from subprocess import Popen
|
||||
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
|
@ -29,27 +29,6 @@ def create_path(path):
|
|||
else:
|
||||
print "Directory already exists " + path
|
||||
|
||||
def create_user(username):
|
||||
print "Checking for user "+username
|
||||
p = Popen('id '+username, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
||||
output = p.stdout.read()
|
||||
if (output[0:3] != "uid"):
|
||||
# Make the pypo user
|
||||
print "Creating user "+username
|
||||
os.system("adduser --system --quiet --group --shell /bin/bash "+username)
|
||||
|
||||
#set pypo password
|
||||
p = os.popen('/usr/bin/passwd pypo 1>/dev/null 2>&1', 'w')
|
||||
p.write('pypo\n')
|
||||
p.write('pypo\n')
|
||||
p.close()
|
||||
else:
|
||||
print "User already exists."
|
||||
#add pypo to audio group
|
||||
os.system("adduser " + username + " audio 1>/dev/null 2>&1")
|
||||
#add pypo to pulse-access group
|
||||
#os.system("adduser " + username + " pulse-access 1>/dev/null 2>&1")
|
||||
|
||||
def copy_dir(src_dir, dest_dir):
|
||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||
#print "Removing old directory "+dest_dir
|
||||
|
@ -61,7 +40,6 @@ def copy_dir(src_dir, dest_dir):
|
|||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
#print current_script_dir[0:index]
|
||||
return current_script_dir[0:index]
|
||||
|
||||
def is_natty():
|
||||
|
@ -86,18 +64,13 @@ try:
|
|||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
|
||||
current_script_dir = get_current_script_dir()
|
||||
#print "Checking and removing any existing pypo processes"
|
||||
#os.system("python %s/pypo-uninstall.py 1>/dev/null 2>&1"% current_script_dir)
|
||||
#time.sleep(5)
|
||||
|
||||
p = Popen("/etc/init.d/airtime-playout stop", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
# Create users
|
||||
create_user("pypo")
|
||||
|
||||
create_path(config["pypo_log_dir"])
|
||||
os.system("chmod -R 755 " + config["pypo_log_dir"])
|
||||
os.system("chown -R pypo:pypo "+config["pypo_log_dir"])
|
||||
|
@ -148,9 +121,13 @@ try:
|
|||
print "Installing pypo daemon"
|
||||
shutil.copy(config["bin_dir"]+"/bin/airtime-playout-init-d", "/etc/init.d/airtime-playout")
|
||||
|
||||
p = Popen("update-rc.d airtime-playout defaults", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
print "Waiting for processes to start..."
|
||||
p = Popen("/etc/init.d/airtime-playout start", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
|
||||
except Exception, e:
|
||||
print "exception:" + str(e)
|
||||
|
|
|
@ -15,15 +15,6 @@ PATH_INI_FILE = '/etc/airtime/pypo.cfg'
|
|||
def remove_path(path):
|
||||
os.system("rm -rf " + path)
|
||||
|
||||
def remove_user(username):
|
||||
os.system("killall -u %s 1>/dev/null 2>&1" % username)
|
||||
|
||||
#allow all process to be completely closed before we attempt to delete user
|
||||
print "Waiting for processes to close..."
|
||||
time.sleep(5)
|
||||
|
||||
os.system("deluser --remove-home " + username + " 1>/dev/null 2>&1")
|
||||
|
||||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
|
@ -35,9 +26,10 @@ try:
|
|||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
|
||||
os.system("/etc/init.d/airtime-playout stop")
|
||||
os.system("rm -f /etc/init.d/airtime-playout")
|
||||
|
||||
print "Removing cache directories"
|
||||
remove_path(config["cache_base_dir"])
|
||||
|
@ -48,7 +40,6 @@ try:
|
|||
print "Removing pypo files"
|
||||
remove_path(config["bin_dir"])
|
||||
|
||||
remove_user("pypo")
|
||||
print "Pypo uninstall complete."
|
||||
except Exception, e:
|
||||
print "exception:" + str(e)
|
||||
|
|
|
@ -49,7 +49,8 @@ logging.config.fileConfig("logging.cfg")
|
|||
try:
|
||||
config = ConfigObj('/etc/airtime/pypo.cfg')
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
logger = logging.getLogger()
|
||||
logger.error('Error loading config file: %s', e)
|
||||
sys.exit()
|
||||
|
||||
class Global:
|
||||
|
@ -71,6 +72,7 @@ class Global:
|
|||
def test_api(self):
|
||||
self.api_client.test()
|
||||
|
||||
"""
|
||||
def check_schedule(self, export_source):
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
@ -97,17 +99,20 @@ class Global:
|
|||
|
||||
for media in playlist['medias']:
|
||||
print media
|
||||
"""
|
||||
|
||||
def keyboardInterruptHandler(signum, frame):
|
||||
print "\nKeyboard Interrupt\n"
|
||||
sys.exit();
|
||||
logger = logging.getLogger()
|
||||
logger.info('\nKeyboard Interrupt\n')
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print '###########################################'
|
||||
print '# *** pypo *** #'
|
||||
print '# Liquidsoap Scheduled Playout System #'
|
||||
print '###########################################'
|
||||
logger = logging.getLogger()
|
||||
logger.info('###########################################')
|
||||
logger.info('# *** pypo *** #')
|
||||
logger.info('# Liquidsoap Scheduled Playout System #')
|
||||
logger.info('###########################################')
|
||||
|
||||
signal.signal(signal.SIGINT, keyboardInterruptHandler)
|
||||
|
||||
|
@ -120,10 +125,7 @@ if __name__ == '__main__':
|
|||
# initialize
|
||||
g = Global()
|
||||
|
||||
#NOTE: MUST EXIT HERE!! while not g.selfcheck(): time.sleep()
|
||||
#Causes pypo to hang on system boot!!!
|
||||
if not g.selfcheck():
|
||||
sys.exit()
|
||||
while not g.selfcheck(): time.sleep(5)
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ try:
|
|||
POLL_INTERVAL = int(config['poll_interval'])
|
||||
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
logger = logging.getLogger()
|
||||
logger.error('Error loading config file: %s', e)
|
||||
sys.exit()
|
||||
|
||||
# Yuk - using a global, i know!
|
||||
|
@ -242,8 +243,7 @@ class PypoFetch(Thread):
|
|||
|
||||
#logger.debug("everything ok, adding %s to playlist", pl_entry)
|
||||
else:
|
||||
print 'zero-file: ' + dst + ' from ' + media['uri']
|
||||
logger.warning("zero-size file - skipping %s. will not add it to playlist", dst)
|
||||
logger.warning("zero-size file - skipping %s. will not add it to playlist at %s", media['uri'], dst)
|
||||
|
||||
else:
|
||||
logger.warning("something went wrong. file %s not available. will not add it to playlist", dst)
|
||||
|
@ -325,8 +325,7 @@ class PypoFetch(Thread):
|
|||
else:
|
||||
logger.info('sucessfully removed %s', os.path.join(r, dir))
|
||||
except Exception, e:
|
||||
print e
|
||||
logger.error("%s", e)
|
||||
logger.error(e)
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
@ -27,6 +27,7 @@ try:
|
|||
LS_PORT = config['ls_port']
|
||||
PUSH_INTERVAL = 2
|
||||
except Exception, e:
|
||||
logger = logging.getLogger()
|
||||
logger.error('Error loading config file %s', e)
|
||||
sys.exit()
|
||||
|
||||
|
|
|
@ -61,12 +61,10 @@ class CueFile():
|
|||
|
||||
command = 'mp3cut -o %s -t %s-%s %s' % (dst + '.tmp.mp3', str_cue_in, str_cue_out, src);
|
||||
logger.info("command: %s", command)
|
||||
print command
|
||||
os.system(command + ' > /dev/null 2>&1')
|
||||
|
||||
command = 'lame -b 128 %s %s' % (dst + '.tmp.mp3', dst);
|
||||
logger.info("command: %s", command)
|
||||
print command
|
||||
os.system(command + ' > /dev/null 2>&1')
|
||||
elif src.lower().endswith('.ogg'):
|
||||
audio = OggVorbis(src)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import os
|
||||
import time
|
||||
|
||||
def remove_user(username):
|
||||
os.system("killall -u %s 1>/dev/null 2>&1" % username)
|
||||
|
||||
#allow all process to be completely closed before we attempt to delete user
|
||||
print "Waiting for processes to close..."
|
||||
time.sleep(3)
|
||||
|
||||
os.system("deluser --remove-home " + username + " 1>/dev/null 2>&1")
|
||||
|
||||
if __name__ == "__main__":
|
||||
remove_user("pypo")
|
|
@ -14,7 +14,7 @@ import shutil
|
|||
import string
|
||||
import platform
|
||||
from configobj import ConfigObj
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from subprocess import Popen
|
||||
|
||||
if os.geteuid() != 0:
|
||||
print "Please run this as root."
|
||||
|
@ -27,25 +27,6 @@ def create_path(path):
|
|||
print "Creating directory " + path
|
||||
os.makedirs(path)
|
||||
|
||||
def create_user(username):
|
||||
print "Checking for user "+username
|
||||
p = Popen('id '+username, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
|
||||
output = p.stdout.read()
|
||||
if (output[0:3] != "uid"):
|
||||
# Make the pypo user
|
||||
print "Creating user "+username
|
||||
os.system("adduser --system --quiet --group --shell /bin/bash "+username)
|
||||
|
||||
#set pypo password
|
||||
p = os.popen('/usr/bin/passwd pypo 1>/dev/null 2>&1', 'w')
|
||||
p.write('pypo\n')
|
||||
p.write('pypo\n')
|
||||
p.close()
|
||||
else:
|
||||
print "User already exists."
|
||||
#add pypo to audio group
|
||||
os.system("adduser " + username + " audio 1>/dev/null 2>&1")
|
||||
|
||||
def copy_dir(src_dir, dest_dir):
|
||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||
print "Removing old directory "+dest_dir
|
||||
|
@ -57,7 +38,6 @@ def copy_dir(src_dir, dest_dir):
|
|||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
#print current_script_dir[0:index]
|
||||
return current_script_dir[0:index]
|
||||
|
||||
|
||||
|
@ -67,18 +47,13 @@ try:
|
|||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
|
||||
current_script_dir = get_current_script_dir()
|
||||
#print "Checking and removing any existing recorder processes"
|
||||
#os.system("python %s/recorder-uninstall.py 1>/dev/null 2>&1"% current_script_dir)
|
||||
#time.sleep(5)
|
||||
|
||||
p = Popen("/etc/init.d/airtime-show-recorder stop", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
# Create users
|
||||
create_user("pypo")
|
||||
|
||||
print "Creating temporary media storage directory"
|
||||
create_path(config["base_recorded_files"])
|
||||
os.system("chmod -R 755 "+config["base_recorded_files"])
|
||||
|
@ -102,6 +77,9 @@ try:
|
|||
print "Installing show-recorder daemon"
|
||||
shutil.copy(config["bin_dir"]+"/airtime-show-recorder-init-d", "/etc/init.d/airtime-show-recorder")
|
||||
|
||||
p = Popen("update-rc.d airtime-show-recorder defaults", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
||||
print "Waiting for processes to start..."
|
||||
p = Popen("/etc/init.d/airtime-show-recorder start", shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
|
|
@ -15,15 +15,6 @@ PATH_INI_FILE = '/etc/airtime/recorder.cfg'
|
|||
def remove_path(path):
|
||||
os.system("rm -rf " + path)
|
||||
|
||||
def remove_user(username):
|
||||
os.system("killall -u %s 1>/dev/null 2>&1" % username)
|
||||
|
||||
#allow all process to be completely closed before we attempt to delete user
|
||||
print "Waiting for processes to close..."
|
||||
time.sleep(5)
|
||||
|
||||
os.system("deluser --remove-home " + username + " 1>/dev/null 2>&1")
|
||||
|
||||
def get_current_script_dir():
|
||||
current_script_dir = os.path.realpath(__file__)
|
||||
index = current_script_dir.rindex('/')
|
||||
|
@ -35,9 +26,10 @@ try:
|
|||
config = ConfigObj(PATH_INI_FILE)
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
sys.exit()
|
||||
sys.exit(1)
|
||||
|
||||
os.system("/etc/init.d/airtime-show-recorder stop")
|
||||
os.system("rm -f /etc/init.d/airtime-show-recorder")
|
||||
|
||||
print "Removing log directories"
|
||||
remove_path(config["log_dir"])
|
||||
|
@ -51,7 +43,6 @@ try:
|
|||
print "Removing media files"
|
||||
remove_path(config["base_recorded_files"])
|
||||
|
||||
remove_user("pypo")
|
||||
print "Uninstall complete."
|
||||
except Exception, e:
|
||||
print "exception:" + str(e)
|
||||
|
|
|
@ -34,7 +34,8 @@ except Exception, e:
|
|||
try:
|
||||
config = ConfigObj('/etc/airtime/recorder.cfg')
|
||||
except Exception, e:
|
||||
print 'Error loading config file: ', e
|
||||
logger = logging.getLogger()
|
||||
logger.error('Error loading config file: %s', e)
|
||||
sys.exit()
|
||||
|
||||
def getDateTimeObj(time):
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#
|
||||
# Absolute path to this script
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute path this script is in
|
||||
# Absolute directory this script is in
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
invokePwd=$PWD
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#
|
||||
# Absolute path to this script
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute path this script is in
|
||||
# Absolute directory this script is in
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
invokePwd=$PWD
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
# Absolute path to this script
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute path this script is in
|
||||
# Absolute directory this script is in
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
# Absolute path to this script
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute path this script is in
|
||||
# Absolute directory this script is in
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue