CC-1695 Remove Campcaster Studio and make install easier

Removed more stuff and started creating new directory structure.
This commit is contained in:
paul.baranowski 2010-09-30 15:32:02 -04:00
parent 3f5b1a1c92
commit d9c6971131
148 changed files with 50 additions and 29338 deletions

29
utils/CleanStor.sh Executable file
View file

@ -0,0 +1,29 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script cleans audio files in the Campcaster storageServer.
reldir=`dirname $0`/..
cd $reldir/var
php -q CleanStor.php "$@" || exit 1

204
utils/backup.php Normal file
View file

@ -0,0 +1,204 @@
<?php
define('NSPACE', 'lse');
header("Content-type: text/plain");
require_once('conf.php');
require_once("$STORAGE_SERVER_PATH/var/conf.php");
require_once('DB.php');
require_once("XML/Util.php");
require_once("XML/Beautifier.php");
require_once("$STORAGE_SERVER_PATH/var/BasicStor.php");
require_once("$STORAGE_SERVER_PATH/var/Prefs.php");
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$bs = new BasicStor();
$stid = $bs->storId;
#var_dump($stid); exit;
#$farr = $bs->bsListFolder($stid); var_dump($farr); exit;
function admDumpFolder(&$bs, $fid, $ind='')
{
// NOTE: need to fix this, removed due to tree removal
// $name = M2tree::GetObjName($fid);
// if (PEAR::isError($name)) {
// echo $name->getMessage();
// exit;
// }
$type = BasicStor::GetObjType($fid);
if (PEAR::isError($type)) {
echo $type->getMessage();
exit;
}
$gunid = BasicStor::GunidFromId($fid);
if (PEAR::isError($gunid)) {
echo $gunid->getMessage();
exit;
}
$pars = array();
if ($gunid) {
$pars['id']="$gunid";
}
$pars['name'] = "$name";
switch ($type) {
case "audioclip":
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'audioClip',
'attributes'=> $pars,
));
break;
case "webstream":
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'webstream',
'attributes'=> $pars,
));
break;
case "playlist":
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'playlist',
'attributes'=> $pars,
));
break;
default:
return "";
}
}
function admDumpGroup(&$bs, $gid, $ind='')
{
$name = Subjects::GetSubjName($gid);
if (PEAR::isError($name)) {
echo $name->getMessage();
exit;
}
$isGr = Subjects::IsGroup($gid);
if (PEAR::isError($isGr)) {
echo $isGr->getMessage();
exit;
}
$pars = array('name'=>"$name");
$pars['id'] = $gid;
if (!$isGr) {
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'member',
'attributes'=> $pars,
));
}
$garr = Subjects::ListGroup($gid);
if (PEAR::isError($garr)) {
echo $garr->getMessage();
exit;
}
$res = '';
foreach ($garr as $i => $member) {
$fid2 = $member['id'];
$res .= admDumpGroup($bs, $fid2, "$ind ");
}
$tagarr = array(
'namespace' => NSPACE,
'localPart' => 'group',
'attributes'=> $pars,
);
$prefs = admDumpPrefs($bs, $gid);
if (!is_null($prefs)) {
$res .= $prefs;
}
if ($res) {
$tagarr['content'] = $res;
}
return XML_Util::createTagFromArray($tagarr, $res === '');
// if (!$res) {
// } else {
// return XML_Util::createTagFromArray(array(
// 'namespace' => NSPACE,
// 'localPart' => 'group',
// 'attributes'=> $pars,
// 'content' => $res,
// ), FALSE);
// }
}
function admDumpSubjects(&$bs, $ind='')
{
$res ='';
$subjs = Subjects::GetSubjects('id, login, pass, type');
foreach ($subjs as $i => $member) {
switch ($member['type']) {
case "U":
$prefs = admDumpPrefs($bs, $member['id']);
$pars = array('login'=>"{$member['login']}", 'pass'=>"{$member['pass']}");
$pars['id'] = $member['id'];
$tagarr = array(
'namespace' => NSPACE,
'localPart' => 'user',
'attributes'=> $pars,
);
if (!is_null($prefs)) {
$tagarr['content'] = $prefs;
}
$res .= XML_Util::createTagFromArray($tagarr , FALSE);
break;
case "G":
$res .= admDumpGroup($bs, $member['id'], "$ind ");
break;
}
}
# return "$ind<subjects>\n$res$ind</subjects>\n";
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'subjects',
'content'=> $res,
), FALSE);
}
function admDumpPrefs(&$bs, $subjid)
{
$res ='';
$pr = new Prefs($bs);
$prefkeys = $pr->readKeys($subjid);
# var_dump($subjid); var_dump($prefkeys); #exit;
foreach ($prefkeys as $i => $prefk) {
$keystr = $prefk['keystr'];
$prefval = $pr->readVal($subjid, $keystr);
$pars = array('name'=>"$keystr", 'val'=>"$prefval");
$res .= XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'pref',
'attributes'=> $pars,
));
}
if (!$res) {
return NULL;
}
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'preferences',
'content'=> $res,
), FALSE);
}
$subjects = admDumpSubjects($bs, ' ');
$tree = admDumpFolder($bs, $stid, ' ');
$res = XML_Util::getXMLDeclaration("1.0", "UTF-8")."\n";
$node = XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'storageServer',
'content' => "$subjects$tree",
), FALSE);
$res .= $node;
$fmt = new XML_Beautifier();
$res = $fmt->formatString($res);
#var_export($res);
#var_dump($res);
echo "$res";
?>

