From 3c12256cb81543d386c8d00b2cd59dfc18489fa2 Mon Sep 17 00:00:00 2001 From: Paul Baranowski Date: Fri, 3 Dec 2010 15:34:18 -0500 Subject: [PATCH] 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. --- .../{nondbinstall.php => propel-install.php} | 0 install/pypo-install.py | 51 +++++++ install/setupDevelopmentEnvironment.sh | 121 ---------------- install/upgrade-1.3-to-1.4.sql | 134 ------------------ install/upgrade/upgrade-to-1.2.0.php | 101 ------------- install/upgrade/upgrade.php | 1 - pypo/scripts/include_dynamic_vars.liq | 26 ---- pypo/scripts/include_live_in.liq | 4 - pypo/scripts/include_notify.liq | 18 +-- pypo/scripts/include_scheduler.liq | 11 +- pypo/scripts/ls_config.liq | 17 +-- pypo/scripts/ls_script.liq | 56 +------- pypo/scripts/pypo_log.sh | 2 +- pypo/scripts/silence-playlist.lsp | 48 +++++++ 14 files changed, 120 insertions(+), 470 deletions(-) rename install/{nondbinstall.php => propel-install.php} (100%) create mode 100644 install/pypo-install.py delete mode 100755 install/setupDevelopmentEnvironment.sh delete mode 100644 install/upgrade-1.3-to-1.4.sql delete mode 100644 install/upgrade/upgrade-to-1.2.0.php delete mode 120000 install/upgrade/upgrade.php create mode 100644 pypo/scripts/silence-playlist.lsp diff --git a/install/nondbinstall.php b/install/propel-install.php similarity index 100% rename from install/nondbinstall.php rename to install/propel-install.php diff --git a/install/pypo-install.py b/install/pypo-install.py new file mode 100644 index 000000000..3f50436d8 --- /dev/null +++ b/install/pypo-install.py @@ -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." + diff --git a/install/setupDevelopmentEnvironment.sh b/install/setupDevelopmentEnvironment.sh deleted file mode 100755 index 4d37c5e39..000000000 --- a/install/setupDevelopmentEnvironment.sh +++ /dev/null @@ -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." - diff --git a/install/upgrade-1.3-to-1.4.sql b/install/upgrade-1.3-to-1.4.sql deleted file mode 100644 index 66e4d60a6..000000000 --- a/install/upgrade-1.3-to-1.4.sql +++ /dev/null @@ -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; diff --git a/install/upgrade/upgrade-to-1.2.0.php b/install/upgrade/upgrade-to-1.2.0.php deleted file mode 100644 index 6303e6dd7..000000000 --- a/install/upgrade/upgrade-to-1.2.0.php +++ /dev/null @@ -1,101 +0,0 @@ -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"; - -?> diff --git a/install/upgrade/upgrade.php b/install/upgrade/upgrade.php deleted file mode 120000 index 1c42eb52c..000000000 --- a/install/upgrade/upgrade.php +++ /dev/null @@ -1 +0,0 @@ -upgrade-to-1.2.0.php \ No newline at end of file diff --git a/pypo/scripts/include_dynamic_vars.liq b/pypo/scripts/include_dynamic_vars.liq index 54e285d4b..16e81189f 100644 --- a/pypo/scripts/include_dynamic_vars.liq +++ b/pypo/scripts/include_dynamic_vars.liq @@ -2,36 +2,10 @@ # Dynamic variables ####################################################################### -playlist_id = ref '0' -user_id = ref '0' -transmission_id = ref '0' -playlist_type = ref '0' pypo_data = ref '0' def set_pypo_data(s) pypo_data := s end -def set_user_id(s) - user_id := s -end - - -def set_playlist_id(s) - playlist_id := s -end - - -def set_transmission_id(s) - transmission_id := s -end - -def set_playlist_type(s) - playlist_type := s -end - -server.register(namespace="vars", "user_id", fun (s) -> begin set_user_id(s) "Done!" end) -server.register(namespace="vars", "playlist_id", fun (s) -> begin set_playlist_id(s) "Done!" end) -server.register(namespace="vars", "transmission_id", fun (s) -> begin set_transmission_id(s) "Done!" end) -server.register(namespace="vars", "playlist_type", fun (s) -> begin set_playlist_type(s) "Done!" end) server.register(namespace="vars", "pypo_data", fun (s) -> begin set_pypo_data(s) "Done!" end) \ No newline at end of file diff --git a/pypo/scripts/include_live_in.liq b/pypo/scripts/include_live_in.liq index c20bf876a..c2e6bef86 100644 --- a/pypo/scripts/include_live_in.liq +++ b/pypo/scripts/include_live_in.liq @@ -1,14 +1,10 @@ ####################################################################### # Live input - From external icecast server ####################################################################### - - live_in = input.http(id="live_in",autostart=false,buffer=.1, max=12.,couchcaster_list) live_in = buffer(id="buffer_live_in",buffer=.1,fallible=true,live_in) live_in = mksafe(live_in) - - live_active = ref false def live_switch(i) print(i) diff --git a/pypo/scripts/include_notify.liq b/pypo/scripts/include_notify.liq index 765ab4168..0c96cf31a 100644 --- a/pypo/scripts/include_notify.liq +++ b/pypo/scripts/include_notify.liq @@ -4,25 +4,19 @@ def notify(m) -# print('user_id: #{!user_id}') -# print('playlist_id: #{!playlist_id}') -# print('transmission_id: #{!transmission_id}') -# print('playlist_type: #{!playlist_type}') - if !playlist_type=='5' then - print('livesession') - system("./notify.sh --playing --playlist-type=#{!playlist_type} --transmission-id=#{!transmission_id} --export-source=scheduler") + #print('livesession') + system("./notify.sh --data='#{!pypo_data}' --media-id=#{m['media_id']} --export-source=scheduler") end if !playlist_type=='6' then - print('couchcaster') - system("./notify.sh --playing --playlist-type=#{!playlist_type} --transmission-id=#{!transmission_id} --export-source=scheduler") + #print('couchcaster') + system("./notify.sh --data='#{!pypo_data}' --media-id=#{m['media_id']} --export-source=scheduler") end if !playlist_type=='0' or !playlist_type=='1' or !playlist_type=='2' or !playlist_type=='3' or !playlist_type=='4' then - print('include_notify.liq: notify on playlist') - #system("./notify.sh --playing --playlist-type=#{!playlist_type} --media-id=#{m['media_id']} --export-source=#{m['export_source']}") - system("./notify.sh --data='#{!pypo_data}' --media-id=#{m['media_id']}") + #print('include_notify.liq: notify on playlist') + system("./notify.sh --data='#{!pypo_data}' --media-id=#{m['media_id']}") end end \ No newline at end of file diff --git a/pypo/scripts/include_scheduler.liq b/pypo/scripts/include_scheduler.liq index e60e1435b..7ff446d4a 100644 --- a/pypo/scripts/include_scheduler.liq +++ b/pypo/scripts/include_scheduler.liq @@ -51,11 +51,12 @@ end def scheduler_status() print('scheduler_active: #{!scheduler_active}') print('scheduler_queue : #{!scheduler_queue}') - - print('user_id: #{!user_id}') - print('playlist_id: #{!playlist_id}') - print('transmission_id: #{!transmission_id}') - print('playlist_type: #{!playlist_type}') + print('pypo_data: #{!pypo_data}') + + #print('user_id: #{!user_id}') + #print('playlist_id: #{!playlist_id}') + #print('transmission_id: #{!transmission_id}') + #print('playlist_type: #{!playlist_type}') "Done" end diff --git a/pypo/scripts/ls_config.liq b/pypo/scripts/ls_config.liq index 50b8f89a7..32bc341b8 100644 --- a/pypo/scripts/ls_config.liq +++ b/pypo/scripts/ls_config.liq @@ -1,12 +1,7 @@ ########################################### # liquidsoap config file # ########################################### - -# author Jonas Ohrstrom - - -# this file is specific to the obp -# installation. eg it assumes that there are +# This config assumes that there are # two instances of LS running # the "scheduler" & the "fallback" instance @@ -15,22 +10,20 @@ # general settings # ########################################### -log_file = "/var/log/obp/ls/