Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
albanpeignier committed Jul 17, 2010
0 parents commit dc729fe
Show file tree
Hide file tree
Showing 43 changed files with 1,744 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
build
*~
local.rb
puppet.log
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "modules/box"]
path = modules/box
url = ../puppet-box
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright © 2010 Alban Peignier, Florent Peyraud

This program 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 3 of the License, or
(at your option) any later version.

This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source :gemcutter

gem "rake"
gem "system-builder", '>= 0.0.10'
9 changes: 9 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
== SYNOPSYS

Setup your environment :

rake setup WORKING_DIR=/var/tmp/streambox

Create a streambox disk image (in dist/) :

rake streambox:dist
87 changes: 87 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
require 'rubygems'

require 'system_builder'
require 'system_builder/task'

load './local.rb' if File.exists?("./local.rb")

release_number = Time.now.strftime('%Y%m%d-%H%M')
release_name = "stagebox-#{release_number}"

boot = SystemBuilder::DebianBoot.new("build/root")
boot.configurators << SystemBuilder::PuppetConfigurator.new(:release_name => release_name)

SystemBuilder::Task.new(:stagebox) do
SystemBuilder::DiskSquashfsImage.new("dist/disk").tap do |image|
image.boot = boot
image.size = 500.megabytes
end
end

SystemBuilder::Task.new(:"stagebox-demo") do
SystemBuilder::IsoSquashfsImage.new("dist/iso").tap do |image|
image.boot = boot
end
end

desc "Setup your environment to build a stagebox image"
task :setup => "stagebox:setup" do
if ENV['WORKING_DIR']
%w{build dist}.each do |subdir|
working_subdir = File.join ENV['WORKING_DIR'], subdir
puts "* create and link #{working_subdir}"
mkdir_p working_subdir
ln_sf working_subdir, subdir
end
end
end

task :clean do
sh "sudo sh -c \"fuser $PWD/build/root || rm -r build/root\"" if File.exists?("build/root")
rm_rf "dist"
mkdir_p "dist"
end

def create_latest_file(latest_file, release_name, release_number)
checksum = %x{sha256sum dist/upgrade.tar}.split.first
File.open(latest_file, "w") do |f|
f.puts "name: #{release_name}"
f.puts "url: http://download.tryphon.eu/stagebox/stagebox-#{release_number}.tar"
f.puts "checksum: #{checksum}"
f.puts "status_updated_at: #{Time.now}"
f.puts "description_url: http://www.tryphon.eu/release/#{release_name}"
end
end

namespace :buildbot do
task :dist do
mkdir_p target_directory = "#{ENV['HOME']}/dist/stagebox"
cp "dist/disk", "#{target_directory}/stagebox-#{release_number}.disk"
cp "dist/iso", "#{target_directory}/stagebox-#{release_number}.iso"
cp "dist/upgrade.tar", "#{target_directory}/stagebox-#{release_number}.tar"
create_latest_file "#{target_directory}/latest.yml", release_name, release_number
end
end

task :buildbot => [:clean, "dist:all", "buildbot:dist"]

namespace :dist do
desc "Create all distribuable artifacts"
task :all => [:disk, :iso, :upgrade]

desc "Create disk image"
task :disk => "stagebox:dist"

desc "Create iso image"
task :iso => "stagebox-demo:dist"

desc "Create upgrade files"
task :upgrade do
rm_rf "dist/upgrade"
mkdir_p "dist/upgrade"
ln_s File.expand_path("build/filesystem.squashfs"), "dist/upgrade/filesystem-#{release_name}.squashfs"
ln_s File.expand_path("build/root/vmlinuz"), "dist/upgrade/vmlinuz-#{release_name}"
ln_s File.expand_path("build/root/initrd.img"), "dist/upgrade/initrd-#{release_name}.img"
sh "tar -cf dist/upgrade.tar --dereference -C dist/upgrade ."
end
end
15 changes: 15 additions & 0 deletions config/qemu-ifdown-bridge
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh -x

if [ "$USER" != "root" -o "$1" != "sudo" ]; then
exec sudo -p "Password for $0:" $0 sudo $1
fi