18
utils/backup.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# param $1: workdir what we would like to tar
# param $2: output file: the .tar file
# param $3: statusfile
echo "==>"
date +\ %Y%m%d\ %H:%M:%S
echo "backup.sh: create tarball $1 to $2"
echo "backup.sh: status: #$3#"
echo "<=="
echo -n "working" > $3;
touch $2 || { echo -n "fault|error with .tar file" > $3; exit 1; }
#sleep 120
cd $1
tar cf $2 * || { echo -n "fault|error in tar procedure" > $3; exit 1; }
chmod 666 $2
echo -n "success" > $3

112
utils/campcaster-backup Executable file
View file

@ -0,0 +1,112 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.campware.org/
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script creates a tgz archive of the Campcaster storage.
#
# To get usage help, try the -h option
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`
phpdir=$reldir
mkdir -p $reldir/tmp
tmpmaindir=`cd $reldir/tmp; pwd`
dbxml="db.xml"
datestr=`date '+%Y%m%d%H%M%S'`
xmltar="xmls.tar"
destfile="storage$datestr.tar"
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "This script creates a tgz archive of the Campcaster storage.";
echo "parameters:";
echo "";
echo " -d, --destination Destination directory [default:$tmpmaindir].";
echo " -h, --help Print this message and exit.";
echo "";
}
#-------------------------------------------------------------------------------
# Process command line parameters
#-------------------------------------------------------------------------------
CMD=${0##*/}
opts=$(getopt -o hd: -l help,destinantion: -n $CMD -- "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
-h|--help)
printUsage;
exit 0;;
-d|--destinantion)
destdir=$2
shift; shift;;
--)
shift;
break;;
*)
echo "Unrecognized option $1.";
printUsage;
exit 1;
esac
done
if [ "x$destdir" == "x" ]; then
destdir=$tmpmaindir
fi
destdir=`cd $destdir; pwd`
#-------------------------------------------------------------------------------
# Do backup
#-------------------------------------------------------------------------------
tmpdir=`mktemp -d $tmpmaindir/tmp.XXXXXX`
echo "Backuping to $destdir/$destfile :"
echo "Dumping database ..."
cd $phpdir
php -q backup.php > $tmpdir/$dbxml
echo "Packaging stored files ..."
cd $phpdir
storpath=`php -q getStorPath.php`
cd $storpath/..
find stor -name "*.xml" -print | tar cf $tmpdir/$xmltar -T -
find stor ! -name "*.xml" -a -type f -print | tar cf $tmpdir/$destfile -T -
cd $tmpdir
tar rf $xmltar $dbxml --remove-files
echo "Compressing XML part ..."
bzip2 $xmltar
tar rf $destfile $xmltar.bz2 --remove-files
mv $destfile "$destdir"
rmdir $tmpdir
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "done"

43
utils/campcaster-import Executable file
View file

@ -0,0 +1,43 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script imports audio files to the Campcaster storageServer.
#
# To get usage help, try the -h option
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`
phpdir=$reldir
filelistpathname=.
#-------------------------------------------------------------------------------
# Do import
#-------------------------------------------------------------------------------
invokePwd=$PWD
#echo $invokePwd
cd $phpdir
php -q campcaster-import.php --dir "$invokePwd" "$@" || exit 1

354
utils/campcaster-import.php Normal file
View file

