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