#!/bin/bash
# Works through each station and builds component parts for a Minerva-compliant
# web interface

# Call this whenever you can get more TV stations that before.

WEB_IMAGES_FOLDER=/var/www/minerva/warp/conf/tvguide/images/
TARGET_FOLDER=/var/www/minerva/warp/conf/tvguide
TARGET=$TARGET_FOLDER/channels.conf

mkdir -p $TARGET_FOLDER

echo \<?php >$TARGET
echo class Warp_TVGuide_Channels { >> $TARGET
echo function getChannelList\(\) {  >> $TARGET
echo   return array\(  >> $TARGET

# Write basic code config for channels
for ch in `ls stations`; do
   echo "\"$ch\" => \"`cat stations/$ch`\"," >> $TARGET
done

echo ");} }" >> $TARGET
echo ?\> >> $TARGET

# Now the station idents
mkdir -p $WEB_IMAGES_FOLDER
cp -a images/* $WEB_IMAGES_FOLDER