@ -0,0 +1,354 @@
<?php
/**
* Mass import of audio files.
*
* @package Campcaster
* @subpackage StorageAdmin
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
ini_set('memory_limit', '128M');
set_time_limit(0);
error_reporting(E_ALL);
set_error_handler("camp_import_error_handler", E_ALL & !E_NOTICE);
require_once('conf.php');
require_once("$STORAGE_SERVER_PATH/var/conf.php");
require_once('DB.php');
require_once("$STORAGE_SERVER_PATH/var/GreenBox.php");
require_once('Console/Getopt.php');
function camp_import_error_handler()
{
echo var_dump(debug_backtrace());
exit();
}
function printUsage()
{
global $CC_CONFIG;
echo "There are two ways to import audio files into Campcaster: linking\n";
echo "or copying.\n";
echo "\n";
echo "Linking has the advantage that it will not duplicate any files,\n";
echo "but you must take care not to move, rename, or delete any of the\n";
echo "imported files from their current locations on disk.\n";
echo "\n";
echo "Copying has the advantage that you can do whatever you like with\n";
echo "the source files after you import them, but has the disadvantage\n";
echo "that it requires doubling the hard drive space needed to store\n";
echo "your files.\n";
echo "\n";
echo "Usage:\n";
echo " campcaster-import [OPTIONS] FILES_OR_DIRS\n";
echo "\n";
echo "Options:\n";
echo " -l, --link Link to specified files.\n";
echo " Saves storage space, but you cannot move, delete,\n";
echo " or rename the original files, otherwise there will\n";
echo " be dead air when Campcaster tries to play the file.\n";
echo "\n";
echo " -c, --copy Copy the specified files.\n";
echo " This is useful if you are importing from removable media.\n";
echo " If you are importing files on your hard drive, this will\n";
echo " double the disk space required.\n";
echo "\n";
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 "\n";
}
/**
* Print error to the screen and keep a count of number of errors.
*
* @param PEAR_Error $pearErrorObj
* @param string $txt
*/
function import_err($p_pearErrorObj, $txt='')
{
global $g_errors;
if (PEAR::isError($p_pearErrorObj)) {
$msg = $p_pearErrorObj->getMessage()." ".$p_pearErrorObj->getUserInfo();
}
echo "\nERROR: $msg\n";
if (!empty($txt)) {
echo "ERROR: $txt\n";
}
$g_errors++;
}
/**
* Import a file or directory into the storage database.
* If it is a directory, files will be imported recursively.
*
* @param string $p_filepath
* You can pass in a directory or file name.
* This must be the full absolute path to the file, not relative.
* @param string $p_importMode
* @param boolean $p_testOnly
*
* @return int
*/
function camp_import_audio_file($p_filepath, $p_importMode = null, $p_testOnly = false)
{
global $STORAGE_SERVER_PATH;
global $g_fileCount;
global $g_duplicates;
// Check parameters
$p_importMode = strtolower($p_importMode);
if (!in_array($p_importMode, array("copy", "link"))) {
return;
}
$greenbox = new GreenBox();
$fileCount = 0;
$duplicates = 0;
if (!file_exists($p_filepath)) {
echo " * WARNING: File does not exist: $p_filepath\n";
return;
}
//echo "Memory usage:".memory_get_usage()."\n";
// If we are given a directory, get all the files recursively and
// call this function for each file.
if (is_dir($p_filepath)) {
// NOTE: this method of using opendir() is used over other
// techniques because of its low memory usage. Both PEAR's
// File_Find and PHP5's built-in RecursiveDirectoryIterator
// use about 5500 bytes per file, while this method uses
// about 1100 bytes per file.
$d = opendir($p_filepath);
while (false !== ($file = readdir($d))) {
if ($file != "." && $file != "..") {
$path = "$p_filepath/$file";
camp_import_audio_file($path, $p_importMode, $p_testOnly);
}
}
closedir($d);
return;
}
// Check for non-supported file type
if (!preg_match('/\.(ogg|mp3)$/i', $p_filepath, $var)) {
echo "IGNORED: $p_filepath\n";
//echo " * WARNING: File extension not supported - skipping file: $p_filepath\n";
return;
}
// Set the file permissions to be world-readable
if ($p_importMode == "link") {
// Check current file permissions
$fileperms = fileperms($p_filepath);
// Explaination of 0x0124:
// 1 => owner readable
// 2 => group readable
// 4 => world readable
// (see: http://php.net/manual/en/function.fileperms.php)
$readableByAll = !(($fileperms & 0x0124) ^ 0x0124);
if (!$readableByAll) {
$permError = false;
// Check if we have the ability to change the perms
if (is_writable($p_filepath)) {
// Change the file perms
$fileperms = $fileperms | 0x0124;
chmod($p_filepath, $fileperms);
// Check that file perms were changed
clearstatcache();
$fileperms = fileperms($p_filepath);
$readableByAll = !(($fileperms & 0x0124) ^ 0x124);
if (!$readableByAll) {
$permError = true;
}
} else {
$permError = true;
}
if ($permError) {
global $g_errors;
$g_errors++;
echo "ERROR: $p_filepath\n"
." When importing with the '--link' option, files must be set\n"
." world-readable. The file permissions for the file cannot be\n"
." changed. Check that you are not trying to import from a FAT32\n"
." drive. Otherwise, this problem might be fixed by running this \n"
." script with 'sudo'.\n";
return;
}
}
}
// $timeBegin = microtime(true);
$md5sum = md5_file($p_filepath);
// $timeEnd = microtime(true);
// echo " * MD5 time: ".($timeEnd-$timeBegin)."\n";
// Look up md5sum in database
$duplicate = StoredFile::RecallByMd5($md5sum);
if ($duplicate) {
echo "DUPLICATE: $p_filepath\n";
$g_duplicates++;
return;
}
echo "Importing: [".sprintf("%05d",$g_fileCount+1)."] $p_filepath\n";
if (!$p_testOnly) {
if ($p_importMode == "copy") {
$doCopyFiles = true;
} elseif ($p_importMode == "link") {
$doCopyFiles = false;
}
$values = array(
"filepath" => $p_filepath,
"md5" => $md5sum,
);
$storedFile = $greenbox->bsPutFile($values, $doCopyFiles);
if (PEAR::isError($storedFile)) {
import_err($storedFile, "Error in bsPutFile()");
echo var_export($metadata)."\n";
return;
}
} else {
echo "==========================================================================\n";
echo "METADATA\n";
var_dump($metadata);
}
$g_fileCount++;
return;
}
$DEBUG_IMPORT = false;
echo "========================\n";
echo "Campcaster Import Script\n";
echo "========================\n";
$g_errors = 0;
//print_r($argv);
$start = intval(date('U'));
if ($DEBUG_IMPORT) {
$testonly = false;
$importMode = "link";
$files = array("/home/paul/music/Tom Petty/Anthology - Through the Years disc 2/13 - Into The Great Wide Open.ogg");
$dsn = array('username' => 'test',
'password' => 'test',
'hostspec' => 'localhost',
'phptype' => 'pgsql',
'database' => 'Campcaster-paul');
} else {
$dsn = $CC_CONFIG['dsn'];
}
//PEAR::setErrorHandling(PEAR_ERROR_RETURN);
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "camp_import_error_handler");
$CC_DBC = DB::connect($dsn, TRUE);
if (PEAR::isError($CC_DBC)) {
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
exit(1);
}
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
if (!$DEBUG_IMPORT) {
$parsedCommandLine = Console_Getopt::getopt($argv, "thcld", array("test", "help", "copy", "link", "dir="));
//print_r($parsedCommandLine);
if (PEAR::isError($parsedCommandLine)) {
printUsage();
exit(1);
}
$cmdLineOptions = $parsedCommandLine[0];
if (count($parsedCommandLine[1]) == 0) {
printUsage();
exit;
}
$files = $parsedCommandLine[1];
$testonly = FALSE;
$importMode = null;
$currentDir = null;
foreach ($cmdLineOptions as $tmpValue) {
$optionName = $tmpValue[0];
$optionValue = $tmpValue[1];
switch ($optionName) {
case "h":
case '--help':
printUsage();
exit;
case "c":
case "--copy":
$importMode = "copy";
break;
case 'l':
case '--link':
$importMode = "link";
break;
case '--dir':
$currentDir = $optionValue;
break;
case "t":
case "--test":
$testonly = TRUE;
break;
}
}
}
if (is_null($importMode)) {
printUsage();
exit(0);
}
global $CC_CONFIG;
if (!is_writable($CC_CONFIG["storageDir"])) {
echo "ERROR: You do not have write permissions to the directory you are trying to import to:\n " . $CC_CONFIG["storageDir"] . "\n\n";
exit;
}
global $g_fileCount;
global $g_duplicates;
if (is_array($files)) {
foreach ($files as $filepath) {
// absolute path
if (($filepath[0] == "/") || ($filepath[0] == "~")) {
$fullPath = realpath($filepath);
} elseif (!is_null($currentDir)) {
$fullPath = realpath("$currentDir/$filepath");
} else {
$fullPath = null;
}
if (empty($fullPath)) {
echo "ERROR: I cant find the given file: $filepath\n\n";
exit;
}
camp_import_audio_file($fullPath, $importMode, $testonly);
}
}
$end = intval(date('U'));
$time = $end - $start;
if ($time > 0) {
$speed = round(($g_fileCount+$g_duplicates)/$time, 1);
} else {
$speed = ($g_fileCount+$g_duplicates);
}
echo "==========================================================================\n";
echo " *** Import mode: $importMode\n";
echo " *** Files imported: $g_fileCount\n";
echo " *** Duplicate files (not imported): $g_duplicates\n";
if ($g_errors > 0) {
echo " *** Errors: $g_errors\n";
}
echo " *** Total: ".($g_fileCount+$g_duplicates)." files in $time seconds = $speed files/second.\n";
echo "==========================================================================\n";
?>

110
utils/campcaster-restore Executable file
View file

@ -0,0 +1,110 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script restores the data which was backed up with campcaster-backup.
#
# To get usage help, try the -h option
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`
phpdir=$reldir
mkdir -p $reldir/tmp
tmpmaindir=`cd $reldir/tmp; pwd`
dbxml="db.xml"
tarfile0="xmls.tar"
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "This script restores the data which was backed up with campcaster-backup."
echo "parameters:";
echo "";
echo " -f, --file File with the backed up data, required.";
echo " -h, --help Print this message and exit.";
echo "";
}
#-------------------------------------------------------------------------------
# Process command line parameters
#-------------------------------------------------------------------------------
CMD=${0##*/}
opts=$(getopt -o hf: -l help,file -n $CMD -- "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
-h|--help)
printUsage;
exit 0;;
-f|--file)
tarfile=$2
shift; shift;;
--)
shift;
break;;
*)
echo "Unrecognized option $1.";
printUsage;
exit 1;
esac
done
if [ "x$tarfile" == "x" ]; then
echo "Required parameter file not specified.";
printUsage;
exit 1;
fi
tfdir=`dirname $tarfile`
tfdir=`cd $tfdir; pwd`
tfbname=`basename $tarfile`
tarfile="$tfdir/$tfbname"
#-------------------------------------------------------------------------------
# Do restore
#-------------------------------------------------------------------------------
tmpdir=`mktemp -d $tmpmaindir/tmp.XXXXXX`
echo "Restoring database from $tarfile ..."
cd $tmpdir
tar xf $tarfile
tar xjf $tarfile0.bz2
rm -f $tarfile0.bz2
cd $phpdir
php -q restore.php $tmpdir/$dbxml $tmpdir
rm -rf "$tmpdir/stor"
rm -f $tmpdir/*
rmdir "$tmpdir"
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "done"

3
utils/conf.php Normal file
View file

@ -0,0 +1,3 @@
<?php
$STORAGE_SERVER_PATH = dirname(__FILE__)."/../../storageServer";
?>

3
utils/conf.php.template Normal file
View file

@ -0,0 +1,3 @@
<?php
$STORAGE_SERVER_PATH = 'ls_storageServer';
?>

211
utils/createDatabase.sh Executable file
View file

@ -0,0 +1,211 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
# To report bugs, send an e-mail to bugs@campware.org
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
# This script creates the database used by Campcaster
#
# Invoke as:
# ./bin/createDatabase.sh
#
# To get usage help, try the -h option
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`/..
basedir=`cd $reldir; pwd;`
bindir=$basedir/bin
etcdir=$basedir/etc
docdir=$basedir/doc
tmpdir=$basedir/tmp
usrdir=$basedir/usr
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "Campcaster scheduler database creation script.";
echo "parameters";
echo "";
echo " -D, --database The name of the Campcaster database.";
echo " [default: Campcaster]";
echo " -s, --dbserver The name of the database server host.";
echo " [default: localhost]";
echo " -u, --dbuser The name of the database user to access the"
echo " database. [default: campcaster]";
echo " -w, --dbpassword The database user password.";
echo " [default: campcaster]";
echo " -h, --help Print this message and exit.";
echo "";
}
#-------------------------------------------------------------------------------
# Process command line parameters
#-------------------------------------------------------------------------------
CMD=${0##*/}
opts=$(getopt -o D:hs:u:w: -l database:,dbserver:,dbuser:,dbpassword:,help, -n $CMD -- "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
-D|--database)
database=$2;
shift; shift;;
-h|--help)
printUsage;
exit 0;;
-s|--dbserver)
dbserver=$2;
shift; shift;;
-u|--dbuser)
dbuser=$2;
shift; shift;;
-w|--dbpassword)
dbpassword=$2;
shift; shift;;
--)
shift;
break;;
*)
echo "Unrecognized option $1.";
printUsage;
exit 1;
esac
done
if [ "x$dbserver" == "x" ]; then
dbserver=localhost;
fi
if [ "x$database" == "x" ]; then
database=Campcaster;
fi
if [ "x$dbuser" == "x" ]; then
dbuser=campcaster;
fi
if [ "x$dbpassword" == "x" ]; then
dbpassword=campcaster;
fi
echo "Creating database for Campcaster scheduler.";
echo "";
echo "Using the following parameters:";
echo "";
echo " database server: $dbserver";
echo " database: $database";
echo " database user: $dbuser";
echo " database user password: $dbpassword";
echo ""
#-------------------------------------------------------------------------------
# The details of installation
#-------------------------------------------------------------------------------
ls_dbserver=$dbserver
ls_dbuser=$dbuser
ls_dbpassword=$dbpassword
ls_database=$database
postgres_user=postgres
#-------------------------------------------------------------------------------
# Function to check for the existence of an executable on the PATH
#
# @param $1 the name of the exectuable
# @return 0 if the executable exists on the PATH, non-0 otherwise
#-------------------------------------------------------------------------------
check_exe() {
if [ -x "`which $1 2> /dev/null`" ]; then
echo "Executable $1 found...";
return 0;
else
echo "Executable $1 not found...";
return 1;
fi
}
#-------------------------------------------------------------------------------
# Check to see if this script is being run as root
#-------------------------------------------------------------------------------
if [ `whoami` != "root" ]; then
echo "Please run this script as root.";
exit ;
fi
#-------------------------------------------------------------------------------
# Check for required tools
#-------------------------------------------------------------------------------
echo "Checking for required tools..."
check_exe "su" || exit 1;
check_exe "psql" || exit 1;
#-------------------------------------------------------------------------------
# Create the necessary database user and database itself
#-------------------------------------------------------------------------------
echo "Creating database and database user...";
# FIXME: the below might not work for remote databases
if [ "x$ls_dbserver" == "xlocalhost" ]; then
su - $postgres_user -c "echo \"CREATE USER $ls_dbuser \
ENCRYPTED PASSWORD '$ls_dbpassword' \
CREATEDB NOCREATEUSER;\" \
| psql template1" \
|| echo "Couldn't create database user $ls_dbuser.";
su - $postgres_user -c "echo \"CREATE DATABASE \\\"$ls_database\\\" \
OWNER $ls_dbuser ENCODING 'utf-8';\" \
| psql template1" \
|| echo "Couldn't create database $ls_database.";
else
echo "Unable to automatically create database user and table for";
echo "remote database $ls_dbserver.";
echo "Make sure to create database user $ls_dbuser with password";
echo "$ls_dbpassword on database server at $ls_dbserver.";
echo "Also create a database called $ld_database, owned by this user.";
echo "";
echo "The easiest way to achieve this is by issuing the following SQL";
echo "commands to PostgreSQL:";
echo "CREATE USER $ls_dbuser";
echo " ENCRYPTED PASSWORD '$ls_dbpassword'";
echo " CREATEDB NOCREATEUSER;";
echo "CREATE DATABASE \"$ls_database\"";
echo " OWNER $ls_dbuser ENCODING 'utf-8';";
fi
# TODO: check for the success of these operations somehow
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "Done."

