Started to create pypo install script (install/pypo-install.py).

Cleaned up liquidsoap scripts a bit.

Renamed nondbinstall.php to propel-install.php

Removed unused files.
This commit is contained in:
Paul Baranowski 2010-12-03 15:34:18 -05:00
parent 51a1fde9ee
commit 3c12256cb8
14 changed files with 120 additions and 470 deletions

51
install/pypo-install.py Normal file
View file

@ -0,0 +1,51 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import os
import traceback
from optparse import *
import sys
import time
import datetime
import logging
import logging.config
import shutil
import string
from subprocess import Popen, PIPE, STDOUT
def create_path(path):
if not (os.path.exists(path)):
print "Creating directory " + path
os.makedirs(path)
try:
# Does pypo user exist?
print "Checking for pypo user..."
p = Popen('id pypo', shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
output = p.stdout.read()
if (output[0:3] != "uid"):
# Make the pypo user
print "Creating pypo user..."
os.system("adduser --system --quiet --group --disabled-login --no-create-home pypo")
print "Creating directories..."
create_path("/var/log/pypo")
os.system("chmod -R 755 /var/log/pypo")
os.system("chown -R pypo:pypo /var/log/pypo")
#os.mkdirs("/var/log/liquidsoap")
#os.system("chown -R liquidsoap:liquidsoap /var/log/liquidsoap")
create_path("/opt/pypo")
create_path("/opt/pypo/cache")
create_path("/opt/pypo/files")
create_path("/opt/pypo/files/basic")
create_path("/opt/pypo/files/fallback")
create_path("/opt/pypo/files/jingles")
create_path("/opt/pypo/archive")
os.system("chmod -R 755 /opt/pypo/")
os.system("chown -R pypo:pypo /opt/pypo")
except Exception, e:
print "exception:" + str(e)
print "Done."

View file

@ -1,121 +0,0 @@
#!/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
#
#-------------------------------------------------------------------------------
# A script to set up the development environment for Campcaster
#
# Invoke as:
# ./bin/setupDevelopmentEnvironment.sh
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`/..
basedir=`cd $reldir; pwd;`
bindir=$basedir/bin
etcdir=$basedir/etc
docdir=$basedir/doc
srcdir=$basedir/src
tmpdir=$basedir/tmp
toolsdir=$srcdir/tools
modules_dir=$srcdir/modules
products_dir=$srcdir/products
usrdir=`cd $basedir/usr; pwd;`
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "Campcaster development environment setup script.";
echo "parameters";
echo "";
echo " -g, --apache-group The group the apache daemon runs as.";
echo " [default: apache]";
echo " -h, --help Print this message and exit.";
echo "";
}
#-------------------------------------------------------------------------------
# Process command line parameters
#-------------------------------------------------------------------------------
CMD=${0##*/}
opts=$(getopt -o g:h -l apache-group:,help -n $CMD -- "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
-g|--apache-group)
apache_group=$2;
shift; shift;;
-h|--help)
printUsage;
exit 0;;
--)
shift;
break;;
*)
echo "Unrecognized option $1.";
printUsage;
exit 1;
esac
done
if [ "x$apache_group" == "x" ]; then
apache_group=apache;
fi
#-------------------------------------------------------------------------------
# Create the configure script
#-------------------------------------------------------------------------------
rm -rf $tmpdir/configure
$bindir/autogen.sh || exit 1
$basedir/configure --prefix=$usrdir \
--with-www-docroot=$usrdir/var \
--with-apache-group=$apache_group \
--enable-debug || exit 1
#-------------------------------------------------------------------------------
# Compile everything at once, including the tools
#-------------------------------------------------------------------------------
make -C $basedir all || exit 1
#-------------------------------------------------------------------------------
# User setup
#-------------------------------------------------------------------------------
#echo "Setting up user settings..."
$bindir/user_setup.sh --apache-group=$apache_group || exit 1
#-------------------------------------------------------------------------------
# We're done
#-------------------------------------------------------------------------------
echo "Done."

View file

@ -1,134 +0,0 @@
CREATE SEQUENCE file_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1000000
CACHE 1;
ALTER TABLE ls_files
ALTER COLUMN id
SET DEFAULT NEXTVAL('file_id_seq');
DROP TABLE ls_struct CASCADE;
DROP TABLE ls_tree CASCADE;
DROP TABLE ls_classes CASCADE;
DROP TABLE ls_cmemb CASCADE;
DROP SEQUENCE ls_struct_id_seq_seq;
DROP SEQUENCE ls_tree_id_seq_seq;
DROP TABLE as_tree CASCADE;
DROP TABLE as_struct CASCADE;
DROP TABLE as_classes CASCADE;
DROP TABLE as_cmemb CASCADE;
DROP SEQUENCE as_struct_id_seq_seq;
DROP SEQUENCE as_tree_id_seq_seq;
ALTER TABLE cc_files
ADD COLUMN track_title character varying(512);
ALTER TABLE cc_files
ADD COLUMN artist_name character varying(512);
ALTER TABLE cc_files
ADD COLUMN bit_rate character varying(32);
ALTER TABLE cc_files
ADD COLUMN sample_rate character varying(32);
ALTER TABLE cc_files
ADD COLUMN format character varying(128);
ALTER TABLE cc_files
ADD COLUMN length character (16);
ALTER TABLE cc_files
ADD COLUMN album_title character varying(512);
ALTER TABLE cc_files
ADD COLUMN genre character varying(64);
ALTER TABLE cc_files
ADD COLUMN comments text;
ALTER TABLE cc_files
ADD COLUMN "year" character varying(16);
ALTER TABLE cc_files
ADD COLUMN track_number integer;
ALTER TABLE cc_files
ADD COLUMN channels integer;
ALTER TABLE cc_files
ADD COLUMN url character varying(1024);
ALTER TABLE cc_files
ADD COLUMN bpm character varying(8);
ALTER TABLE cc_files
ADD COLUMN rating character varying(8);
ALTER TABLE cc_files
ADD COLUMN encoded_by character varying(255);
ALTER TABLE cc_files
ADD COLUMN disc_number character varying(8);
ALTER TABLE cc_files
ADD COLUMN mood character varying(64);
ALTER TABLE cc_files
ADD COLUMN label character varying(512);
ALTER TABLE cc_files
ADD COLUMN composer character varying(512);
ALTER TABLE cc_files
ADD COLUMN encoder character varying(64);
ALTER TABLE cc_files
ADD COLUMN checksum character varying(256);
ALTER TABLE cc_files
ADD COLUMN lyrics text;
ALTER TABLE cc_files
ADD COLUMN orchestra character varying(512);
ALTER TABLE cc_files
ADD COLUMN conductor character varying(512);
ALTER TABLE cc_files
ADD COLUMN lyricist character varying(512);
ALTER TABLE cc_files
ADD COLUMN original_lyricist character varying(512);
ALTER TABLE cc_files
ADD COLUMN radio_station_name character varying(512);
ALTER TABLE cc_files
ADD COLUMN info_url character varying(512);
ALTER TABLE cc_files
ADD COLUMN artist_url character varying(512);
ALTER TABLE cc_files
ADD COLUMN audio_source_url character varying(512);
ALTER TABLE cc_files
ADD COLUMN radio_station_url character varying(512);
ALTER TABLE cc_files
ADD COLUMN buy_this_url character varying(512);
ALTER TABLE cc_files
ADD COLUMN isrc_number character varying(512);
ALTER TABLE cc_files
ADD COLUMN catalog_number character varying(512);
ALTER TABLE cc_files
ADD COLUMN original_artist character varying(512);
ALTER TABLE cc_files
ADD COLUMN copyright character varying(512);
ALTER TABLE cc_files
ADD COLUMN report_datetime character varying(32);
ALTER TABLE cc_files
ADD COLUMN report_location character varying(512);
ALTER TABLE cc_files
ADD COLUMN report_organization character varying(512);
ALTER TABLE cc_files
ADD COLUMN subject character varying(512);
ALTER TABLE cc_files
ADD COLUMN contributor character varying(512);
ALTER TABLE cc_files
ADD COLUMN language character varying(512);
ALTER TABLE cc_schedule RENAME playlist TO playlist_id;
ALTER TABLE cc_schedule ALTER playlist_id TYPE integer;
ALTER TABLE cc_schedule ADD COLUMN group_id integer;
ALTER TABLE cc_schedule ADD COLUMN file_id integer;
ALTER TABLE cc_schedule
ADD COLUMN clip_length time without time zone DEFAULT '00:00:00.000000';
ALTER TABLE cc_schedule
ADD COLUMN fade_in time without time zone DEFAULT '00:00:00.000';
ALTER TABLE cc_schedule
ADD COLUMN fade_out time without time zone DEFAULT '00:00:00.000';
ALTER TABLE cc_schedule
ADD COLUMN cue_in time without time zone DEFAULT '00:00:00.000';
ALTER TABLE cc_schedule
ADD COLUMN cue_out time without time zone DEFAULT '00:00:00.000';
ALTER TABLE cc_schedule ADD CONSTRAINT unique_id UNIQUE (id);
CREATE SEQUENCE schedule_group_id_seq;
DROP TABLE cc_mdata CASCADE;

View file

@ -1,101 +0,0 @@
<?php
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*
*/
// 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);
}
echo "*********************************************\n";
echo "* StorageServer Upgrade from 1.1.X to 1.2.0 *\n";
echo "*********************************************\n";
require_once(dirname(__FILE__).'/../../conf.php');
require_once(dirname(__FILE__)."/../installInit.php");
campcaster_db_connect();
require_once(dirname(__FILE__)."/../../StoredFile.php");
// Check to see if upgrade has already been applied
$sql = "SELECT md5 FROM ".$CC_CONFIG['filesTable']." LIMIT 1";
$result = $CC_DBC->query($sql);
if (!PEAR::isError($result)) {
echo " * THIS UPGRADE HAS ALREADY BEEN APPLIED.\n";
exit(0);
}
echo " * Adding column 'md5' to '".$CC_CONFIG['filesTable']." table...";
$sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ADD COLUMN md5 char(32)";
camp_install_query($sql, false);
$sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ALTER COLUMN md5 SET STORAGE EXTENDED";
camp_install_query($sql);
echo " * Creating index on column 'md5'...";
$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx ON ".$CC_CONFIG['filesTable']." (md5)";
camp_install_query($sql);
echo " * Converting metadata values 'ls:genre' to 'dc:type'...";
$sql = "UPDATE ".$CC_CONFIG['mdataTable']." SET predns='dc', predicate='type' WHERE predns='ls' and predicate='genre'";
camp_install_query($sql);
echo " * Adding 'jobpid' to ".$CC_CONFIG['transTable']."...";
$sql = "ALTER TABLE ".$CC_CONFIG['transTable']." ADD COLUMN jobpid int";
camp_install_query($sql);
echo " * Fixing track numbers...\n";
$sql = "SELECT id, object as track_num FROM ".$CC_CONFIG['mdataTable']
." WHERE predns='ls' AND predicate='track_num'";
$rows = $CC_DBC->GetAll($sql);
foreach ($rows as $row) {
$newTrackNum = camp_parse_track_number($row["track_num"]);
if ($row["track_num"] != $newTrackNum) {
echo " * Converting '".$row["track_num"]."' --> '$newTrackNum'\n";
$sql = "UPDATE ".$CC_CONFIG["mdataTable"]
." SET object='$newTrackNum'"
." WHERE id=".$row["id"];
$CC_DBC->query($sql);
}
}
// Get MD5 values for all files
echo " * Computing MD5 sums for all files (this may take a while)...\n";
$sql = "SELECT to_hex(gunid) as gunid, name FROM ".$CC_CONFIG['filesTable'] ." WHERE ftype='audioclip'";
$rows = $CC_DBC->GetAll($sql);
$errorFiles = array();
foreach ($rows as $row) {
$gunid = StoredFile::NormalizeGunid($row['gunid']);
$storedFile = new StoredFile($gunid);
$fileName = $storedFile->getRealFileName();
$humanName = basename($row['name']);
echo " File: $humanName\n";
if (file_exists($fileName)) {
$md5 = md5_file($fileName);
$storedFile->setMd5($md5);
//echo " MD5: $md5\n";
} else {
$errorFiles[] = "$gunid -- $humanName";
echo " ERROR: file does not exist! (GUNID: $gunid)\n";
}
}
if (count($errorFiles) > 0) {
echo "\n\nWARNING\n";
echo "The following files were not found:\n";
foreach ($errorFiles as $file) {
echo $file."\n";
}
}
echo "*******************************************\n";
echo "* StorageServer Upgrade to 1.2.0 Complete *\n";
echo "*******************************************\n";
?>

View file

@ -1 +0,0 @@
upgrade-to-1.2.0.php