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:
parent
2b90008ef2
commit
173d82007f
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @package Airtime
|
* @package Airtime
|
||||||
* @copyright 2010 Sourcefabric O.P.S.
|
* @copyright 2011 Sourcefabric O.P.S.
|
||||||
* @license http://www.gnu.org/licenses/gpl.txt
|
* @license http://www.gnu.org/licenses/gpl.txt
|
||||||
*/
|
*/
|
||||||
|
set_include_path(__DIR__.'/../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||||
|
|
||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
echo "******************************** Install Begin *********************************".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');
|
require_once(dirname(__FILE__).'/include/AirtimeInstall.php');
|
||||||
|
|
||||||
AirtimeInstall::ExitIfNotRoot();
|
AirtimeInstall::ExitIfNotRoot();
|
||||||
AirtimeIni::ExitIfIniFilesExist();
|
|
||||||
echo "* Creating INI files".PHP_EOL;
|
require_once('Zend/Loader/Autoloader.php');
|
||||||
AirtimeIni::CreateIniFiles();
|
$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::InstallPhpCode();
|
||||||
AirtimeInstall::InstallBinaries();
|
AirtimeInstall::InstallBinaries();
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,7 @@ class AirtimeIni
|
||||||
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
||||||
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
||||||
|
|
||||||
|
public static function IniFilesExist()
|
||||||
public static function ExitIfIniFilesExist()
|
|
||||||
{
|
{
|
||||||
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
|
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
|
||||||
AirtimeIni::CONF_FILE_PYPO,
|
AirtimeIni::CONF_FILE_PYPO,
|
||||||
|
@ -42,14 +41,7 @@ class AirtimeIni
|
||||||
$exist = true;
|
$exist = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($exist) {
|
return $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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -112,6 +112,12 @@ try:
|
||||||
os.system("chown -R pypo:pypo "+config["bin_dir"])
|
os.system("chown -R pypo:pypo "+config["bin_dir"])
|
||||||
os.system("chown -R pypo:pypo "+config["cache_base_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"
|
print "Installing pypo daemon"
|
||||||
create_path("/etc/service/pypo")
|
create_path("/etc/service/pypo")
|
||||||
create_path("/etc/service/pypo/log")
|
create_path("/etc/service/pypo/log")
|
||||||
|
@ -130,7 +136,7 @@ try:
|
||||||
|
|
||||||
print "Waiting for processes to start..."
|
print "Waiting for processes to start..."
|
||||||
time.sleep(5)
|
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)
|
time.sleep(2)
|
||||||
|
|
||||||
found = True
|
found = True
|
||||||
|
|
|
@ -37,7 +37,7 @@ try:
|
||||||
print 'Error loading config file: ', e
|
print 'Error loading config file: ', e
|
||||||
sys.exit()
|
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"
|
print "Removing log directories"
|
||||||
remove_path(config["log_base_dir"])
|
remove_path(config["log_base_dir"])
|
||||||
|
@ -45,6 +45,10 @@ try:
|
||||||
print "Removing cache directories"
|
print "Removing cache directories"
|
||||||
remove_path(config["cache_base_dir"])
|
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"
|
print "Removing pypo files"
|
||||||
remove_path(config["bin_dir"])
|
remove_path(config["bin_dir"])
|
||||||
|
|
||||||
|
|
0
python_apps/show-recorder/install/recorder-start.py → python_apps/show-recorder/airtime-show-recorder-start
Normal file → Executable file
0
python_apps/show-recorder/install/recorder-start.py → python_apps/show-recorder/airtime-show-recorder-start
Normal file → Executable file
0
python_apps/show-recorder/install/recorder-stop.py → python_apps/show-recorder/airtime-show-recorder-stop
Normal file → Executable file
0
python_apps/show-recorder/install/recorder-stop.py → python_apps/show-recorder/airtime-show-recorder-stop
Normal file → Executable file
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec setuidgid pypo multilog t /var/log/airtime/recorder/main
|
exec setuidgid pypo multilog t /var/log/airtime/show-recorder/main
|
||||||
|
|
|
@ -4,8 +4,8 @@ export HOME="/var/tmp/airtime/show-recorder/"
|
||||||
export TERM=xterm
|
export TERM=xterm
|
||||||
|
|
||||||
# Location of pypo_cli.py Python script
|
# Location of pypo_cli.py Python script
|
||||||
recorder_path="/usr/lib/airtime/show-recorder/bin/"
|
recorder_path="/usr/lib/airtime/show-recorder/"
|
||||||
recorder_script="testrecordscript.py"
|
recorder_script="recorder.py"
|
||||||
|
|
||||||
api_client_path="/usr/lib/airtime/pypo/"
|
api_client_path="/usr/lib/airtime/pypo/"
|
||||||
cd ${recorder_path}
|
cd ${recorder_path}
|
||||||
|
|
|
@ -92,6 +92,12 @@ try:
|
||||||
print "Setting permissions"
|
print "Setting permissions"
|
||||||
os.system("chmod -R 755 "+config["bin_dir"])
|
os.system("chmod -R 755 "+config["bin_dir"])
|
||||||
os.system("chown -R pypo:pypo "+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"
|
print "Installing recorder daemon"
|
||||||
create_path("/etc/service/recorder")
|
create_path("/etc/service/recorder")
|
||||||
|
@ -103,7 +109,7 @@ try:
|
||||||
|
|
||||||
print "Waiting for processes to start..."
|
print "Waiting for processes to start..."
|
||||||
time.sleep(5)
|
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)
|
time.sleep(2)
|
||||||
|
|
||||||
found = True
|
found = True
|
||||||
|
|
|
@ -37,11 +37,15 @@ try:
|
||||||
print 'Error loading config file: ', e
|
print 'Error loading config file: ', e
|
||||||
sys.exit()
|
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"
|
print "Removing log directories"
|
||||||
remove_path(config["log_dir"])
|
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"
|
print "Removing application files"
|
||||||
remove_path(config["bin_dir"])
|
remove_path(config["bin_dir"])
|
||||||
|
|
||||||
|
|
|
@ -336,6 +336,7 @@ if ($time > 0) {
|
||||||
|
|
||||||
echo "==========================================================================\n";
|
echo "==========================================================================\n";
|
||||||
echo " *** Import mode: $importMode\n";
|
echo " *** Import mode: $importMode\n";
|
||||||
|
echo " *** Destination folder: ".$CC_CONFIG['storageDir']."\n";
|
||||||
echo " *** Files imported: $g_fileCount\n";
|
echo " *** Files imported: $g_fileCount\n";
|
||||||
echo " *** Duplicate files (not imported): $g_duplicates\n";
|
echo " *** Duplicate files (not imported): $g_duplicates\n";
|
||||||
if ($g_errors > 0) {
|
if ($g_errors > 0) {
|
||||||
|
|
Loading…
Reference in New Issue