10
utils/dumpDbSchema.php Normal file
View file

@ -0,0 +1,10 @@
<?
require_once('conf.php');
require_once("$STORAGE_SERVER_PATH/var/conf.php");
header("Conten-type: text/plain");
$dbname = $CC_CONFIG['dsn']['database'];
$dbuser = $CC_CONFIG['dsn']['username'];
$dbhost = $CC_CONFIG['dsn']['hostspec'];
$res = `pg_dump -s $dbname -U $dbuser`;
echo "$res\n";
?>

85
utils/dumpDbSchema.sh Executable file
View file

@ -0,0 +1,85 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script dumps the schema of the Campcaster database.
#
# To get usage help, try the -h option
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`/..
phpdir=ls_storageAdmin_phppart_dir
if [ "$phpdir" == "ls_storageAdmin_phppart_dir" ]
then
phpdir=`cd $reldir/var; pwd`
fi
filelistpathname=.
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "This script dumps the schema of the Campcaster database.";
echo "parameters:";
echo "";
echo " -h, --help Print this message and exit.";
echo "";
}
#-------------------------------------------------------------------------------
# Process command line parameters
#-------------------------------------------------------------------------------
CMD=${0##*/}
opts=$(getopt -o h -l help -n $CMD -- "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
-h|--help)
printUsage;
exit 0;;
--)
shift;
break;;
*)
echo "Unrecognized option $1.";
printUsage;
exit 1;
esac
done
#-------------------------------------------------------------------------------
# Do the schema dump
#-------------------------------------------------------------------------------
cd $phpdir
php -q dumpDbSchema.php
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "-- End of dump."

7
utils/getStorPath.php Normal file
View file

@ -0,0 +1,7 @@
<?php
header("Content-type: text/plain");
require_once('conf.php');
require_once("$STORAGE_SERVER_PATH/var/conf.php");
echo $CC_CONFIG['storageDir']."\n";
?>

40
utils/getUrl.sh Executable file
View file

@ -0,0 +1,40 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
# To report bugs, send an e-mail to bugs@campware.org
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script grabs string at suplied URL
#-------------------------------------------------------------------------------
URL=$1
RES=`curl -sf ${URL}` || \
{
ERN=$?;
if [ $ERN -eq 22 ] ; then
echo "ERROR: curl: 22 - wrong URL ($URL)";
else
echo "ERROR: $ERN - unknown";
fi;
exit $ERN;
}
echo $RES

113
utils/renderer.sh Executable file
View file

@ -0,0 +1,113 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
# To report bugs, send an e-mail to bugs@campware.org
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
# Playlist-to-file renderer caller. DUMMY VERSION.
#
# To get usage help, try the -h option
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`/..
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "Playlist-to-file renderer caller. DUMMY VERSION.";
echo "parameters:";
echo "";
echo " -p, --playlist URL of SMIL playlist to be rendered.";
echo " -s, --statusfile Status file name.";
echo " -o, --output File name where the output will be written.";
echo " -h, --help Print this message and exit.";
echo "";
}
#-------------------------------------------------------------------------------
# Process command line parameters
#-------------------------------------------------------------------------------
CMD=${0##*/}
opts=$(getopt -o hp:s:o: -l help,playlist:,statusfile:,output: -n $CMD -- "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
-h|--help)
printUsage;
exit 0;;
-p|--playlist)
playlist=$2
shift; shift;;
-s|--statusfile)
statusfile=$2
shift; shift;;
-o|--output)
output=$2
shift; shift;;
--)
shift;
break;;
*)
echo "Unrecognized option $1.";
printUsage;
exit 1;
esac
done
if [ "x$playlist" == "x" ]; then
echo "Error in playlist parameter";
printUsage;
exit 1;
fi
if [ "x$statusfile" == "x" ]; then
echo "Error in statusfile parameter";
printUsage;
exit 1;
fi
if [ "x$output" == "x" ]; then
echo "Error in output parameter";
printUsage;
exit 1;
fi
#-------------------------------------------------------------------------------
# Do it
#-------------------------------------------------------------------------------
echo "renderer.sh: rendering $playlist to $output"
echo "working" > $statusfile;
touch $output || { echo "fail" > $statusfile; exit 1; }
#sleep 4
#sleep 2
echo -e "$playlist\n$output" >> $output || { echo "fail" > $statusfile; exit 1; }
echo "success" > $statusfile
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "done"
exit 0

