From 173d82007fdbe64cf42364af86293be518fca0a2 Mon Sep 17 00:00:00 2001 From: Paul Baranowski Date: Fri, 15 Apr 2011 18:23:51 -0400 Subject: [PATCH] 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 --- install/airtime-install.php | 49 +++++++++++++++++-- install/include/AirtimeIni.php | 12 +---- .../pypo-start.py => airtime-pypo-start} | 0 .../pypo-stop.py => airtime-pypo-stop} | 0 python_apps/pypo/install/pypo-install.py | 8 ++- python_apps/pypo/install/pypo-uninstall.py | 6 ++- ...r-start.py => airtime-show-recorder-start} | 0 ...der-stop.py => airtime-show-recorder-stop} | 0 .../install/recorder-daemontools-logger.sh | 2 +- .../install/recorder-daemontools.sh | 4 +- .../show-recorder/install/recorder-install.py | 8 ++- .../install/recorder-uninstall.py | 6 ++- .../{testrecordscript.py => recorder.py} | 0 utils/airtime-import.php | 1 + 14 files changed, 75 insertions(+), 21 deletions(-) rename python_apps/pypo/{install/pypo-start.py => airtime-pypo-start} (100%) rename python_apps/pypo/{install/pypo-stop.py => airtime-pypo-stop} (100%) rename python_apps/show-recorder/{install/recorder-start.py => airtime-show-recorder-start} (100%) mode change 100644 => 100755 rename python_apps/show-recorder/{install/recorder-stop.py => airtime-show-recorder-stop} (100%) mode change 100644 => 100755 mode change 100644 => 100755 python_apps/show-recorder/install/recorder-daemontools-logger.sh mode change 100644 => 100755 python_apps/show-recorder/install/recorder-daemontools.sh mode change 100644 => 100755 python_apps/show-recorder/install/recorder-install.py mode change 100644 => 100755 python_apps/show-recorder/install/recorder-uninstall.py rename python_apps/show-recorder/{testrecordscript.py => recorder.py} (100%) diff --git a/install/airtime-install.php b/install/airtime-install.php index b7443fe1d..402a735ac 100644 --- a/install/airtime-install.php +++ b/install/airtime-install.php @@ -1,9 +1,10 @@ '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(); diff --git a/install/include/AirtimeIni.php b/install/include/AirtimeIni.php index 0edee909d..27384fead 100644 --- a/install/include/AirtimeIni.php +++ b/install/include/AirtimeIni.php @@ -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; } /** diff --git a/python_apps/pypo/install/pypo-start.py b/python_apps/pypo/airtime-pypo-start similarity index 100% rename from python_apps/pypo/install/pypo-start.py rename to python_apps/pypo/airtime-pypo-start diff --git a/python_apps/pypo/install/pypo-stop.py b/python_apps/pypo/airtime-pypo-stop similarity index 100% rename from python_apps/pypo/install/pypo-stop.py rename to python_apps/pypo/airtime-pypo-stop diff --git a/python_apps/pypo/install/pypo-install.py b/python_apps/pypo/install/pypo-install.py index dc0075baf..b86b64370 100755 --- a/python_apps/pypo/install/pypo-install.py +++ b/python_apps/pypo/install/pypo-install.py @@ -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 diff --git a/python_apps/pypo/install/pypo-uninstall.py b/python_apps/pypo/install/pypo-uninstall.py index 28907fefd..fa0a62dc0 100755 --- a/python_apps/pypo/install/pypo-uninstall.py +++ b/python_apps/pypo/install/pypo-uninstall.py @@ -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"]) diff --git a/python_apps/show-recorder/install/recorder-start.py b/python_apps/show-recorder/airtime-show-recorder-start old mode 100644 new mode 100755 similarity index 100% rename from python_apps/show-recorder/install/recorder-start.py rename to python_apps/show-recorder/airtime-show-recorder-start diff --git a/python_apps/show-recorder/install/recorder-stop.py b/python_apps/show-recorder/airtime-show-recorder-stop old mode 100644 new mode 100755 similarity index 100% rename from python_apps/show-recorder/install/recorder-stop.py rename to python_apps/show-recorder/airtime-show-recorder-stop diff --git a/python_apps/show-recorder/install/recorder-daemontools-logger.sh b/python_apps/show-recorder/install/recorder-daemontools-logger.sh old mode 100644 new mode 100755 index 7d53b9653..3510acf44 --- a/python_apps/show-recorder/install/recorder-daemontools-logger.sh +++ b/python_apps/show-recorder/install/recorder-daemontools-logger.sh @@ -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 diff --git a/python_apps/show-recorder/install/recorder-daemontools.sh b/python_apps/show-recorder/install/recorder-daemontools.sh old mode 100644 new mode 100755 index 86931fa57..311d9ff70 --- a/python_apps/show-recorder/install/recorder-daemontools.sh +++ b/python_apps/show-recorder/install/recorder-daemontools.sh @@ -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} diff --git a/python_apps/show-recorder/install/recorder-install.py b/python_apps/show-recorder/install/recorder-install.py old mode 100644 new mode 100755 index 7274874d0..f5169a9c9 --- a/python_apps/show-recorder/install/recorder-install.py +++ b/python_apps/show-recorder/install/recorder-install.py @@ -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 diff --git a/python_apps/show-recorder/install/recorder-uninstall.py b/python_apps/show-recorder/install/recorder-uninstall.py old mode 100644 new mode 100755 index fa60e4e5d..fceabfa78 --- a/python_apps/show-recorder/install/recorder-uninstall.py +++ b/python_apps/show-recorder/install/recorder-uninstall.py @@ -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"]) diff --git a/python_apps/show-recorder/testrecordscript.py b/python_apps/show-recorder/recorder.py similarity index 100% rename from python_apps/show-recorder/testrecordscript.py rename to python_apps/show-recorder/recorder.py diff --git a/utils/airtime-import.php b/utils/airtime-import.php index 9c0e37600..3e497e7f9 100644 --- a/utils/airtime-import.php +++ b/utils/airtime-import.php @@ -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) {