CC-2058: Utilities are not in the system $PATH

-Added airtime-clean-storage and airtime-import symbolic links
This commit is contained in:
martin 2011-03-24 02:12:08 -04:00
parent 369c800bf0
commit f108ac846f
9 changed files with 153 additions and 49 deletions

View file

@ -46,6 +46,9 @@ AirtimeInstall::SetupStorageDirectory($CC_CONFIG);
echo "* Setting Dir Permissions".PHP_EOL;
AirtimeInstall::ChangeDirOwnerToWebserver($CC_CONFIG["storageDir"]);
echo "* Creating /usr/bin symlinks".PHP_EOL;
AirtimeInstall::CreateSymlinks($CC_CONFIG["storageDir"]);
echo "* Importing Sample Audio Clips".PHP_EOL;
system(__DIR__."/../utils/airtime-import --copy ../audio_samples/ > /dev/null");

View file

@ -20,6 +20,7 @@ require_once(dirname(__FILE__).'/installInit.php');
// Need to check that we are superuser before running this.
AirtimeInstall::ExitIfNotRoot();
AirtimeInstall::RemoveSymlinks();
echo "******************************* Uninstall Begin ********************************".PHP_EOL;
//------------------------------------------------------------------------

View file

@ -203,4 +203,20 @@ class AirtimeInstall {
exec($command);
}
public static function CreateSymlinks(){
AirtimeInstall::RemoveSymlinks();
$dir = realpath(__DIR__."/../utils/airtime-import");
exec("ln -s $dir /usr/bin/airtime-import");
$dir = realpath(__DIR__."/../utils/airtime-clean-storage");
exec("ln -s $dir /usr/bin/airtime-clean-storage");
}
public static function RemoveSymlinks(){
exec("rm /usr/bin/airtime-import");
exec("rm /usr/bin/airtime-clean-storage");
}
}

View file

@ -23,4 +23,4 @@
#-------------------------------------------------------------------------------
# This script cleans audio files in the Airtime storageServer.
php -q CleanStor.php "$@" || exit 1
php -q airtime-clean-storage.php "$@" || exit 1

View file

@ -0,0 +1,124 @@
<?php
// Do not allow remote execution
$arr = array_diff_assoc($_SERVER, $_ENV);
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
header("HTTP/1.1 400");
header("Content-type: text/plain; charset=UTF-8");
echo "400 Not executable\r\n";
exit(1);
}
require_once('../application/configs/conf.php');
require_once('../install/installInit.php');
require_once('../application/models/StoredFile.php');
function printUsage() {
global $CC_CONFIG;
echo "Usage:\n";
echo " ./airtime-clean-storage [OPTION] \n";
echo "\n";
echo "Options:\n";
echo " -c, --clean Removes all broken links from the storage server\n";
echo " and empties all missing file information from the database.\n";
echo "\n";
echo " -e, --empty Removes all files from the storage server \n";
echo " and empties all relevant information from the database.\n\n";
echo "Storage server: ". realpath($CC_CONFIG["storageDir"]) ."\n\n\n";
}
function airtime_clean_files($p_path) {
if (!empty($p_path) && (strlen($p_path) > 4)) {
list($dirList,$fileList) = File_Find::maptree($p_path);
$array_mus;
foreach ($fileList as $filepath) {
if (@substr($filepath, strlen($filepath) - 3) != "xml") {
$array_mus[] = $filepath;
}
}
foreach ($array_mus as $audio_file) {
if (@is_link($audio_file) && !@stat($audio_file)) {
//filesystem clean up.
@unlink($audio_file);
echo "unlinked $audio_file\n";
@unlink($audio_file . ".xml");
echo "unlinked " . $audio_file . ".xml\n";
@rmdir(@dirname($audio_file));
echo "removed dir " . @dirname($audio_file) . "\n";
//database clean up.
$stored_audio_file = StoredFile::RecallByGunid(@basename($audio_file));
$stored_audio_file->delete();
}
}
}
}
function airtime_remove_files($p_path) {
if (!empty($p_path) && (strlen($p_path) > 4)) {
list($dirList,$fileList) = File_Find::maptree($p_path);
foreach ($fileList as $filepath) {
echo " * Removing $filepath\n";
@unlink($filepath);
echo "done.\n";
}
foreach ($dirList as $dirpath) {
echo " * Removing $dirpath\n";
@rmdir($dirpath);
echo "done.\n";
}
}
}
function airtime_empty_db($db) {
global $CC_CONFIG;
if (!PEAR::isError($db)) {
if (AirtimeInstall::DbTableExists($CC_CONFIG['filesTable'])) {
echo " * Deleting from database table ".$CC_CONFIG['filesTable']."\n";
$sql = "DELETE FROM ".$CC_CONFIG['filesTable'];
AirtimeInstall::InstallQuery($sql, false);
}
else {
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
}
}
}
global $CC_CONFIG;
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
if ($argc != 2){
printUsage();
exit(1);
}
switch($argv[1]){
case '-e':
case '--empty':
airtime_empty_db($CC_DBC);
airtime_remove_files($CC_CONFIG['storageDir']);
break;
case '-c':
case '--clean':
airtime_clean_files($CC_CONFIG['storageDir']);
break;
default:
printUsage();
}

View file

@ -29,15 +29,16 @@
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`
phpdir=$reldir
filelistpathname=.
# Absolute path to this script
SCRIPT=`readlink -f $0`
# Absolute path this script is in
SCRIPTPATH=`dirname $SCRIPT`
#-------------------------------------------------------------------------------
# Do import
#-------------------------------------------------------------------------------
invokePwd=$PWD
#echo $invokePwd
cd $phpdir
cd $SCRIPTPATH
php -q airtime-import.php --dir "$invokePwd" "$@" || exit 1

View file

@ -56,7 +56,7 @@ function printUsage()
echo " -h, --help Print this message and exit.\n";
echo "\n";
echo "Files will be imported to directory:\n";
echo " ". $CC_CONFIG["storageDir"] ."\n";
echo " ". realpath($CC_CONFIG["storageDir"]) ."\n";
echo "\n";
}

View file

@ -18,7 +18,7 @@ function printUsage() {
global $CC_CONFIG;
echo "Usage:\n";
echo " ./CleanStor [OPTION] \n";
echo " ./cleanStor [OPTION] \n";
echo "\n";
echo "Options:\n";
echo " -c, --clean Removes all broken links from the storage server\n";

View file

@ -1,41 +0,0 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Airtime project.
# http://airtime.sourcefabric.org/
# To report bugs, send an e-mail to contact@sourcefabric.org
#
# Airtime is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Airtime is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Airtime; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script call locstor.resetStorage XMLRPC method
#-------------------------------------------------------------------------------
reldir=`dirname $0`/..
WWW_ROOT=`cd $reldir/var/install; php -q getWwwRoot.php` || exit $?
echo "# storageServer root URL: $WWW_ROOT"
#$reldir/var/xmlrpc/xr_cli_test.py -s $WWW_ROOT/xmlrpc/xrLocStor.php \
# resetStorage || exit $?
cd $reldir/var/xmlrpc
php -q xr_cli_test.php -s $WWW_ROOT/xmlrpc/xrLocStor.php \
resetStorage 1 1 || exit $?
echo "# resetStorage: OK"
exit 0