41
utils/resetStorage.sh Executable file
View file

@ -0,0 +1,41 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
# To report bugs, send an e-mail to bugs@campware.org
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; 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

256
utils/restore.php Normal file
View file

@ -0,0 +1,256 @@
<?php
define('NSPACE', 'lse');
define('VERBOSE', FALSE);
#define('VERBOSE', TRUE);
header("Content-type: text/plain");
require_once 'conf.php';
require_once "$STORAGE_SERVER_PATH/var/conf.php";
require_once 'DB.php';
require_once "XML/Util.php";
require_once "XML/Beautifier.php";
require_once "$STORAGE_SERVER_PATH/var/BasicStor.php";
require_once "$STORAGE_SERVER_PATH/var/Prefs.php";
/* =========================================================== misc functions */
function ls_restore_processObject($el)
{
$res = array(
'name' => $el->attrs['name']->val,
'type' => $el->name,
);
switch ($res['type']) {
case 'folder':
foreach ($el->children as $i => $o) {
$res['children'][] = ls_restore_processObject($o);
}
break;
default:
$res['gunid'] = $el->attrs['id']->val;
break;
}
return $res;
}
function ls_restore_checkErr($r, $ln='')
{
if (PEAR::isError($r)) {
echo "ERROR $ln: ".$r->getMessage()." ".$r->getUserInfo()."\n";
exit;
}
}
function ls_restore_restoreObject($obj, /*$parid,*/ $reallyInsert=TRUE){
global $tmpdir, $bs;
switch ($obj['type']) {
case "audioClip";
case "webstream";
case "playlist";
$gunid = $obj['gunid'];
if (is_null($gunid)) {
break;
}
$gunid3 = substr($gunid, 0, 3);
$mediaFile = "$tmpdir/stor/$gunid3/$gunid";
# echo "X1 $gunid, $gunid3, $mediaFile\n";
if (!file_exists($mediaFile)) {
$mediaFile = NULL;
}
$mdataFile = "$tmpdir/stor/$gunid3/$gunid.xml";
if (!file_exists($mdataFile)) {
$mdataFile = NULL;
}
if ($reallyInsert) {
if (VERBOSE) {
echo " creating file {$obj['name']} ...\n";
}
$values = array(
"filename" => $obj['name'],
"filepath" => $mediaFile,
"metadata" => $mdataFile,
"gunid" => $obj['gunid'],
"filetype" => strtolower($obj['type'])
);
$r = $bs->bsPutFile($values);
ls_restore_checkErr($r, __LINE__);
}
break;
}
}
/* =============================================================== processing */
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$bs = new BasicStor();
$pr = new Prefs($bs);
$dbxml = file_get_contents($argv[1]);
$tmpdir = $argv[2];
require_once("$STORAGE_SERVER_PATH/var/XmlParser.php");
$parser = new XmlParser($dbxml);
if ($parser->isError()) {
return PEAR::raiseError(
"MetaData::parse: ".$parser->getError()
);
}
$xmlTree = $parser->getTree();
/* ----------------------------------------- processing storageServer element */
$subjArr = FALSE;
//$tree = FALSE;
foreach ($xmlTree->children as $i => $el) {
switch ($el->name) {
case "subjects":
if ($subjArr !== FALSE) {
echo "ERROR: unexpected subjects element\n";
}
$subjArr = $el->children;
break;
// case "folder":
// if ($tree !== FALSE) {
// echo "ERROR: unexpected folder element\n";
// }
// $tree = ls_restore_processObject($el);
// break;
default:
echo "ERROR: unknown element name {$el->name}\n";
exit;
}
// echo "{$el->name}\n";
}
/* ---------------------------------------------- processing subjects element */
$subjects = array();
$groups = array();
foreach ($subjArr as $i => $el) {
switch ($el->name) {
case "group":
$grname = $el->attrs['name']->val;
$groups[$grname] = $el->children;
$subjects[$grname] = array(
'type' => 'group',
);
break;
case "user":
$login = $el->attrs['login']->val;
$subjects[$login] = array(
'type' => 'user',
'pass' => $el->attrs['pass']->val,
# 'realname' => $el->attrs['realname']->val,
'realname' => '',
'prefs' => (isset($el->children[0]) ? $el->children[0]->children : NULL),
);
break;
}
}
/* -------------------------------------------------------- processing groups */
foreach ($groups as $grname => $group) {
foreach ($group as $i => $el) {
switch ($el->name) {
case "member":
$groups[$grname][$i] = $el->attrs['name']->val;
break;
case "preferences":
$subjects[$grname]['prefs'] = $el->children;
unset($groups[$grname][$i]);
break;
}
}
}
#var_dump($xmlTree);
#var_dump($subjArr);
#var_dump($groups);
#var_dump($subjects);
#var_dump($tree);
#exit;
/* ================================================================ restoring */
if (VERBOSE) {
echo " resetting storage ...\n";
}
$bs->resetStorage(FALSE);
$storId = $bs->storId;
/* ------------------------------------------------------- restoring subjects */
foreach ($subjects as $login => $subj) {
$uid0 = Subjects::GetSubjId($login);
ls_restore_checkErr($uid0);
switch ($subj['type']) {
case "user":
if ($login=='root') {
$r = $bs->passwd($login, NULL, $subj['pass'], TRUE);
ls_restore_checkErr($r, __LINE__);
$uid = $uid0;
} else {
if (!is_null($uid0)) {
$r = $bs->removeSubj($login);
ls_restore_checkErr($r, __LINE__);
}
if (VERBOSE) {
echo " adding user $login ...\n";
}
$uid = $bs->addSubj($login, $subj['pass'], $subj['realname'], TRUE);
ls_restore_checkErr($uid, __LINE__);
}
break;
case "group":
if (!is_null($uid0)) {
$r = $bs->removeSubj($login);
if (PEAR::isError($r)) {
$uid = $uid0;
break;
}
//ls_restore_checkErr($r, __LINE__);
}
if (VERBOSE) {
echo " adding group $login ...\n";
}
$uid = $bs->addSubj($login, NULL);
ls_restore_checkErr($uid, __LINE__);
// var_export($uid); echo " ";
break;
} // switch
// echo "$login/$uid :\n";
if (isset($subj['prefs'])) {
// var_dump($subj['prefs']); exit;
foreach ($subj['prefs'] as $i => $el) {
switch ($el->name) {
case "pref":
$prefkey = $el->attrs['name']->val;
$prefval = $el->attrs['val']->val;
// echo" PREF($prefkey)=$prefval\n";
$res = $pr->insert($uid, $prefkey, $prefval);
ls_restore_checkErr($res, __LINE__);
break;
default:
var_dump($el);
}
}
}
}
/* --------------------------------------------------------- restoring groups */
#var_dump($groups);
foreach ($groups as $grname => $group) {
foreach ($group as $i => $login) {
if (VERBOSE) {
echo " adding subject $login to group $grname ...\n";
}
$r = Subjects::AddSubjectToGroup($login, $grname);
ls_restore_checkErr($r, __LINE__);
}
}
/* -------------------------------------------------------- restoring objects */
ls_restore_restoreObject($tree, /*$storId,*/ FALSE);
?>

