CC-2166 Packaging improvements

Added command line options to the install process to overwrite or
preserve the existing config files.

Added the pypo-start/stop and recorder-start/stop symlinks to /usr/bin.

Renamed pypo-start.py to airtime-pypo-start.
Renamed pypo-stop.py to airtime-pypo-stop.
Renamed recorder-start.py to airtime-show-recorder-start.
Renamed recorder-stop.py to airtime-show-recorder-stop.

Renamed testrecordscript.py to recorder.py
This commit is contained in:
Paul Baranowski 2011-04-15 18:23:51 -04:00
parent 2b90008ef2
commit 173d82007f
14 changed files with 75 additions and 21 deletions

View File

@ -1,9 +1,10 @@
<?php
/**
* @package Airtime
* @copyright 2010 Sourcefabric O.P.S.
* @copyright 2011 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
set_include_path(__DIR__.'/../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
echo PHP_EOL;
echo "******************************** Install Begin *********************************".PHP_EOL;
@ -12,9 +13,49 @@ require_once(dirname(__FILE__).'/include/AirtimeIni.php');
require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
AirtimeInstall::ExitIfNotRoot();
AirtimeIni::ExitIfIniFilesExist();
echo "* Creating INI files".PHP_EOL;
AirtimeIni::CreateIniFiles();
require_once('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance();
try {
$opts = new Zend_Console_Getopt(
array(
'help|h' => 'Displays usage information.',
'overwrite|o' => 'Overwrite any existing config files.',
'preserve|p' => 'Keep any existing config files.'
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
exit($e->getMessage() ."\n\n". $e->getUsageMessage());
}
if (isset($opts->h)) {
echo $opts->getUsageMessage();
exit;
}
$overwrite = false;
if (isset($opts->o)) {
$overwrite = true;
}
else if (!isset($opts->p) && !isset($opts->o)) {
if (AirtimeIni::IniFilesExist()) {
$userAnswer = "x";
while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) {
echo PHP_EOL."You have existing config files. Do you want to (O)verwrite them, or (P)reserve them? (o/P) ";
$userAnswer = trim(fgets(STDIN));
}
if (in_array($userAnswer, array("o", "O"))) {
$overwrite = true;
}
}
}
if ($overwrite) {
echo "* Creating INI files".PHP_EOL;
AirtimeIni::CreateIniFiles();
}
AirtimeInstall::InstallPhpCode();
AirtimeInstall::InstallBinaries();

View File

@ -28,8 +28,7 @@ class AirtimeIni
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
public static function ExitIfIniFilesExist()
public static function IniFilesExist()
{
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
AirtimeIni::CONF_FILE_PYPO,
@ -42,14 +41,7 @@ class AirtimeIni
$exist = true;
}
}
if ($exist) {
echo PHP_EOL."Existing config files will be overwritten. Do you want to continue? (y/N) ";
$response = trim(fgets(STDIN));
if ($response != "Y" && $response != "y") {
echo "Install process stopped.".PHP_EOL.PHP_EOL;
exit();
}
}
return $exist;
}
/**

View File

@ -112,6 +112,12 @@ try:
os.system("chown -R pypo:pypo "+config["bin_dir"])
os.system("chown -R pypo:pypo "+config["cache_base_dir"])
print "Creating symbolic links"
os.system("rm -f /usr/bin/airtime-pypo-start")
os.system("ln -s "+config["bin_dir"]+"/bin/airtime-pypo-start /usr/bin/")
os.system("rm -f /usr/bin/airtime-pypo-stop")
os.system("ln -s "+config["bin_dir"]+"/bin/airtime-pypo-stop /usr/bin/")
print "Installing pypo daemon"
create_path("/etc/service/pypo")
create_path("/etc/service/pypo/log")
@ -130,7 +136,7 @@ try:
print "Waiting for processes to start..."
time.sleep(5)
os.system("python %s/pypo-start.py" % (get_current_script_dir()))
os.system("python /usr/bin/airtime-pypo-start")
time.sleep(2)
found = True

View File

@ -37,7 +37,7 @@ try:
print 'Error loading config file: ', e
sys.exit()
os.system("python %s/pypo-stop.py" % get_current_script_dir())
os.system("python /usr/bin/airtime-pypo-stop")
print "Removing log directories"
remove_path(config["log_base_dir"])
@ -45,6 +45,10 @@ try:
print "Removing cache directories"
remove_path(config["cache_base_dir"])
print "Removing symlinks"
os.system("rm -f /usr/bin/airtime-pypo-start")
os.system("rm -f /usr/bin/airtime-pypo-stop")
print "Removing pypo files"
remove_path(config["bin_dir"])

View File

@ -1,2 +1,2 @@
#!/bin/sh
exec setuidgid pypo multilog t /var/log/airtime/recorder/main
exec setuidgid pypo multilog t /var/log/airtime/show-recorder/main

View File

@ -4,8 +4,8 @@ export HOME="/var/tmp/airtime/show-recorder/"
export TERM=xterm
# Location of pypo_cli.py Python script
recorder_path="/usr/lib/airtime/show-recorder/bin/"
recorder_script="testrecordscript.py"
recorder_path="/usr/lib/airtime/show-recorder/"
recorder_script="recorder.py"
api_client_path="/usr/lib/airtime/pypo/"
cd ${recorder_path}

8
python_apps/show-recorder/install/recorder-install.py Normal file → Executable file
View File

@ -92,6 +92,12 @@ try:
print "Setting permissions"
os.system("chmod -R 755 "+config["bin_dir"])
os.system("chown -R pypo:pypo "+config["bin_dir"])
print "Creating symbolic links"
os.system("rm -f /usr/bin/airtime-show-recorder-start")
os.system("ln -s "+config["bin_dir"]+"/airtime-show-recorder-start /usr/bin/")
os.system("rm -f /usr/bin/airtime-show-recorder-stop")
os.system("ln -s "+config["bin_dir"]+"/airtime-show-recorder-stop /usr/bin/")
print "Installing recorder daemon"
create_path("/etc/service/recorder")
@ -103,7 +109,7 @@ try:
print "Waiting for processes to start..."
time.sleep(5)
os.system("python %s/recorder-start.py" % (get_current_script_dir()))
os.system("python /usr/bin/airtime-show-recorder-start")
time.sleep(2)
found = True

View File

@ -37,11 +37,15 @@ try:
print 'Error loading config file: ', e
sys.exit()
os.system("python %s/recorder-stop.py" % get_current_script_dir())
os.system("python /usr/bin/airtime-show-recorder-stop")
print "Removing log directories"
remove_path(config["log_dir"])
print "Removing symlinks"
os.system("rm -f /usr/bin/airtime-show-recorder-start")
os.system("rm -f /usr/bin/airtime-show-recorder-stop")
print "Removing application files"
remove_path(config["bin_dir"])

View File

@ -336,6 +336,7 @@ if ($time > 0) {
echo "==========================================================================\n";
echo " *** Import mode: $importMode\n";
echo " *** Destination folder: ".$CC_CONFIG['storageDir']."\n";
echo " *** Files imported: $g_fileCount\n";
echo " *** Duplicate files (not imported): $g_duplicates\n";
if ($g_errors > 0) {