Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various setup.sh fixes #74

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For how the streaming system overall looks at the following diagram;
![Streaming System overall Diagram](https://docs.google.com/drawings/d/1ZN5uqd-fo62e0IZSzuOSo6YadRY_n7umkUThmqckACA/pub?w=960&h=720)


## What is Tim Video's?
# What is Tim Video's?

Tim Video's is a collection of tools for live streaming conferences and user
groups. It includes both software and hardware for both the recording and
Expand All @@ -20,6 +20,12 @@ viewing sides.
It has been used with conferences like PyCon US and Linux.conf.au and at user
groups like Sydney Linux User Group and Sydney Python User Group.

# Important information
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is in the correct location.

Maybe move it under the # Parts section and make it a subheading.


```config.private.json``` is referenced by many parts of the Tim Videos system.
It contains passwords, rooms/stream metadata, and other important information.
Please ensure this is populated early (base it from ```config.json.example```.

# Parts

* **website** - The actual website people end up seeing/going too. Uses
Expand All @@ -40,6 +46,9 @@ groups like Sydney Linux User Group and Sydney Python User Group.
tools to push the configurations out to systems. Useful for conferences
where you are managing a lot of encoders/collectors.

There is a script in here called ```pusher/pushconfig.py``` which should be used
to generate the correct Flumotion configuration files for encoders/collectors.

* **flumotion-extra** - Website controller of flumotion (replaces the GTK
tool).

Expand Down
1 change: 0 additions & 1 deletion tools/register/README

This file was deleted.

1 change: 1 addition & 0 deletions tools/register/README
13 changes: 13 additions & 0 deletions tools/register/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This script is used to register a flumotion encoder server onto the timvideos frontend system.
This should be ran on the encoder machines.

Usage (run as root in a screen/tmux session):

```python register_wrapper.py -m user:password@encoder-server -g group -s sharedsecret```

(where:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't need a "(" here...

* user:password equal flumotion manager username/password,
* group equals group/room in config.private.json on timvideos frontend,
* sharedsecret is secret in config.private.json on timvideos frontend

fake_register.py can be used to test room registration (see parent README.md)
11 changes: 11 additions & 0 deletions tools/setup/25-python-stuff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -ex
#
# Copyright 2014 Next Day Video P/L. All Rights Reserved.
# Author: [email protected] (Ryan Verner)
#
# Installs required python packages
#

sudo apt-get install python-pip
sudo pip install termcolor

7 changes: 7 additions & 0 deletions tools/setup/30-custom-flumotion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ sudo apt-get install --assume-yes build-essential autoconf autopoint libtool lib
# Dependencies to run flumotion
sudo apt-get install --assume-yes python-kiwi python-twisted.* ssl-cert

# Fix permissions issue (/usr/local/var/* can be chmod 700)
sudo chmod 755 /usr/local/var

# Install the core flumotion
(
cd ../flumotion
Expand Down Expand Up @@ -63,3 +66,7 @@ sudo chown flumotion:flumotion /usr/local/etc/flumotion/default.pem

# Give access to the firewire ports
sudo adduser flumotion video

# Give access to audio (non-dvswitch ALSA sources)
sudo adduser flumotion audio

1 change: 1 addition & 0 deletions tools/setup/40-gst-plugins-dvswitch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sudo apt-get install --assume-yes build-essential autoconf autopoint libtool lib
# build and install
(
cd
rm -fr gst-plugins-dvswitch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will fail if gst-plugins-dvswitch doesn't already exist.

git clone https://github.com/timvideos/gst-plugins-dvswitch.git
cd gst-plugins-dvswitch
git clean -f -x
Expand Down
1 change: 1 addition & 0 deletions tools/setup/runall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cd streaming-system/tools/setup
./05-update.sh
./20-gstreamer-packages.sh
./20-useful-packages.sh
./25-python-stuff.sh
./30-custom-flumotion.sh
./40-gst-plugins-dvswitch.sh
./99-remove-ppa.sh
Expand Down
1 change: 0 additions & 1 deletion tools/watchdog/README

This file was deleted.

1 change: 1 addition & 0 deletions tools/watchdog/README
9 changes: 9 additions & 0 deletions tools/watchdog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This script is used to watch and restart flumotion components.
This should be ran on the collector + encoder machines.

Usage (run as root in a screen/tmux session):

```python watchdog_wrapper.sh -m user:[email protected]```

(where user:password equal flumotion manager username/password)

12 changes: 9 additions & 3 deletions website/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ clean:
git clean -f -d

bin/activate:
virtualenv --no-site-packages .
virtualenv --always-copy --no-site-packages .
-rm distribute*.tar.gz

freeze:
Expand All @@ -45,7 +45,7 @@ third_party:

src/pip-delete-this-directory.txt: requirements.txt
$(ACTIVATE) && pip install -r requirements.txt
$(ACTIVATE) && [ -f private/requirements.txt ] && pip install -r private/requirements.txt
$(ACTIVATE) && [ -f private/requirements.txt ] && pip install -r private/requirements.txt || exit 0
touch -r requirements.txt src/pip-delete-this-directory.txt

install: lib/python2.6/site-packages/ez_setup.py lib/python2.6/site-packages/distribute-0.6.24-py2.6.egg-info src/pip-delete-this-directory.txt frontend/data.py
Expand All @@ -56,6 +56,7 @@ frontend/data.py: eventfeed2internal.py pycon2internal.py
prepare-serve: install
$(ACTIVATE) && python manage.py collectstatic --noinput
# $(ACTIVATE) && python manage.py syncdb
# $(ACTIVATE) && python manage.py migrate

lint: install
@# R0904 - Disable "Too many public methods" warning
Expand Down Expand Up @@ -84,8 +85,13 @@ config:
upload:
$(ACTIVATE) && git-cl upload

serve: prepare-serve install
initdb:
$(ACTIVATE) && python manage.py syncdb
$(ACTIVATE) && python manage.py migrate

serve: prepare-serve install
$(ACTIVATE) && python manage.py runserver ${ARGS}

testserve: prepare-serve install initdb serve

.PHONY : lint upload deploy serve clean config prepare-serve
49 changes: 40 additions & 9 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ sudo pip install virtualenv
Running a test server
=====================

Run ``make serve``; this will configure a virtualenv, download and install
Run ``make testserve``; this will configure a virtualenv, download and install
dependencies (inside the virtualenv; your system will not be touched); and a
test server will be started.

If this is your first time running ``make serve`` you'll be prompted to provide
If you recieve a "bin/activate" error, try ```make distclean``` and try again.

If this is your first time running ``make testserve`` you'll be prompted to provide
a username and password for an admin account.

This test server should not be used in production (see relevant section below).

Requests are served at http://127.0.0.1:8000 by default. If you need to change
the listening IP or port, try ```ARGS="192.168.1.1:8000" make serve``` where ARGS
the listening IP or port, try ```ARGS="192.168.1.1:8000" make testserve``` where ARGS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapping?

represents your desired listening IP and port.

This test server **should NOT be used in production** (see relevant section below).
Expand Down Expand Up @@ -82,7 +84,7 @@ This keeps on going.

Open http://127.0.0.1:8000/example to view the page

Note: DO NOT run ``make serve`` as root. If you do, virtualenv folders won't
Note: DO NOT run ``make testserve`` as root. If you do, virtualenv folders won't
have write permissions, so the tracker won't be able to write to sqlite
database.

Expand Down Expand Up @@ -138,22 +140,51 @@ Production Deployment
be persisted across deployments, you may have to take care of this in your
deploy script.

* To do the deployment, I use the ``setup.sh`` script in conf directory. It
takes a copy of the current code in ``~website/timvideos`` and puts it in
``~website/$VERSION-$DATE-$TIME`` directory and then links
``~website/current`` to that.
* **To deploy on an Ubuntu 12.04 LTS system**, run the ``setup.sh`` script in the conf/
directory. If an existing deploy doesn't exist, it will create the relevant
groups, users, install the correct packages, copy in some configuration files for
relevant daemons (nginx, etc) and git pull the project into ~website/timvideos.
**Please look at the script first if deploying on a system already used for other
things as this assumes a fairly fresh install.**.

If already deployed into ~website/timvideos, it will update from git.

The script will then copy installation over into ~website/timvideos-$VERSION-DATE-TIME and
then links ~website/current to that.

This makes it relatively easy to revert to an earlier version of the code.

The script may work on other distros, but has only been tested on Ubuntu 12.04 LTS.

* The script will ask for a production settings.py to be created using
non-sqlite details. Populate this with a real DB, such as PostgreSQL.

* On a new installation, you will need to initialise the database (this is
not done by setup.sh as it can be used for upgrades, too). You can do this
by running ```make initdb```.

* On an existing installation you may need to migrate any schema changes.
You can do this by running ```bin/python manage.py migrate```.

* The app runs inside [Green Unicorn][], and is started by
[upstart][]. Take a look at conf/init.conf

* The app uses [nginx][] as a frontend, and to serve static files. Only a few
changes from the default config are needed to accomplish this.

Take a look at conf/nginx.conf
Take a look at conf/nginx.conf (this needs to be modified).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about it needs to be modified?


[deploy key]: http://help.github.com/deploy-keys/
[Green Unicorn]: http://gunicorn.org/
[upstart]: http://upstart.ubuntu.com/
[nginx]: http://nginx.org/en/ "nginx"




Important information
=====================

```config.private.json``` is referenced by many parts of the Tim Videos system.
It contains passwords, rooms/stream metadata, and other important information.
Please ensure this is populated early (base it from ```config.json.example```.
29 changes: 24 additions & 5 deletions website/conf/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ fi
set -x
set -e

# Remove old /tmp/timvideos-static
rm -rf /tmp/timvideos-static

# Add the groups required
addgroup --system website
addgroup --system website-run
Expand All @@ -29,8 +32,9 @@ adduser $USER website-run
# Get python dependencies
apt-get -y install python-pip python-setuptools python-virtualenv

# Set up the website directory
# Set up the website directory and set current directory test deployment is running in
BASEDIR=/home/website
CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Set up upstart config file
ln -sf $BASEDIR/current/website/conf/init.conf /etc/init/website.conf
Expand Down Expand Up @@ -69,8 +73,16 @@ export VERSION=$(date +%Y%m%d-%H%M%S)-$(git describe --tags --long --always)
cd ..

if [ ! -f $BASEDIR/timvideos/website/private/settings.py ]; then
echo "Please create a settings.py file in $BASEDIR/timvideos/website/private/settings.py"
exit 1
if [ -f $CURDIR/../private/settings.py ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want to use your private settings from development?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what the next lines do (if this doesn't already exist - i.e. existing production deployment - check if this was configured in the directory the script is being ran from - which will be the dev/test directory - and copy these over). Unless I'm misunderstanding the purpose of this...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mithro as far as I'm aware (I've tested the script on new deployments, against a test deployment, against an existing prod environment) it still covers your original use case and should be OK

echo "Copying settings.py from $CURDIR to $BASEDIR..."
cp $CURDIR/../private/settings.py $BASEDIR/timvideos/website/private/settings.py
else
echo "No settings.py file found in either test or production directories."
echo "Please create a settings.py file in $BASEDIR/timvideos/website/private/settings.py"
echo "This should contain production db settings (not sqlite!)."
echo "Once this is done, run this script again."
exit 1
fi
fi

VERSIONDIR=$BASEDIR/timvideos-$VERSION
Expand All @@ -85,8 +97,15 @@ cp -R /tmp/timvideos-static $VERSIONDIR/website/static
as_website rm current || true
as_website ln -s timvideos-$VERSION current

# Need to get config-private.json
# Need to get settings-private.py
# Copy over config.private.json from previous installation
if [ ! -f $BASEDIR/timvideos/config.private.json ]; then
if [ -f $CURDIR/../../config.private.json ]; then
echo "Copying config.private.json from $CURDIR to $BASEDIR..."
cp $CURDIR/../../config.private.json $BASEDIR/timvideos/config.private.json
else
echo "No config.private.json file found!"
fi
fi

# Make upstart/gunicorn reload config file
chmod 644 $VERSIONDIR/website/conf/init.conf
Expand Down
3 changes: 3 additions & 0 deletions website/private/settings.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
# 'NAME': 'website-run',
# 'PASSWORD': '',
# 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP
# 'PORT': '', # Set to empty string for default.
# }
#}

Expand Down