Skip to content
Snippets Groups Projects
Commit bf546d70 authored by ale's avatar ale
Browse files

use local packages in Vagrant, setup ices2 as test source

parent d6024274
No related branches found
No related tags found
No related merge requests found
.vagrant
*.deb
song*.ogg
# Vagrantfile for a test 3-node autoradio cluster.
#
# By default it will pull autoradio packages from the public
# repository. Set the environment variable LOCAL to a non-empty value
# if you want to use local packages, in which case the 'etcd' and
# 'autoradio' packages should be placed in the same directory as this
# file.
API_VERSION = "2"
# Note: we shouldn't need to create a host entry for 'etcd'...
# Note: we shouldn't need to create a host entry for 'etcd' but it is
# faster to set up the cluster this way.
$setup_host_file = <<SCRIPT
cat >/etc/hosts <<EOF
127.0.0.1 localhost
......@@ -18,7 +26,11 @@ Vagrant.configure(API_VERSION) do |config|
config.vm.provision "shell", inline: $setup_host_file
config.vm.provision "shell" do |s|
s.path = "bootstrap.sh"
if ENV['LOCAL'].nil?
s.path = "bootstrap.sh"
else
s.path = "bootstrap-local.sh"
end
s.args = "autora.dio"
end
......@@ -32,7 +44,6 @@ Vagrant.configure(API_VERSION) do |config|
config.vm.define "node2" do |m|
m.vm.hostname = "node2"
m.vm.network "private_network", ip: "192.168.50.3"
#m.vm.provision "shell", inline: "hostname node2"
m.vm.provision "shell",
inline: "echo ETCD_SERVER=node1 > /etc/default/etcd"
end
......@@ -42,8 +53,10 @@ Vagrant.configure(API_VERSION) do |config|
m.vm.network "private_network", ip: "192.168.50.4"
m.vm.provision "shell",
inline: "echo ETCD_SERVER=node1 > /etc/default/etcd"
# Create a test mountpoint.
m.vm.provision "shell",
inline: "sleep 3 && radioctl create-mount sample.ogg"
inline: "sleep 3 && radioctl create-mount /stream.ogg"
end
end
......
#!/bin/bash
set -e
cat >/etc/default/icecast2 <<EOF
CONFIGFILE="/etc/icecast2/icecast.xml"
USERID=icecast2
GROUPID=icecast
ENABLE=true
EOF
most_recent_match() {
local pattern="$1"
ls -t ${pattern} | head -1
}
# Install the required packages.
export DEBIAN_FRONTEND=noninteractive
apt-get -q update
yes N 2>/dev/null | apt-get install -q -y runit icecast2 libcap2-bin liquidsoap
dpkg -i $(most_recent_match /vagrant/etcd_*.deb)
dpkg -i $(most_recent_match /vagrant/autoradio_*.deb)
# Install the configuration.
DOMAIN="${DOMAIN:-$1}"
if [ -n "${DOMAIN}" ]; then
echo "Autoconfigured with domain: ${DOMAIN}" 1>&2
echo "DOMAIN=${DOMAIN}" > /etc/default/autoradio
fi
echo "REDIRECTORD_OPTIONS=\"--enable-icecast-proxy\"" >> /etc/default/autoradio
echo "All done (?)" 1>&2
exit 0
<?xml version="1.0"?>
<ices>
<!-- run in background -->
<background>0</background>
<!-- where logs, etc go. -->
<logpath>/tmp</logpath>
<logfile>ices.log</logfile>
<!-- 1=error,2=warn,3=info,4=debug -->
<loglevel>4</loglevel>
<!-- set this to 1 to log to the console instead of to the file above -->
<consolelog>1</consolelog>
<!-- optional filename to write process id to -->
<!-- <pidfile>/home/ices/ices.pid</pidfile> -->
<stream>
<!-- metadata used for stream listing (not currently used) -->
<metadata>
<name>Jesus</name>
<genre>Example genre</genre>
<description>A short description of your stream</description>
</metadata>
<!-- input module
The module used here is the playlist module - it has
'submodules' for different types of playlist. There are
two currently implemented, 'basic', which is a simple
file-based playlist, and 'script' which invokes a command
to returns a filename to start playing. -->
<input>
<module>playlist</module>
<param name="type">basic</param>
<param name="file">ices-playlist.txt</param>
<!-- random play -->
<param name="random">0</param>
<!-- if the playlist get updated that start at the beginning -->
<param name="restart-after-reread">1</param>
<!-- if set to 1 , plays once through, then exits. -->
<param name="once">0</param>
</input>
<!-- Stream instance
You may have one or more instances here. This allows you to
send the same input data to one or more servers (or to different
mountpoints on the same server). Each of them can have different
parameters. This is primarily useful for a) relaying to multiple
independent servers, and b) encoding/reencoding to multiple
bitrates.
If one instance fails (for example, the associated server goes
down, etc), the others will continue to function correctly.
This example defines two instances as two mountpoints on the
same server. -->
<instance>
<!-- Server details:
You define hostname and port for the server here, along with
the source password and mountpoint. -->
<hostname>192.168.50.3</hostname>
<port>80</port>
<username>@USERNAME@</username>
<password>@PASSWORD@</password>
<mount>/stream.ogg</mount>
<!-- Reconnect parameters:
When something goes wrong (e.g. the server crashes, or the
network drops) and ices disconnects from the server, these
control how often it tries to reconnect, and how many times
it tries to reconnect. Delay is in seconds.
If you set reconnectattempts to -1, it will continue
indefinately. Suggest setting reconnectdelay to a large value
if you do this.
-->
<reconnectdelay>1</reconnectdelay>
<reconnectattempts>100000</reconnectattempts>
<!-- maxqueuelength:
This describes how long the internal data queues may be. This
basically lets you control how much data gets buffered before
ices decides it can't send to the server fast enough, and
either shuts down or flushes the queue (dropping the data)
and continues.
For advanced users only.
-->
<maxqueuelength>80</maxqueuelength>
<!-- Live encoding/reencoding:
Currrently, the parameters given here for encoding MUST
match the input data for channels and sample rate. That
restriction will be relaxed in the future.
-->
<encode>
<nominal-bitrate>64000</nominal-bitrate> <!-- bps. e.g. 64000 for 64 kbps -->
<samplerate>44100</samplerate>
<channels>2</channels>
</encode>
</instance>
</stream>
</ices>
#!/bin/sh
#
# Stream data to the test mountpoint, using 'ices2'.
#
stream=/stream.ogg
# Download a couple of test songs.
for song in song1.ogg song2.ogg ; do
test -e /vagrant/${song} || wget -O /vagrant/${song} http://www.incal.net/ale/test-songs/${song}
done
# Install Ices2.
sudo apt-get -q -y install ices2
# Create the Ices2 config file.
username=$(radioctl show-mount ${stream} | awk -F= '/^username/ {print $2}')
password=$(radioctl show-mount ${stream} | awk -F= '/^password/ {print $2}')
if [ -z "${username}" ]; then
echo "ERROR: stream ${stream} not found"
exit 1
fi
sed -e s/@USERNAME@/${username}/ -e s/@PASSWORD@/${password}/ \
< /vagrant/ices.xml.tmpl > /tmp/ices.xml
cat > /tmp/ices-playlist.txt <<EOF
/vagrant/song1.ogg
/vagrant/song2.ogg
EOF
cd /tmp
ices2 /tmp/ices.xml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment