trog's MediaGoblin [beta]

Supports: Debian 7 (64-bit); Ubuntu 12.04 LTS (64-bit)

Source Code

#!/bin/bash

# Warning
echo "WARNING: this is destructive. If it continues it can blow away your files & data (including an entire Postgres database."
echo "To confirm continuing, type 'yes' and hit enter: "

read ack

if [ "$ack" == "yes" ]; then
  echo "OK, here we go..."
else
  echo "Exiting."
  exit 1
fi

# Install git, Python core 
sudo apt-get -y install git-core python python-dev python-lxml python-imaging python-virtualenv

# Install postgres
sudo apt-get -y install postgresql postgresql-client python-psycopg2

# Install video
sudo apt-get -y install python-gst0.10 gstreamer0.10-plugins-base gstreamer0.10-plugins-bad gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-ffmpeg

# Postgres sets up with ASCII encoding, change it to UTF 8
# Thanks http://jacobian.org/writing/pg-encoding-ubuntu/
# FIXME: automatically get the Postgres version
sudo -u postgres pg_dropcluster --stop 9.1 main
sudo -u postgres pg_createcluster --start -e UTF-8 9.1 main

# Create MG user
sudo -u postgres createuser  --no-superuser --no-createdb --no-createrole mediagoblin

# Create the MG DB
sudo -u postgres createdb -E UNICODE -O mediagoblin mediagoblin

# Create system user
adduser --system mediagoblin

# Create the MG directory
# FIXME: is the 'users' group safe?
sudo mkdir -p /srv/mediagoblin && sudo chown -hR mediagoblin:users /srv/mediagoblin

# Install MG
cd /srv/mediagoblin
git clone git://gitorious.org/mediagoblin/mediagoblin.git
cd mediagoblin
git submodule init && git submodule update
(virtualenv --system-site-packages . || virtualenv .) && ./bin/python setup.py develop
./bin/easy_install flup

# Set up the INI file (FIXME, is this the right directory?)
cp mediagoblin.ini mediagoblin_local.ini

# Uncomment out the SQL engine line to set Postgres
sed -i 's/# sql_engine/sql_engine/' mediagoblin_local.ini 

# Allow video
echo "[[mediagoblin.media_types.video]]" >> mediagoblin_local.ini 

# Update MG DB
sudo -u mediagoblin ./bin/gmg dbupdate

# Set the permissions so MG user owns the directory
# FIXME: As above, check group is safe
sudo chown -R mediagoblin.users /srv/mediagoblin/mediagoblin/

# Start the MG server
sudo -u mediagoblin ./lazyserver.sh --server-name=broadcast start