88
utils/setupDirs.sh Executable file
View file

@ -0,0 +1,88 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
#
# Campcaster 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.
#
# Campcaster 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 Campcaster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script does httpd writeable directories setup
#-------------------------------------------------------------------------------
WWW_ROOT=`cd var/install; php -q getWwwRoot.php` || exit $?
echo " *** StorageServer bin/setupDirs.sh BEGIN"
echo " * Root URL: $WWW_ROOT"
PHP_PWD_COMMAND=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \
{
errno=$?
if [ $errno -eq 22 ]
then
echo "root URL is not accessible - configure HTTP entry point, please"
fi
exit $errno
}
PHP_PWD=$PHP_PWD_COMMAND
# MOD_PHP may not be working, this command will tell us
if [ ${PHP_PWD_COMMAND:0:5} == '<?php' ]; then
echo "MOD_PHP is not working, the raw PHP file is being returned instead of result of the PHP code."
exit 1
fi
if [ $PHP_PWD == "" ]; then
echo " * ERROR: Could not get PHP working directory."
exit 1
fi
echo " ** Webspace mapping test:"
echo " * mod_php : $PHP_PWD"
INSTALL_DIR="$PWD/var/install"
echo " * install : $INSTALL_DIR"
if [ $PHP_PWD == $INSTALL_DIR ]; then
echo " * Mapping OK"
else
echo " * WARNING: there was a problem with webspace mapping!!!"
fi
HTTP_GROUP=`bin/getUrl.sh $WWW_ROOT/install/getGname.php` || \
{
ERN=$?;
echo $HTTP_GROUP;
echo " -> Probably wrong setting in var/conf.php: URL configuration";
exit $ERN;
}
echo " ** The system group that is running the http daemon: '$HTTP_GROUP'"
for i in $*
do
echo " * chown :$HTTP_GROUP $i"
if [ -G $i ]; then
chown :$HTTP_GROUP $i || \
{
ERN=$?;
echo "ERROR: chown :$HTTP_GROUP $i -> You should have permissions to set group owner to group '$HTTP_GROUP'";
exit $ERN;
}
echo " * chmod g+sw $i"
chmod g+sw $i || exit $?
fi
done
echo " *** StorageServer bin/setupDirs.sh END"
exit 0