[ "$1" = "sudo" ] && shift

bridge=br0
local_interface=eth0

ifconfig br0 down
brctl delbr br0

dhclient $local_interface
23 changes: 23 additions & 0 deletions config/qemu-ifup-bridge
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh -x

if [ "$USER" != "root" -o "$1" != "sudo" ]; then
exec sudo -p "Password for $0:" $0 sudo $1
fi

[ "$1" = "sudo" ] && shift

ip addr flush $1

bridge=br0
local_interface=eth0

ip addr flush $local_interface

brctl addbr $bridge
brctl addif $bridge $1
brctl addif $bridge $local_interface

ip link set $bridge up
ip link set $1 up

dhclient $bridge
24 changes: 24 additions & 0 deletions config/qemu-ifup-nat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh -x

if [ "$USER" != "root" -o "$1" != "sudo" ]; then
exec sudo -p "Password for $0:" $0 sudo $1
fi

[ "$1" = "sudo" ] && shift

/sbin/ifconfig $1 172.20.0.1

interfaces=`/sbin/ifconfig -s | awk '/^eth/ { print $1 }'`

for tun_interface in `/sbin/ifconfig -s | awk '/^tun/ { print $1 }'`; do
/sbin/ifconfig $tun_interface | grep -q "172.20."
if [ $? == 0 ]; then
interfaces="$interfaces $tun_interface"
fi
done

for interface in $interfaces; do
/sbin/iptables -t nat -A POSTROUTING -s 172.20.0.1/24 -o $interface -j MASQUERADE
done

/sbin/sysctl -w net.ipv4.ip_forward=1
35 changes: 35 additions & 0 deletions files/apache/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<VirtualHost *:80>
ServerName streambox.local
ServerAdmin [email protected]

DNSSDServiceName "Tryphon StreamBox"

DocumentRoot /usr/share/streamcontrol/public
PassengerDefaultUser www-data
PassengerMaxPoolSize 3
PassengerMaxRequests 10000
PassengerLogLevel 3
<Directory /usr/share/streamcontrol/public>
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Alias /munin /var/www/munin
<Directory /var/www/munin>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Location /munin>
PassengerEnabled off
</Location>

LogLevel warn

# Use only syslog
ErrorLog syslog
CustomLog "|/usr/bin/logger -p local1.info -t apache2/access" combined
</VirtualHost>
33 changes: 33 additions & 0 deletions files/darkice/darkice.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# this section describes general aspects of the live streaming session
[general]
duration = 0 # duration of encoding, in seconds. 0 means forever
bufferSecs = 5 # size of internal slip buffer, in seconds
reconnect = yes # reconnect to the server(s) if disconnected

# this section describes the audio input that will be streamed
[input]
device = /dev/dsp # OSS DSP soundcard device for the audio input
sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16 # bits per sample. try 16
channel = 2 # channels. 1 = mono, 2 = stereo

# this section describes a streaming connection to an IceCast2 server
# there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7]
# these can be mixed with [icecast-x] and [shoutcast-x] sections
[icecast2-0]
bitrateMode = vbr # average bit rate
format = vorbis # format of the stream: ogg vorbis
quality = 0.5 # bitrate of the stream sent to the server
server = localhost
# host name of the server
port = 8000 # port of the IceCast2 server, usually 8000
password = hackme # source password to the IceCast2 server
mountPoint = main # mount point of this stream on the IceCast2 server
# name = StreamBox stream
# name of the stream
# description =
# description of the stream
# url = http://www.yourserver.com
# URL related to the stream
# genre = my own # genre of the stream
# public = yes # advertise this stream?
14 changes: 14 additions & 0 deletions files/darkice/darkice.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Defaults for darkice initscript
# sourced by /etc/init.d/darkice
# installed at /etc/default/darkice by the maintainer scripts

#
# This is a POSIX shell fragment
#
RUN=yes
# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c /etc/darkice/darkice.cfg --pidfile $PIDFILE"
USER=root
GROUP=audio

DAEMON=/usr/bin/darkice-safe
Loading

0 comments on commit dc729fe

Please sign in to comment.